diff options
author | KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> | 2006-03-27 04:15:58 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-27 11:44:47 -0500 |
commit | 679bc9fbb508a0aac9539b2de747eb5849feb428 (patch) | |
tree | 350b9d7d01eeb7e2401b5ade156ead1a635a4bba | |
parent | 8357f8695d58b50fbf2bd507b4b0fc2cd1e43bd6 (diff) |
[PATCH] for_each_online_pgdat: for_each_bootmem
Add a list_head to bootmem_data_t and make bootmems use it. bootmem list is
sorted by node_boot_start.
Only nodes against which init_bootmem() is called are linked to the list.
(i386 allocates bootmem only from one node(0) not from all online nodes.)
A summary:
1. for_each_online_pgdat() traverses all *online* nodes.
2. alloc_bootmem() allocates memory only from initialized-for-bootmem nodes.
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | include/linux/bootmem.h | 1 | ||||
-rw-r--r-- | mm/bootmem.c | 39 |
2 files changed, 30 insertions, 10 deletions
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h index 7155452fb4a8..de3eb8d8ae26 100644 --- a/include/linux/bootmem.h +++ b/include/linux/bootmem.h | |||
@@ -38,6 +38,7 @@ typedef struct bootmem_data { | |||
38 | unsigned long last_pos; | 38 | unsigned long last_pos; |
39 | unsigned long last_success; /* Previous allocation point. To speed | 39 | unsigned long last_success; /* Previous allocation point. To speed |
40 | * up searching */ | 40 | * up searching */ |
41 | struct list_head list; | ||
41 | } bootmem_data_t; | 42 | } bootmem_data_t; |
42 | 43 | ||
43 | extern unsigned long __init bootmem_bootmap_pages (unsigned long); | 44 | extern unsigned long __init bootmem_bootmap_pages (unsigned long); |
diff --git a/mm/bootmem.c b/mm/bootmem.c index b55bd39fc5dd..d3e3bd2ffcea 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c | |||
@@ -33,6 +33,7 @@ EXPORT_SYMBOL(max_pfn); /* This is exported so | |||
33 | * dma_get_required_mask(), which uses | 33 | * dma_get_required_mask(), which uses |
34 | * it, can be an inline function */ | 34 | * it, can be an inline function */ |
35 | 35 | ||
36 | static LIST_HEAD(bdata_list); | ||
36 | #ifdef CONFIG_CRASH_DUMP | 37 | #ifdef CONFIG_CRASH_DUMP |
37 | /* | 38 | /* |
38 | * If we have booted due to a crash, max_pfn will be a very low value. We need | 39 | * If we have booted due to a crash, max_pfn will be a very low value. We need |
@@ -52,6 +53,27 @@ unsigned long __init bootmem_bootmap_pages (unsigned long pages) | |||
52 | 53 | ||
53 | return mapsize; | 54 | return mapsize; |
54 | } | 55 | } |
56 | /* | ||
57 | * link bdata in order | ||
58 | */ | ||
59 | static void link_bootmem(bootmem_data_t *bdata) | ||
60 | { | ||
61 | bootmem_data_t *ent; | ||
62 | if (list_empty(&bdata_list)) { | ||
63 | list_add(&bdata->list, &bdata_list); | ||
64 | return; | ||
65 | } | ||
66 | /* insert in order */ | ||
67 | list_for_each_entry(ent, &bdata_list, list) { | ||
68 | if (bdata->node_boot_start < ent->node_boot_start) { | ||
69 | list_add_tail(&bdata->list, &ent->list); | ||
70 | return; | ||
71 | } | ||
72 | } | ||
73 | list_add_tail(&bdata->list, &bdata_list); | ||
74 | return; | ||
75 | } | ||
76 | |||
55 | 77 | ||
56 | /* | 78 | /* |
57 | * Called once to set up the allocator itself. | 79 | * Called once to set up the allocator itself. |
@@ -62,13 +84,11 @@ static unsigned long __init init_bootmem_core (pg_data_t *pgdat, | |||
62 | bootmem_data_t *bdata = pgdat->bdata; | 84 | bootmem_data_t *bdata = pgdat->bdata; |
63 | unsigned long mapsize = ((end - start)+7)/8; | 85 | unsigned long mapsize = ((end - start)+7)/8; |
64 | 86 | ||
65 | pgdat->pgdat_next = pgdat_list; | ||
66 | pgdat_list = pgdat; | ||
67 | |||
68 | mapsize = ALIGN(mapsize, sizeof(long)); | 87 | mapsize = ALIGN(mapsize, sizeof(long)); |
69 | bdata->node_bootmem_map = phys_to_virt(mapstart << PAGE_SHIFT); | 88 | bdata->node_bootmem_map = phys_to_virt(mapstart << PAGE_SHIFT); |
70 | bdata->node_boot_start = (start << PAGE_SHIFT); | 89 | bdata->node_boot_start = (start << PAGE_SHIFT); |
71 | bdata->node_low_pfn = end; | 90 | bdata->node_low_pfn = end; |
91 | link_bootmem(bdata); | ||
72 | 92 | ||
73 | /* | 93 | /* |
74 | * Initially all pages are reserved - setup_arch() has to | 94 | * Initially all pages are reserved - setup_arch() has to |
@@ -383,12 +403,11 @@ unsigned long __init free_all_bootmem (void) | |||
383 | 403 | ||
384 | void * __init __alloc_bootmem(unsigned long size, unsigned long align, unsigned long goal) | 404 | void * __init __alloc_bootmem(unsigned long size, unsigned long align, unsigned long goal) |
385 | { | 405 | { |
386 | pg_data_t *pgdat = pgdat_list; | 406 | bootmem_data_t *bdata; |
387 | void *ptr; | 407 | void *ptr; |
388 | 408 | ||
389 | for_each_pgdat(pgdat) | 409 | list_for_each_entry(bdata, &bdata_list, list) |
390 | if ((ptr = __alloc_bootmem_core(pgdat->bdata, size, | 410 | if ((ptr = __alloc_bootmem_core(bdata, size, align, goal, 0))) |
391 | align, goal, 0))) | ||
392 | return(ptr); | 411 | return(ptr); |
393 | 412 | ||
394 | /* | 413 | /* |
@@ -416,11 +435,11 @@ void * __init __alloc_bootmem_node(pg_data_t *pgdat, unsigned long size, unsigne | |||
416 | 435 | ||
417 | void * __init __alloc_bootmem_low(unsigned long size, unsigned long align, unsigned long goal) | 436 | void * __init __alloc_bootmem_low(unsigned long size, unsigned long align, unsigned long goal) |
418 | { | 437 | { |
419 | pg_data_t *pgdat = pgdat_list; | 438 | bootmem_data_t *bdata; |
420 | void *ptr; | 439 | void *ptr; |
421 | 440 | ||
422 | for_each_pgdat(pgdat) | 441 | list_for_each_entry(bdata, &bdata_list, list) |
423 | if ((ptr = __alloc_bootmem_core(pgdat->bdata, size, | 442 | if ((ptr = __alloc_bootmem_core(bdata, size, |
424 | align, goal, LOW32LIMIT))) | 443 | align, goal, LOW32LIMIT))) |
425 | return(ptr); | 444 | return(ptr); |
426 | 445 | ||