aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/mm/init.c
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2005-09-12 12:49:24 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-12 13:49:57 -0400
commit0a43e4bf7489074c667f24b9670ecd88f6eb0a07 (patch)
treee729588d01798bb8439d48a30d328c2cecfa7d69 /arch/x86_64/mm/init.c
parent7c7a3897f678cfafebc8ec0a5e61a814f2f24e42 (diff)
[PATCH] x86-64: Use e820_find_hole to compute reserved pages
Avoids a very dumb loop Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/x86_64/mm/init.c')
-rw-r--r--arch/x86_64/mm/init.c42
1 files changed, 5 insertions, 37 deletions
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index 47cf9163aa89..5659d979316d 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -381,35 +381,12 @@ void __init clear_kernel_mapping(unsigned long address, unsigned long size)
381 __flush_tlb_all(); 381 __flush_tlb_all();
382} 382}
383 383
384static inline int page_is_ram (unsigned long pagenr)
385{
386 int i;
387
388 for (i = 0; i < e820.nr_map; i++) {
389 unsigned long addr, end;
390
391 if (e820.map[i].type != E820_RAM) /* not usable memory */
392 continue;
393 /*
394 * !!!FIXME!!! Some BIOSen report areas as RAM that
395 * are not. Notably the 640->1Mb area. We need a sanity
396 * check here.
397 */
398 addr = (e820.map[i].addr+PAGE_SIZE-1) >> PAGE_SHIFT;
399 end = (e820.map[i].addr+e820.map[i].size) >> PAGE_SHIFT;
400 if ((pagenr >= addr) && (pagenr < end))
401 return 1;
402 }
403 return 0;
404}
405
406static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules, 384static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel, kcore_modules,
407 kcore_vsyscall; 385 kcore_vsyscall;
408 386
409void __init mem_init(void) 387void __init mem_init(void)
410{ 388{
411 int codesize, reservedpages, datasize, initsize; 389 long codesize, reservedpages, datasize, initsize;
412 int tmp;
413 390
414#ifdef CONFIG_SWIOTLB 391#ifdef CONFIG_SWIOTLB
415 if (!iommu_aperture && 392 if (!iommu_aperture &&
@@ -432,25 +409,16 @@ void __init mem_init(void)
432 409
433 /* this will put all low memory onto the freelists */ 410 /* this will put all low memory onto the freelists */
434#ifdef CONFIG_NUMA 411#ifdef CONFIG_NUMA
435 totalram_pages += numa_free_all_bootmem(); 412 totalram_pages = numa_free_all_bootmem();
436 tmp = 0;
437 /* should count reserved pages here for all nodes */
438#else 413#else
439 414
440#ifdef CONFIG_FLATMEM 415#ifdef CONFIG_FLATMEM
441 max_mapnr = end_pfn; 416 max_mapnr = end_pfn;
442 if (!mem_map) BUG(); 417 if (!mem_map) BUG();
443#endif 418#endif
444 419 totalram_pages = free_all_bootmem();
445 totalram_pages += free_all_bootmem();
446
447 for (tmp = 0; tmp < end_pfn; tmp++)
448 /*
449 * Only count reserved RAM pages
450 */
451 if (page_is_ram(tmp) && PageReserved(pfn_to_page(tmp)))
452 reservedpages++;
453#endif 420#endif
421 reservedpages = end_pfn - totalram_pages - e820_hole_size(0, end_pfn);
454 422
455 after_bootmem = 1; 423 after_bootmem = 1;
456 424
@@ -467,7 +435,7 @@ void __init mem_init(void)
467 kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START, 435 kclist_add(&kcore_vsyscall, (void *)VSYSCALL_START,
468 VSYSCALL_END - VSYSCALL_START); 436 VSYSCALL_END - VSYSCALL_START);
469 437
470 printk("Memory: %luk/%luk available (%dk kernel code, %dk reserved, %dk data, %dk init)\n", 438 printk("Memory: %luk/%luk available (%ldk kernel code, %ldk reserved, %ldk data, %ldk init)\n",
471 (unsigned long) nr_free_pages() << (PAGE_SHIFT-10), 439 (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
472 end_pfn << (PAGE_SHIFT-10), 440 end_pfn << (PAGE_SHIFT-10),
473 codesize >> 10, 441 codesize >> 10,