From: Johannes Weiner <hannes@cmpxchg.org>
To: Tejun Heo <tj@kernel.org>
Cc: mingo@elte.hu, rusty@rustcorp.com.au, tglx@linutronix.de,
x86@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com,
jeremy@goop.org, cpw@sgi.com, nickpiggin@yahoo.com.au,
ink@jurassic.park.msu.ru
Subject: Re: [PATCH 02/10] bootmem: clean up arch-specific bootmem wrapping
Date: Tue, 24 Feb 2009 12:30:44 +0100 [thread overview]
Message-ID: <20090224113044.GA2060@cmpxchg.org> (raw)
In-Reply-To: <1235445101-7882-3-git-send-email-tj@kernel.org>
On Tue, Feb 24, 2009 at 12:11:33PM +0900, Tejun Heo wrote:
> Impact: cleaner and consistent bootmem wrapping
>
> By setting CONFIG_HAVE_ARCH_BOOTMEM_NODE, archs can define
> arch-specific wrappers for bootmem allocation. However, this is done
> a bit strangely in that only the high level convenience macros can be
> changed while lower level, but still exported, interface functions
> can't be wrapped. This not only is messy but also leads to strange
> situation where alloc_bootmem() does what the arch wants it to do but
> the equivalent __alloc_bootmem() call doesn't although they should be
> able to be used interchangeably.
>
> This patch updates bootmem such that archs can override / wrap the
> backend function - alloc_bootmem_core() instead of the highlevel
> interface functions to allow simpler and consistent wrapping. Also,
> HAVE_ARCH_BOOTMEM_NODE is renamed to HAVE_ARCH_BOOTMEM.
>
> Signed-off-by: Tejun Heo <tj@kernel.org>
> Cc: Johannes Weiner <hannes@saeurebad.de>
> ---
> arch/avr32/Kconfig | 2 +-
> arch/x86/Kconfig | 2 +-
> arch/x86/include/asm/mmzone_32.h | 43 ++++---------------------------------
> include/linux/bootmem.h | 10 +++-----
> mm/bootmem.c | 14 +++++++++--
> 5 files changed, 22 insertions(+), 49 deletions(-)
>
> diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig
> index b189680..05fe305 100644
> --- a/arch/avr32/Kconfig
> +++ b/arch/avr32/Kconfig
> @@ -181,7 +181,7 @@ source "kernel/Kconfig.preempt"
> config QUICKLIST
> def_bool y
>
> -config HAVE_ARCH_BOOTMEM_NODE
> +config HAVE_ARCH_BOOTMEM
> def_bool n
>
> config ARCH_HAVE_MEMORY_PRESENT
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index d3f6ead..6fd3b23 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -1111,7 +1111,7 @@ config NODES_SHIFT
> Specify the maximum number of NUMA Nodes available on the target
> system. Increases memory reserved to accomodate various tables.
>
> -config HAVE_ARCH_BOOTMEM_NODE
> +config HAVE_ARCH_BOOTMEM
> def_bool y
> depends on X86_32 && NUMA
>
> diff --git a/arch/x86/include/asm/mmzone_32.h b/arch/x86/include/asm/mmzone_32.h
> index 07f1af4..1e0fa9e 100644
> --- a/arch/x86/include/asm/mmzone_32.h
> +++ b/arch/x86/include/asm/mmzone_32.h
> @@ -93,45 +93,12 @@ static inline int pfn_valid(int pfn)
> #endif /* CONFIG_DISCONTIGMEM */
>
> #ifdef CONFIG_NEED_MULTIPLE_NODES
> -
> -/*
> - * Following are macros that are specific to this numa platform.
> - */
> -#define reserve_bootmem(addr, size, flags) \
> - reserve_bootmem_node(NODE_DATA(0), (addr), (size), (flags))
> -#define alloc_bootmem(x) \
> - __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
> -#define alloc_bootmem_nopanic(x) \
> - __alloc_bootmem_node_nopanic(NODE_DATA(0), (x), SMP_CACHE_BYTES, \
> - __pa(MAX_DMA_ADDRESS))
> -#define alloc_bootmem_low(x) \
> - __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, 0)
> -#define alloc_bootmem_pages(x) \
> - __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
> -#define alloc_bootmem_pages_nopanic(x) \
> - __alloc_bootmem_node_nopanic(NODE_DATA(0), (x), PAGE_SIZE, \
> - __pa(MAX_DMA_ADDRESS))
> -#define alloc_bootmem_low_pages(x) \
> - __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0)
> -#define alloc_bootmem_node(pgdat, x) \
> -({ \
> - struct pglist_data __maybe_unused \
> - *__alloc_bootmem_node__pgdat = (pgdat); \
> - __alloc_bootmem_node(NODE_DATA(0), (x), SMP_CACHE_BYTES, \
> - __pa(MAX_DMA_ADDRESS)); \
> -})
> -#define alloc_bootmem_pages_node(pgdat, x) \
> -({ \
> - struct pglist_data __maybe_unused \
> - *__alloc_bootmem_node__pgdat = (pgdat); \
> - __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, \
> - __pa(MAX_DMA_ADDRESS)); \
> -})
> -#define alloc_bootmem_low_pages_node(pgdat, x) \
> +/* always use node 0 for bootmem on this numa platform */
> +#define alloc_bootmem_core(__bdata, size, align, goal, limit) \
> ({ \
> - struct pglist_data __maybe_unused \
> - *__alloc_bootmem_node__pgdat = (pgdat); \
> - __alloc_bootmem_node(NODE_DATA(0), (x), PAGE_SIZE, 0); \
> + bootmem_data_t __maybe_unused * __abm_bdata_dummy = (__bdata); \
> + __alloc_bootmem_core(NODE_DATA(0)->bdata, \
> + (size), (align), (goal), (limit)); \
> })
> #endif /* CONFIG_NEED_MULTIPLE_NODES */
This won't suffice as reserve_bootmem() doesn't use
alloc_bootmem_core(), so now you effectively removed the node-0
restriction for reserve_bootmem() on this configuration.
I wonder why this setup wants to register several bootmem nodes but
only use node 0, anyway. Does someone remember? :)
> diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
> index 95837bf..3a87f93 100644
> --- a/include/linux/bootmem.h
> +++ b/include/linux/bootmem.h
> @@ -69,10 +69,9 @@ extern int reserve_bootmem_node(pg_data_t *pgdat,
> unsigned long physaddr,
> unsigned long size,
> int flags);
> -#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
> -extern int reserve_bootmem(unsigned long addr, unsigned long size, int flags);
> -#endif
> -
> +extern int reserve_bootmem(unsigned long addr,
> + unsigned long size,
> + int flags);
> extern void *__alloc_bootmem_nopanic(unsigned long size,
> unsigned long align,
> unsigned long goal);
> @@ -94,7 +93,7 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
> unsigned long size,
> unsigned long align,
> unsigned long goal);
> -#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
> +
> #define alloc_bootmem(x) \
> __alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
> #define alloc_bootmem_nopanic(x) \
> @@ -113,7 +112,6 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,
> __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 int reserve_bootmem_generic(unsigned long addr, unsigned long size,
> int flags);
> diff --git a/mm/bootmem.c b/mm/bootmem.c
> index 51a0ccf..d7140c0 100644
> --- a/mm/bootmem.c
> +++ b/mm/bootmem.c
> @@ -37,6 +37,16 @@ static struct list_head bdata_list __initdata = LIST_HEAD_INIT(bdata_list);
>
> static int bootmem_debug;
>
> +/*
> + * If an arch needs to apply workarounds to bootmem allocation, it can
> + * set CONFIG_HAVE_ARCH_BOOTMEM and define a wrapper around
> + * __alloc_bootmem_core().
> + */
> +#ifndef CONFIG_HAVE_ARCH_BOOTMEM
> +#define alloc_bootmem_core(bdata, size, align, goal, limit) \
> + __alloc_bootmem_core((bdata), (size), (align), (goal), (limit))
> +#endif
> +
> static int __init bootmem_debug_setup(char *buf)
> {
> bootmem_debug = 1;
> @@ -382,7 +392,6 @@ int __init reserve_bootmem_node(pg_data_t *pgdat, unsigned long physaddr,
> return mark_bootmem_node(pgdat->bdata, start, end, 1, flags);
> }
>
> -#ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
> /**
> * reserve_bootmem - mark a page range as usable
> * @addr: starting address of the range
> @@ -403,7 +412,6 @@ int __init reserve_bootmem(unsigned long addr, unsigned long size,
>
> return mark_bootmem(start, end, 1, flags);
> }
> -#endif /* !CONFIG_HAVE_ARCH_BOOTMEM_NODE */
>
> static unsigned long align_idx(struct bootmem_data *bdata, unsigned long idx,
> unsigned long step)
> @@ -428,7 +436,7 @@ static unsigned long align_off(struct bootmem_data *bdata, unsigned long off,
> return ALIGN(base + off, align) - base;
> }
>
> -static void * __init alloc_bootmem_core(struct bootmem_data *bdata,
> +static void * __init __alloc_bootmem_core(struct bootmem_data *bdata,
> unsigned long size, unsigned long align,
> unsigned long goal, unsigned long limit)
static but you refer to it in arch/x86/include/mmzone_32.h.
Hannes
next prev parent reply other threads:[~2009-02-24 11:29 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-24 3:11 [PATCHSET x86/core/percpu] improve the first percpu chunk allocation Tejun Heo
2009-02-24 3:11 ` [PATCH 01/10] percpu: fix pcpu_chunk_struct_size Tejun Heo
2009-02-24 3:11 ` [PATCH 02/10] bootmem: clean up arch-specific bootmem wrapping Tejun Heo
2009-02-24 11:30 ` Johannes Weiner [this message]
2009-02-24 11:39 ` Tejun Heo
2009-02-24 3:11 ` [PATCH 03/10] bootmem: reorder interface functions and add a missing one Tejun Heo
2009-02-24 3:11 ` [PATCH 04/10] vmalloc: add @align to vm_area_register_early() Tejun Heo
2009-02-24 3:11 ` [PATCH 05/10] x86: update populate_extra_pte() and add populate_extra_pmd() Tejun Heo
2009-02-24 3:11 ` [PATCH 06/10] percpu: remove unit_size power-of-2 restriction Tejun Heo
2009-02-24 3:11 ` [PATCH 07/10] percpu: give more latitude to arch specific first chunk initialization Tejun Heo
2009-02-24 3:11 ` [PATCH 08/10] x86: separate out setup_pcpu_4k() from setup_per_cpu_areas() Tejun Heo
2009-02-24 3:11 ` [PATCH 09/10] x86: add embedding percpu first chunk allocator Tejun Heo
2009-02-24 3:11 ` [PATCH 10/10] x86: add remapping " Tejun Heo
2009-02-24 9:57 ` [PATCHSET x86/core/percpu] improve the first percpu chunk allocation Ingo Molnar
2009-02-24 11:48 ` Tejun Heo
2009-02-24 12:40 ` Ingo Molnar
2009-02-24 13:27 ` Tejun Heo
2009-02-24 14:12 ` Ingo Molnar
2009-02-24 14:37 ` Tejun Heo
2009-02-24 15:15 ` Ingo Molnar
2009-02-24 23:33 ` Tejun Heo
2009-03-04 0:03 ` Rusty Russell
2009-03-04 0:15 ` H. Peter Anvin
2009-03-04 0:50 ` Ingo Molnar
2009-02-24 12:51 ` Ingo Molnar
2009-02-24 14:47 ` Tejun Heo
2009-02-24 15:19 ` Ingo Molnar
2009-02-24 15:30 ` Nick Piggin
2009-02-24 13:02 ` Ingo Molnar
2009-02-24 14:40 ` Tejun Heo
2009-02-24 20:17 ` Ingo Molnar
2009-02-24 20:51 ` Ingo Molnar
2009-02-24 21:02 ` Yinghai Lu
2009-02-24 21:12 ` [PATCH] x86: check range in reserve_early() -v2 Yinghai Lu
2009-02-24 21:16 ` [PATCHSET x86/core/percpu] improve the first percpu chunk allocation Ingo Molnar
2009-02-25 2:09 ` [PATCH x86/core/percpu 1/2] x86, percpu: fix minor bugs in setup_percpu.c Tejun Heo
2009-02-25 2:10 ` [PATCH x86/core/percpu 2/2] x86: convert cacheflush macros inline functions Tejun Heo
2009-02-25 2:23 ` [PATCHSET x86/core/percpu] improve the first percpu chunk allocation Tejun Heo
2009-02-25 2:56 ` Tejun Heo
2009-02-25 12:59 ` Ingo Molnar
2009-02-25 13:43 ` WARNING: at include/linux/percpu.h:159 __create_workqueue_key+0x1f6/0x220() Ingo Molnar
2009-02-26 2:03 ` [PATCH core/percpu] percpu: fix too low alignment restriction on UP Tejun Heo
2009-02-26 3:26 ` Ingo Molnar
2009-02-25 6:40 ` [PATCHSET x86/core/percpu] improve the first percpu chunk allocation Rusty Russell
2009-02-25 12:54 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090224113044.GA2060@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=cpw@sgi.com \
--cc=hpa@zytor.com \
--cc=ink@jurassic.park.msu.ru \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=nickpiggin@yahoo.com.au \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox