2010-11-16 21:32:49

by Suresh Siddha

[permalink] [raw]
Subject: [patch 1/2] bootmem: add alloc_bootmem_align()

Signed-off-by: Suresh Siddha <[email protected]>
Acked-by: H. Peter Anvin <[email protected]>
---
include/linux/bootmem.h | 2 ++
1 file changed, 2 insertions(+)

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) \


2010-11-16 22:14:30

by H. Peter Anvin

[permalink] [raw]
Subject: Re: [patch 1/2] bootmem: add alloc_bootmem_align()

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))


?

-hpa

2010-11-17 00:06:57

by Suresh Siddha

[permalink] [raw]
Subject: Re: [patch 1/2] bootmem: add alloc_bootmem_align()

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

2010-12-14 00:49:17

by Suresh Siddha

[permalink] [raw]
Subject: [tip:x86/urgent] bootmem: Add alloc_bootmem_align()

Commit-ID: 53dde5f385bc56e312f78b7cb25ffaf8efd4735d
Gitweb: http://git.kernel.org/tip/53dde5f385bc56e312f78b7cb25ffaf8efd4735d
Author: Suresh Siddha <[email protected]>
AuthorDate: Tue, 16 Nov 2010 13:23:50 -0800
Committer: H. Peter Anvin <[email protected]>
CommitDate: Mon, 13 Dec 2010 16:11:13 -0800

bootmem: Add alloc_bootmem_align()

Add an alloc_bootmem_align() interface to allocate bootmem with
specified alignment. This is necessary to be able to allocate the
xsave area in a subsequent patch.

Signed-off-by: Suresh Siddha <[email protected]>
LKML-Reference: <[email protected]>
Acked-by: H. Peter Anvin <[email protected]>
Signed-off-by: H. Peter Anvin <[email protected]>
Cc: <[email protected]>
---
include/linux/bootmem.h | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h
index 266ab92..499dfe9 100644
--- a/include/linux/bootmem.h
+++ b/include/linux/bootmem.h
@@ -105,6 +105,8 @@ extern void *__alloc_bootmem_low_node(pg_data_t *pgdat,

#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) \