bdata and pgdat initialization cleanup [1/5] change alloc_bootmem_node arg
Subsystems (2)
RFC PATCH 1/1 bdata and pgdat initialization cleanup [1/5] change alloc_bootmem_node arg
Hi,
After reading node-hot-add patch discussion, I started to rewrite pgdat initialization codes to share them with node_hot_add codes.
But they look too complicated... so, I'd like to start from making
it clean :) Following patches are just for review before writing tons of each-arch patches. I'm now testing these on i386.
-- Kame
pgdat initialization is affected by bootmem initialization to some extent. This increases complexity of bootmem codes.
As a first step, this patch modifies generic bootmem allocator and pgdat_link. These patches divide bootmem and pgdat.
This patch does
- define bootmem[MAX_NUMNODES] and BOOTMEM(i)
All archs/config can use this. (MAX_NUMNODES=1 when FLATMEM)
- rewrite bootmem funcs based on bootmem_data_t instead of pg_data_t.
- pgdat_link initialization is removed. so for_each_pgdat cannot work. this is fixed by the next patch.
- for_each_pgdat() for bootmem allocater is changed to list_for_each_entry(bdata, bdata_list, list). By this, CONFIG_HAVE_ARCH_BOOTMEM_NODE can be removed. (order of bootmem's list should be carefully checked.) i.e if init_bootmem_node(node) is not called, the node is not a target of alloc_bootmem().
Patches for each archs (which has NUMA configs) will follow after patches for generic codes.
Sigh, this will change many callers of alloc_bootmem_node().
include/linux/bootmem.h +31 -16
@@ -38,8 +38,19 @@ typedef struct bootmem_data {unsigned long last_pos;unsigned long last_success;/* Previous allocation point. To speed * up searching */ +struct list_head list; } bootmem_data_t; +extern bootmem_data_t bootmem[MAX_NUMNODES ]; + +#ifndef BOOTMEM +#ifdef CONFIG_NUMA +#define BOOTMEM (i) (&bootmem[(i)]) +#else +#define BOOTMEM (i) (&bootmem[0]) +#endif +#endif /* BOOTMEM */ +extern unsigned long __init bootmem_bootmap_pages (unsigned long );extern unsigned long __init init_bootmem (unsigned long addr,unsigned long memend);extern void __init free_bootmem (unsigned long addr,unsigned long size);
@@ -47,11 +58,11 @@ extern void * __init __alloc_bootmem (unextern void *__init __alloc_bootmem_low (unsigned long size,unsigned long align,unsigned long goal); -extern void *__init __alloc_bootmem_low_node (pg_data_t *pgdat, +extern void *__init __alloc_bootmem_low_node (bootmem_data_t *bdata,unsigned long size,unsigned long align,unsigned long goal); -#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE +extern void __init reserve_bootmem (unsigned long addr,unsigned long size);#define alloc_bootmem (x) \ __alloc_bootmem((x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
@@ -61,21 +72,25 @@ extern void __init reserve_bootmem (unsi __alloc_bootmem((x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))#define alloc_bootmem_low_pages (x) \ __alloc_bootmem_low((x), PAGE_SIZE, 0) -#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ +extern unsigned long __init free_all_bootmem (void ); -extern void *__init __alloc_bootmem_node (pg_data_t *pgdat,unsigned long size,unsigned long align,unsigned long goal); -extern unsigned long __init init_bootmem_node (pg_data_t *pgdat,unsigned long freepfn,unsigned long startpfn,unsigned long endpfn); -extern void __init reserve_bootmem_node (pg_data_t *pgdat,unsigned long physaddr,unsigned long size); -extern void __init free_bootmem_node (pg_data_t *pgdat,unsigned long addr,unsigned long size); -extern unsigned long __init free_all_bootmem_node (pg_data_t *pgdat); -#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE -#define alloc_bootmem_node (pgdat, x) \ - __alloc_bootmem_node((pgdat), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS)) -#define alloc_bootmem_pages_node (pgdat, x) \ - __alloc_bootmem_node((pgdat), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) -#define alloc_bootmem_low_pages_node (pgdat, x) \ - __alloc_bootmem_low_node((pgdat), (x), PAGE_SIZE, 0) -#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */ +extern void *__init __alloc_bootmem_node (bootmem_data_t *bdata, +unsigned long size,unsigned long align,unsigned long goal); +extern unsigned long __init init_bootmem_node (bootmem_data_t *bdata, +unsigned long freepfn,unsigned long startpfn,unsigned long endpfn); +extern void __init reserve_bootmem_node (bootmem_data_t *bdata, +unsigned long physaddr,unsigned long size); +extern void __init free_bootmem_node (bootmem_data_t *bdata, +unsigned long addr,unsigned long size); +extern unsigned long __init free_all_bootmem_node (bootmem_data_t *bdata); + +#define alloc_bootmem_node (bdata, x) \ + __alloc_bootmem_node((bdata), (x), SMP_CACHE_BYTES,\ + __pa(MAX_DMA_ADDRESS)) +#define alloc_bootmem_pages_node (bdata, x) \ + __alloc_bootmem_node((bdata), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS)) +#define alloc_bootmem_low_pages_node (bdata, x) \ + __alloc_bootmem_low_node((bdata), (x), PAGE_SIZE, 0)#ifdef CONFIG_HAVE_ARCH_ALLOC_REMAP extern void *alloc_remap (int nid,unsigned long size);
mm/bootmem.c +37 -34
167 lines not on this page · raw message
mm/page_alloc.c +1 -2
@@ -2225,8 +2225,7 @@ void __init free_area_init_node(int nid, }#ifndef CONFIG_NEED_MULTIPLE_NODES -static bootmem_data_t contig_bootmem_data; -struct pglist_data contig_page_data = { .bdata = &contig_bootmem_data }; +struct pglist_data contig_page_data = { .bdata =BOOTMEM (0 )};EXPORT_SYMBOL (contig_page_data);#endif
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>