Re: [patch 1/2] bootmem: add alloc_bootmem_align()
From: Suresh Siddha
Date: Tue Nov 16 2010 - 19:07:03 EST
On Tue, 2010-11-16 at 14:14 -0800, H. Peter Anvin wrote:
> On 11/16/2010 01:23 PM, Suresh Siddha wrote:
> > Index: tree/include/linux/bootmem.h
> > ===================================================================
> > --- tree.orig/include/linux/bootmem.h
> > +++ tree/include/linux/bootmem.h
> > @@ -105,6 +105,8 @@ extern void *__alloc_bootmem_low_node(pg
> >
> > #define alloc_bootmem(x) \
> > __alloc_bootmem(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
> > +#define alloc_bootmem_align(x, align) \
> > + __alloc_bootmem(x, align, __pa(MAX_DMA_ADDRESS))
> > #define alloc_bootmem_nopanic(x) \
> > __alloc_bootmem_nopanic(x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
> > #define alloc_bootmem_pages(x) \
>
> [...]
>
> > */
> > - init_xstate_buf = alloc_bootmem(xstate_size);
> > + init_xstate_buf = alloc_bootmem_align(xstate_size,
> > + __alignof__(struct xsave_struct));
> > init_xstate_buf->i387.mxcsr = MXCSR_DEFAULT;
>
> Perhaps it would make even more sense to have:
>
> #define alloc_bootmem_alignof(x, type) \
> __alloc_bootmem(x, __alignof__(type), __pa(MAX_DMA_ADDRESS))
>
Wanted to keep it broad so that more people can start using it.
For example, most of the current x86 uses of alloc_bootmem_pages() (or
the __alloc_bootmem() calls in other architectures) can be replaced with
alloc_bootmem_align() and most of them don't have a relevant type to
describe the alignment.
thanks,
suresh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/