slab: always follow arch requested alignments
Subsystems (2)
PATCH 1/1 slab: always follow arch requested alignments
From: Heiko Carstens <[email protected]>
In kmem_cache_create(): always check if BYTES_PER_WORD is less than ARCH_SLAB_MINALIGN and disable debug options that would set the alignment to BYTES_PER_WORD.
This will make sure that all slab caches will have at least an ARCH_SLAB_MINALIGN alignment.
In addition make sure that a caller mandated align which is greater than BYTES_PER_WORD also disables the same debug options. This makes sure that ARCH_KMALLOC_MINALIGN also has an effect if CONFIG_DEBUG_SLAB is set.
---
mm/slab.c | 6 ++++++ 1 file changed, 6 insertions(+)
mm/slab.c +6 -0
@@ -2103,12 +2103,18 @@ #endifif (ralign >BYTES_PER_WORD ) flags &= ~(SLAB_RED_ZONE |SLAB_STORE_USER ); } +if (BYTES_PER_WORD <ARCH_SLAB_MINALIGN ) + flags &= ~(SLAB_RED_ZONE |SLAB_STORE_USER ); +/* 3) caller mandated alignment: disables debug if necessary */ if (ralign < align) { ralign = align;if (ralign >BYTES_PER_WORD ) flags &= ~(SLAB_RED_ZONE |SLAB_STORE_USER ); } +if (align >BYTES_PER_WORD ) + flags &= ~(SLAB_RED_ZONE |SLAB_STORE_USER ); +/* * 4) Store it. Note that the debug code below can reduce * the alignment to BYTES_PER_WORD.
Quoted 10 lines · Heiko Carstens
In
kmem_cache_create(): always check ifBYTES_PER_WORDis less thanARCH_SLAB_MINALIGNand disable debug options that would set the alignment toBYTES_PER_WORD.
This will make sure that all slab caches will have at least anARCH_SLAB_MINALIGNalignment.In addition make sure that a caller mandated align which is greater than
BYTES_PER_WORDalso disables the same debug options. This makes sure thatARCH_KMALLOC_MINALIGNalso has an effect ifCONFIG_DEBUG_SLABis set.
Ok, but why?
Pekka
Quoted 3 lines · Heiko Carstens
In
kmem_cache_create(): always check ifBYTES_PER_WORDis less thanARCH_SLAB_MINALIGNand disable debug options that would set the alignment toBYTES_PER_WORD.
Why disable debug options?
Quoted 2 lines
This will make sure that all slab caches will have at least an
ARCH_SLAB_MINALIGNalignment.
You can specify alignment at cache creation. Why do we need all slabs to be aligned?
Quoted 4 lines
In addition make sure that a caller mandated align which is greater than
BYTES_PER_WORDalso disables the same debug options. This makes sure thatARCH_KMALLOC_MINALIGNalso has an effect ifCONFIG_DEBUG_SLABis set.
Is there a particular problem you are trying to address?
Quoted 7 lines · Christoph Lameter
Quoted 3 lines · Heiko Carstens
In
kmem_cache_create(): always check ifBYTES_PER_WORDis less thanARCH_SLAB_MINALIGNand disable debug options that would set the alignment toBYTES_PER_WORD.Why disable debug options?
Because if they are still enabled we would end up with an BYTES_PER_WORD alignment (which is bad, see below).
Quoted 5 lines
Quoted 2 lines
This will make sure that all slab caches will have at least an
ARCH_SLAB_MINALIGNalignment.You can specify alignment at cache creation. Why do we need all slabs to be aligned?
Uhm, that's the meaning of ARCH_SLAB_MINALIGN, isn't it?
from mm/slab.c :
#ifndef ARCH_SLAB_MINALIGN
/*
* Enforce a minimum alignment for all caches.
* Intended for archs that get misalignment faults even for BYTES_PER_WORD
* aligned buffers. Includes ARCH_KMALLOC_MINALIGN.
* If possible: Do not enable this flag for CONFIG_DEBUG_SLAB, it disables
* some debug features.
*/
#define ARCH_SLAB_MINALIGN 0
#endif
Quoted 6 lines
Quoted 4 lines
In addition make sure that a caller mandated align which is greater than
BYTES_PER_WORDalso disables the same debug options. This makes sure thatARCH_KMALLOC_MINALIGNalso has an effect ifCONFIG_DEBUG_SLABis set.Is there a particular problem you are trying to address?
Sorry, I should have mentioned it: on s390 (32 bit) we set #define ARCH_KMALLOC_MINALIGN 8.
This is needed since our common I/O layer allocates data structures that need to have an eight byte alignment. Now, if I turn on DEBUG_SLAB, nothing works anymore, simply because the slab cache code ignores ARCH_KMALLOC_MINALIGN and uses an BYTES_PER_WORD alignment instead, which it shouldn't:
also from mm/slab.c :
#ifndef ARCH_KMALLOC_MINALIGN
/*
* Enforce a minimum alignment for the kmalloc caches.
* Usually, the kmalloc caches are cache_line_size() aligned, except when
* DEBUG and FORCED_DEBUG are enabled, then they are BYTES_PER_WORD aligned.
* Some archs want to perform DMA into kmalloc caches and need a guaranteed
* alignment larger than BYTES_PER_WORD. ARCH_KMALLOC_MINALIGN allows that.
* Note that this flag disables some debug features.
*/
#define ARCH_KMALLOC_MINALIGN 0
#endif
Since that didn't work I thought why not set ARCH_SLAB_MINALIGN to 8, since that would (according to the description) guarantee that _all_ caches would have an 8 byte alignment. But that didn't work too.
So the result is this patch, which makes DEBUG_SLAB work on s390. And actually guarantees what the above descriptions imply (unless the patch is broken).
Quoted 21 lines · Heiko Carstens
Sorry, I should have mentioned it: on s390 (32 bit) we set #define
ARCH_KMALLOC_MINALIGN8.
This is needed since our common I/O layer allocates data structures that need to have an eight byte alignment. Now, if I turn onDEBUG_SLAB, nothing works anymore, simply because the slab cache code ignoresARCH_KMALLOC_MINALIGNand uses anBYTES_PER_WORDalignment instead, which it shouldn't:also from
mm/slab.c:#ifndef
ARCH_KMALLOC_MINALIGN
/*
* Enforce a minimum alignment for the kmalloc caches.
* Usually, the kmalloc caches arecache_line_size()aligned, except when
* DEBUG andFORCED_DEBUGare enabled, then they areBYTES_PER_WORDaligned.
* Some archs want to perform DMA into kmalloc caches and need a guaranteed
* alignment larger thanBYTES_PER_WORD.ARCH_KMALLOC_MINALIGNallows that.
* Note that this flag disables some debug features.
*/
#defineARCH_KMALLOC_MINALIGN0
#endif
Quoted 3 lines
Since that didn't work I thought why not set
ARCH_SLAB_MINALIGNto 8, since that would (according to the description) guarantee that _all_ caches would have an 8 byte alignment. But that didn't work too.
Why did that not work
See kmem_cache_create():
/* 2) arch mandated alignment: disables debug if necessary */
if (ralign < ARCH_SLAB_MINALIGN) {
ralign = ARCH_SLAB_MINALIGN;
if (ralign > BYTES_PER_WORD)
flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER);
}Quoted 7 lines · Christoph Lameter
Quoted 3 lines · Heiko Carstens
Since that didn't work I thought why not set
ARCH_SLAB_MINALIGNto 8, since that would (according to the description) guarantee that _all_ caches would have an 8 byte alignment. But that didn't work too.Why did that not work
Quoted 7 lines
See
kmem_cache_create():/* 2) arch mandated alignment: disables debug if necessary */ if (ralign < ARCH_SLAB_MINALIGN) { ralign = ARCH_SLAB_MINALIGN; if (ralign > BYTES_PER_WORD) flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER); }
That is because if kmem_cache_create gets called with SLAB_HWCACHE_ALIGN set in flags then ralign will be greater or equal to ARCH_SLAB_MINALIGN:
/* 1) arch recommendation: can be overridden for debug */
if (flags & SLAB_HWCACHE_ALIGN) {
[...]
ralign = cache_line_size();
[...]Therefore the test above will be passed and SLAB_RED_ZONE and SLAB_STORE_USER will stay in flags.cache_line_size() will return 256 on s390.
Quoted 9 lines · Heiko Carstens
Quoted 8 lines
See
kmem_cache_create():/* 2) arch mandated alignment: disables debug if necessary */ if (ralign < ARCH_SLAB_MINALIGN) { ralign = ARCH_SLAB_MINALIGN; if (ralign > BYTES_PER_WORD) flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER); }
Quoted 8 lines
That is because if
kmem_cache_creategets called withSLAB_HWCACHE_ALIGNset in flags then ralign will be greater or equal toARCH_SLAB_MINALIGN:/* 1) arch recommendation: can be overridden for debug */ if (flags & SLAB_HWCACHE_ALIGN) { [...] ralign = cache_line_size(); [...]
Ok. Then you do not have a problem because ralign is greater than ARCH_SLAB_MINALIGN.
Quoted 3 lines
Therefore the test above will be passed and
SLAB_RED_ZONEandSLAB_STORE_USERwill stay in flags.cache_line_size()will return 256 on s390.
Looks as if you would have the correct alignment then. I still do not understand where the problem is since you want to align on an 8 byte boundary.
Quoted 21 lines · Christoph Lameter
Quoted 8 lines · Heiko Carstens
Quoted 7 lines
See
kmem_cache_create():/* 2) arch mandated alignment: disables debug if necessary */ if (ralign < ARCH_SLAB_MINALIGN) { ralign = ARCH_SLAB_MINALIGN; if (ralign > BYTES_PER_WORD) flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER); }Quoted 8 lines
That is because if
kmem_cache_creategets called withSLAB_HWCACHE_ALIGNset in flags then ralign will be greater or equal toARCH_SLAB_MINALIGN:/* 1) arch recommendation: can be overridden for debug */ if (flags & SLAB_HWCACHE_ALIGN) { [...] ralign = cache_line_size(); [...]Ok. Then you do not have a problem because ralign is greater than
ARCH_SLAB_MINALIGN.
Quoted 7 lines
Quoted 3 lines
Therefore the test above will be passed and
SLAB_RED_ZONEandSLAB_STORE_USERwill stay in flags.cache_line_size()will return 256 on s390.Looks as if you would have the correct alignment then. I still do not understand where the problem is since you want to align on an 8 byte boundary.
CONFIG_DEBUG_SLAB is on. In step 4) we have align = ralign. Still ok.
Next thing:
if (flags & SLAB_RED_ZONE) {
/* redzoning only works with word aligned caches */
align = BYTES_PER_WORD;Result: align is less than ARCH_SLAB_MINALIGN -> busted. Same is true if SLAB_STORE_USER is set. Therefore I masked them both out in my patch.
Quoted 34 lines · Heiko Carstens
Quoted 21 lines · Christoph Lameter
Quoted 8 lines · Heiko Carstens
Quoted 7 lines
See
kmem_cache_create():/* 2) arch mandated alignment: disables debug if necessary */ if (ralign < ARCH_SLAB_MINALIGN) { ralign = ARCH_SLAB_MINALIGN; if (ralign > BYTES_PER_WORD) flags &= ~(SLAB_RED_ZONE | SLAB_STORE_USER); }Quoted 8 lines
That is because if
kmem_cache_creategets called withSLAB_HWCACHE_ALIGNset in flags then ralign will be greater or equal toARCH_SLAB_MINALIGN:/* 1) arch recommendation: can be overridden for debug */ if (flags & SLAB_HWCACHE_ALIGN) { [...] ralign = cache_line_size(); [...]Ok. Then you do not have a problem because ralign is greater than
ARCH_SLAB_MINALIGN.Quoted 7 lines
Quoted 3 lines
Therefore the test above will be passed and
SLAB_RED_ZONEandSLAB_STORE_USERwill stay in flags.cache_line_size()will return 256 on s390.Looks as if you would have the correct alignment then. I still do not understand where the problem is since you want to align on an 8 byte boundary.
CONFIG_DEBUG_SLABis on. In step 4) we have align = ralign. Still ok.
Next thing:
Quoted 7 lines
if (flags & SLAB_RED_ZONE) { /* redzoning only works with word aligned caches */ align = BYTES_PER_WORD;Result: align is less than
ARCH_SLAB_MINALIGN-> busted. Same is true ifSLAB_STORE_USERis set. Therefore I masked them both out in my patch.
Since I didn't get an ACK or NACK, I split this patch into two very small ones and repost them. Hopefully with a better description than the first time.
Hi Heiko,
Quoted 3 lines · Heiko Carstens
Since I didn't get an ACK or NACK, I split this patch into two very small ones and repost them. Hopefully with a better description than the first time.
I don't see ARCH_SLAB_MINALIGN defined for s390, what's up with that? I agree that we should always respect ARCH_SLAB_MINALIGN no matter what. Does the included patch fix that for you?
Pekka
[PATCH] slab: respect mandated minimum architecture alignment
The slab debugging code for SLAB_RED_ZONE and SLAB_STORE_USER require BYTES_PER_WORD alignment for the caches. However, for some architectures, the mandated minimum alignment might be bigger than that, so disable debugging for those cases instead of crashing the machine.
---
mm/slab.c +7 -0
@@ -2123,6 +2123,13 @@ #endif#if DEBUG cachep->obj_size = size; +/* +* Debugging requires BYTES_PER_WORD alignment but we must always +* respect ARCH_SLAB_MINALIGN so disable debugging if necessary. +*/ +if (ARCH_SLAB_MINALIGN >BYTES_PER_WORD ) + flags &= ~(SLAB_RED_ZONE |SLAB_STORE_USER ); +if (flags &SLAB_RED_ZONE ) {/* redzoning only works with word aligned caches */ align =BYTES_PER_WORD ;
PATCH 1/2 slab: always consider caller mandated alignment
In reply to Heiko CarstensFrom: Heiko Carstens <[email protected]>
In case of CONFIG_DEBUG_SLAB kmem_cache_create() creates caches with an alignment lesser than ARCH_KMALLOC_MINALIGN. This breaks s390 (32bit), since it needs an eight byte alignment. Also it doesn't behave like it's decribed in mm/slab.c :
* Enforce a minimum alignment for the kmalloc caches.
* Usually, the kmalloc caches are cache_line_size() aligned, except when
* DEBUG and FORCED_DEBUG are enabled, then they are BYTES_PER_WORD aligned.
* Some archs want to perform DMA into kmalloc caches and need a guaranteed
* alignment larger than BYTES_PER_WORD. ARCH_KMALLOC_MINALIGN allows that.
* Note that this flag disables some debug features.
For example the following might happen if kmem_cache_create() gets called with -- size: 64; align: 8; flags with SLAB_HWCACHE_ALIGN, SLAB_RED_ZONE and SLAB_STORE_USER set.
These are the steps as numbered in kmem_cache_create() where 5) is after the "if (flags & SLAB_RED_ZONE)" statement.
1) align: 8 ralign 64
2) align: 8 ralign 64
3) align: 8 ralign 64
4) align: 64 ralign 64
5) align: 4 ralign 64
Note that in this case in step 3) the flags SLAB_RED_ZONE and SLAB_STORE_USER don't get masked out and that this causes an BYTES_PER_WORD alignment in step 5) which breaks s390.
---
mm/slab.c | 3 +++ 1 files changed, 3 insertions(+)
mm/slab.c +3 -0
@@ -2109,6 +2109,9 @@if (ralign >BYTES_PER_WORD ) flags &= ~(SLAB_RED_ZONE |SLAB_STORE_USER ); } +if (align >BYTES_PER_WORD ) + flags &= ~(SLAB_RED_ZONE |SLAB_STORE_USER ); +/* * 4) Store it. Note that the debug code below can reduce * the alignment to BYTES_PER_WORD.
PATCH 2/2 slab: always consider arch mandated alignment
In reply to Heiko CarstensFrom: Heiko Carstens <[email protected]>
Since ARCH_KMALLOC_MINALIGN didn't work on s390 I tried ARCH_SLAB_MINALIGN instead, just to find out that it didn't work too.
In case of CONFIG_DEBUG_SLAB kmem_cache_create() creates caches with an alignment lesser than ARCH_SLAB_MINALIGN, which it shouldn't according to this comment in mm/slab.c :
* Enforce a minimum alignment for all caches.
* Intended for archs that get misalignment faults even for BYTES_PER_WORD
* aligned buffers. Includes ARCH_KMALLOC_MINALIGN.
* If possible: Do not enable this flag for CONFIG_DEBUG_SLAB, it disables
* some debug features.
For example the following might happen if kmem_cache_create() gets called with -- size: 64; align: 0; flags with SLAB_HWCACHE_ALIGN, SLAB_RED_ZONE and SLAB_STORE_USER set. ARCH_SLAB_MINALIGN is 8.
These are the steps as numbered in kmem_cache_create() where 5) is after the "if (flags & SLAB_RED_ZONE)" statement.
1) align: 0 ralign 64
2) align: 0 ralign 64
3) align: 0 ralign 64
4) align: 64 ralign 64
5) align: 4 ralign 64
Note that in this case in step 2) the flags SLAB_RED_ZONE and SLAB_STORE_USER don't get masked out and that this causes an BYTES_PER_WORD alignment in step 5) which is lesser than ARCH_SLAB_MINALIGN.
---
mm/slab.c | 3 +++ 1 files changed, 3 insertions(+)
mm/slab.c +3 -0
@@ -2103,6 +2103,9 @@if (ralign >BYTES_PER_WORD ) flags &= ~(SLAB_RED_ZONE |SLAB_STORE_USER ); } +if (BYTES_PER_WORD <ARCH_SLAB_MINALIGN ) + flags &= ~(SLAB_RED_ZONE |SLAB_STORE_USER ); +/* 3) caller mandated alignment: disables debug if necessary */ if (ralign < align) { ralign = align;
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 5 lines · Heiko Carstens
Since
ARCH_KMALLOC_MINALIGNdidn't work on s390 I triedARCH_SLAB_MINALIGNinstead, just to find out that it didn't work too.
In case ofCONFIG_DEBUG_SLABkmem_cache_create()creates caches with an alignment lesser thanARCH_SLAB_MINALIGN, which it shouldn't according to this comment inmm/slab.c:
[snip]
Quoted 5 lines
Index:
linux-2.6/mm/slab.c
===================================================================
mm/slab.c line 2111
Quoted 9 lines
mm/slab.c +3
-0@@ -2103,6 +2103,9 @@if (ralign >BYTES_PER_WORD ) flags &= ~(SLAB_RED_ZONE |SLAB_STORE_USER ); } +if (BYTES_PER_WORD <ARCH_SLAB_MINALIGN ) + flags &= ~(SLAB_RED_ZONE |SLAB_STORE_USER ); +/* 3) caller mandated alignment: disables debug if necessary */ if (ralign < align) { ralign = align;
This is similar to my patch and should be enough to fix the problem. The first patch seems bogus and I don't really understand why you would need it.
Pekka
--
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>
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 19 lines · Pekka J Enberg
Quoted 5 lines · Heiko Carstens
Since
ARCH_KMALLOC_MINALIGNdidn't work on s390 I triedARCH_SLAB_MINALIGNinstead, just to find out that it didn't work too.
In case ofCONFIG_DEBUG_SLABkmem_cache_create()creates caches with an alignment lesser thanARCH_SLAB_MINALIGN, which it shouldn't according to this comment inmm/slab.c:[snip]
Quoted 10 lines
Index:
linux-2.6/mm/slab.c
===================================================================mm/slab.c +2
-0@@ -2103,6 +2103,9 @@if (ralign >BYTES_PER_WORD ) flags &= ~(SLAB_RED_ZONE |SLAB_STORE_USER ); } +if (BYTES_PER_WORD <ARCH_SLAB_MINALIGN ) + flags &= ~(SLAB_RED_ZONE |SLAB_STORE_USER );
Quoted 8 lines
mm/slab.c line 2111
Quoted 4 lines
mm/slab.c +1
-0+/* 3) caller mandated alignment: disables debug if necessary */ if (ralign < align) { ralign = align;This is similar to my patch and should be enough to fix the problem. The first patch seems bogus and I don't really understand why you would need it.
It's enough to fix the ARCH_SLAB_MINALIGN problem. But it does _not_ fix the ARCH_KMALLOC_MINALIGN problem. s390 currently only uses ARCH_KMALLOC_MINALIGN since that should be good enough and it doesn't disable as much debugging as ARCH_SLAB_MINALIGN does.
What exactly isn't clear from the description of the first patch? Or why do you consider it bogus?
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 6 lines · Heiko Carstens
It's enough to fix the
ARCH_SLAB_MINALIGNproblem. But it does _not_ fix theARCH_KMALLOC_MINALIGNproblem. s390 currently only usesARCH_KMALLOC_MINALIGNsince that should be good enough and it doesn't disable as much debugging asARCH_SLAB_MINALIGNdoes.
What exactly isn't clear from the description of the first patch? Or why do you consider it bogus?
Now I am confused. What do you mean by "doesn't disable as much debugging as ARCH_SLAB_MINALIGN does"? AFAICT, the SLAB_RED_ZONE and SLAB_STORE_USER options _require_ BYTES_PER_WORD alignment, so if s390 requires 8 byte alignment, you can't have them debugging anyhow...
Pekka
--
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>
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 8 lines · Pekka J Enberg
Quoted 6 lines · Heiko Carstens
It's enough to fix the
ARCH_SLAB_MINALIGNproblem. But it does _not_ fix theARCH_KMALLOC_MINALIGNproblem. s390 currently only usesARCH_KMALLOC_MINALIGNsince that should be good enough and it doesn't disable as much debugging asARCH_SLAB_MINALIGNdoes.
What exactly isn't clear from the description of the first patch? Or why do you consider it bogus?
Quoted 4 lines
Now I am confused. What do you mean by "doesn't disable as much debugging as
ARCH_SLAB_MINALIGNdoes"? AFAICT, theSLAB_RED_ZONEandSLAB_STORE_USERoptions _require_BYTES_PER_WORDalignment, so if s390 requires 8 byte alignment, you can't have them debugging anyhow...
We only specify ARCH_KMALLOC_MINALIGN, since that aligns only the kmalloc caches, but it doesn't disable debugging on other caches that are created via kmem_cache_create() where an alignment of e.g. 0 is specified.
The point of the first patch is: why should the slab cache be allowed to chose an aligment that is less than what the caller specified? This does very likely break things.
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 7 lines · Heiko Carstens
We only specify
ARCH_KMALLOC_MINALIGN, since that aligns only the kmalloc caches, but it doesn't disable debugging on other caches that are created viakmem_cache_create()where an alignment of e.g. 0 is specified.The point of the first patch is: why should the slab cache be allowed to chose an aligment that is less than what the caller specified? This does very likely break things.
Ah, yes, you are absolutely right. We need to respect caller mandated alignment too. How about this?
Pekka
[PATCH] slab: respect architecture and caller mandated alignment
Ensure cache alignment is always at minimum what the architecture or caller mandates even if slab debugging is enabled.
---
mm/slab.c +15 -7
@@ -2097,6 +2097,15 @@ #endif }else { ralign =BYTES_PER_WORD ; } + +/* +* Redzoning and user store require word alignment. Note this will be +* overridden by architecture or caller mandated alignment if either +* is greater than BYTES_PER_WORD. +*/ +if (flags &SLAB_RED_ZONE || flags &SLAB_STORE_USER ) + ralign =BYTES_PER_WORD ; +/* 2) arch mandated alignment: disables debug if necessary */ if (ralign <ARCH_SLAB_MINALIGN ) { ralign =ARCH_SLAB_MINALIGN ;
@@ -2123,20 +2132,19 @@ #endif#if DEBUG cachep->obj_size = size; +/* +* Both debugging options require word-alignment which is calculated +* into align above. +*/ if (flags &SLAB_RED_ZONE ) { -/* redzoning only works with word aligned caches */ - align =BYTES_PER_WORD ; -/* add space for red zone words */ cachep->obj_offset +=BYTES_PER_WORD ; size +=2 *BYTES_PER_WORD ; }if (flags &SLAB_STORE_USER ) { -/* user store requires word alignment and -* one word storage behind the end of the real -* object. +/* user store requires one word storage behind the end of +* the real object. */ - align =BYTES_PER_WORD ; size +=BYTES_PER_WORD ; }#if FORCED_DEBUG && defined(CONFIG_DEBUG_PAGEALLOC )
--
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>
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 11 lines · Pekka J Enberg
Quoted 7 lines · Heiko Carstens
We only specify
ARCH_KMALLOC_MINALIGN, since that aligns only the kmalloc caches, but it doesn't disable debugging on other caches that are created viakmem_cache_create()where an alignment of e.g. 0 is specified.The point of the first patch is: why should the slab cache be allowed to chose an aligment that is less than what the caller specified? This does very likely break things.
Ah, yes, you are absolutely right. We need to respect caller mandated alignment too. How about this?
Works fine and looks much better than my two patches. Thanks!
Re: [patch 2/2] slab: always consider arch mandated alignment
In reply to Pekka J EnbergQuoted 7 lines · Pekka J Enberg
Quoted 4 lines · Heiko Carstens
We only specify
ARCH_KMALLOC_MINALIGN, since that aligns only the kmalloc caches, but it doesn't disable debugging on other caches that are created viakmem_cache_create()where an alignment of e.g. 0 is specified.
Quoted 10 lines
Quoted 5 lines
The point of the first patch is: why should the slab cache be allowed to chose an aligment that is less than what the caller specified? This does very likely break things.
Ah, yes, you are absolutely right. We need to respect caller mandated alignment too. How about this?
Good catch - I obviously never tested the code for an HWCACHE_ALIGN cache...
Quoted 9 lines
Pekka
[PATCH] slab: respect architecture and caller mandated alignment
Ensure cache alignment is always at minimum what the architecture or caller mandates even if slab debugging is enabled.
Signed-off-by Pekka Enberg <[email protected]>
--
Manfred
--
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>
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 1 line · Manfred Spraul
Signed-off-by Manfred Spraul <[email protected]>
Good bye to all those cacheline contentions that helped us find so many race conditions in the past if we switched on SLAB_DEBUG. I thought this was intentional?
--
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>
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 4 lines · Christoph Lameter
On Wed, 26 Jul 2006, Manfred Spraul wrote:
Quoted 8 lines
Quoted 3 lines
Signed-off-by Manfred Spraul <[email protected]>Good bye to all those cacheline contentions that helped us find so many race conditions in the past if we switched on
SLAB_DEBUG. I thought this was intentional?
Relax, align is nearly never set.
- kmalloc uses align==0, except if the architecture requests it (ARCH_KMALLOC_MINALIGN not 0)
- on my i386 system, the following users explicitely use align:
* the pmd structure (4096: hardware requirement)
* the pgd structure (32 bytes: hardware requirement)
* the task structure (16 byte. fxsave)
* sigqueue, pid: both request 4 byte alignment (based on __alignof__()). Doesn't affect debugging.
From the other mail:
Quoted 8 lines
Thus the patch is correct, it's a bug in the slab allocator. If
HWCACHE_ALIGNQuoted 1 line
is set, then the allocator ignores align or
ARCH_SLAB_MINALIGN.But then Heiko does not want to set
ARCH_SLAB_MINALIGNat all. This is not the issue we are discussing. In the DEBUG case he wantsARCH_KMALLOC_MINALIGNto be enforced even ifARCH_SLAB_MINALIGNis not set.
The kmalloc caches are allocated with HWCACHE_ALIGN+ARCH_KMALLOC_MINALIGN. The logic in kmem_cache_create didn't handle that case correctly. On most architectures, ARCH_KMALLOC_MINALIGN is 0. Thus SLAB_DEBUG redzones everything.
On s390, ARCH_KMALLOC_MINALIGN is 8. This disables redzoning.
Ok?
--
Manfred
--
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>
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 9 lines · Manfred Spraul
Quoted 9 lines
Thus the patch is correct, it's a bug in the slab allocator. If
HWCACHE_ALIGNQuoted 1 line
is set, then the allocator ignores align or
ARCH_SLAB_MINALIGN.But then Heiko does not want to set
ARCH_SLAB_MINALIGNat all. This is not the issue we are discussing. In the DEBUG case he wantsARCH_KMALLOC_MINALIGNto be enforced even ifARCH_SLAB_MINALIGNis not set.
Quoted 7 lines
The kmalloc caches are allocated with HWCACHE_ALIGN+ARCH_KMALLOC_MINALIGN. The logic in
kmem_cache_createdidn't handle that case correctly.
On most architectures,ARCH_KMALLOC_MINALIGNis 0. ThusSLAB_DEBUGredzones everything.
On s390,ARCH_KMALLOC_MINALIGNis 8. This disables redzoning.Ok?
So Redzoning etc will now be diabled regardless even if ARCH_SLAB_MINALIGN is not set but another alignment is given to kmem_cache_alloc?
So we sacrifice the ability to worsen the performance of slabs by misaligning them for debugging purposes.
--
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>
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 3 lines · Christoph Lameter
So Redzoning etc will now be diabled regardless even if
ARCH_SLAB_MINALIGNis not set but another alignment is given tokmem_cache_alloc?
kmem_cache_create().
Quoted 3 lines
So we sacrifice the ability to worsen the performance of slabs by misaligning them for debugging purposes.
If a slab user can live with misaligned objects, then he shouldn't set align. Thus we do not sacrifice anything.
--
Manfred
--
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>
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 5 lines · Manfred Spraul
Quoted 3 lines
So we sacrifice the ability to worsen the performance of slabs by misaligning them for debugging purposes.
If a slab user can live with misaligned objects, then he shouldn't set align. Thus we do not sacrifice anything.
A slab user is setting alignment in order to optimize performance not for correctness. Most users that I know of can live with misalignments. If that would not be the case then this code would never have worked.
--
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>
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 3 lines · Christoph Lameter
A slab user is setting alignment in order to optimize performance not for correctness. Most users that I know of can live with misalignments. If that would not be the case then this code would never have worked.
Which users do you know that set align and that can live with misalignments? As I wrote, there are no such users in my (i386) kernel.
--
Manfred
--
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>
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 9 lines · Manfred Spraul
Quoted 4 lines · Christoph Lameter
A slab user is setting alignment in order to optimize performance not for correctness. Most users that I know of can live with misalignments. If that would not be the case then this code would never have worked.
Which users do you know that set align and that can live with misalignments? As I wrote, there are no such users in my (i386) kernel.
The users of SLAB_HWCACHE_ALIGN can live with that.
Systems running with slab debugging on must be very buggy at this point or we were very lucky:
The list is a bit strange:
Quoted 1 line
* the pmd structure (4096: hardware requirement)
It is already exempted from debug since the size is 4096.
Quoted 1 line
* the pgd structure (32 bytes: hardware requirement)
We were lucky on that one in the past? This should break.
Quoted 1 line
* the task structure (16 byte. fxsave)
Would only break if floating point is used I think.
Quoted 2 lines
* sigqueue, pid: both request 4 byte alignment (based on
__alignof__()). Doesn't affect debugging.
So also not relevant.
We now want to say that SLAB_HWCACHE_ALIGN is only a suggestion to be disposed of if debug is on whereas an explicitly specified alignment must be enforced?
--
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>
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 2 lines · Christoph Lameter
We now want to say that
SLAB_HWCACHE_ALIGNis only a suggestion to be disposed of if debug is on whereas an explicitly specified alignment must be enforced?
Yes and that's what we have been saying all along. When you want performance, you use SLAB_HWCACHE_ALIGN and let the allocator do its job. I don't see much point from API point of view for the caller to explicitly ask for a given alignment and then in addition pass a 'yes I really meant' flag (SLAB_DEBUG_OVERRIDE).
So Christoph, unless you can point out a specific problem with my patch, I'll queue it up to Andrew. Thanks.
Pekka
--
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>
Re: [patch 2/2] slab: always consider arch mandated alignment
Quoted 5 lines · Pekka J Enberg
Yes and that's what we have been saying all along. When you want performance, you use
SLAB_HWCACHE_ALIGNand let the allocator do its job. I don't see much point from API point of view for the caller to explicitly ask for a given alignment and then in addition pass a 'yes I really meant' flag (SLAB_DEBUG_OVERRIDE).
Btw, /proc/slabinfo for UML with defconfig reveals change for only one cache with my patch applied. The 'dquot' cache is created by dquot_init in fs/dquot.c and doesn't really seem to need the alignment for anything...
Pekka
--
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>
Re: [patch 2/2] slab: always consider arch mandated alignment
In reply to Christoph LameterQuoted 3 lines · Christoph Lameter
A slab user is setting alignment in order to optimize performance not for correctness. Most users that I know of can live with misalignments. If that would not be the case then this code would never have worked.
No, caller and architecture mandated alignment is set for correctness. The slab allocator can already optimize for performance on its own (SLAB_HWCACHE_ALIGN).
Pekka
--
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>
Hi Heiko,
Quoted 6 lines · Heiko Carstens
Sorry, I should have mentioned it: on s390 (32 bit) we set #define
ARCH_KMALLOC_MINALIGN8.
This is needed since our common I/O layer allocates data structures that need to have an eight byte alignment. Now, if I turn onDEBUG_SLAB, nothing works anymore, simply because the slab cache code ignoresARCH_KMALLOC_MINALIGNand uses anBYTES_PER_WORDalignment instead, which it shouldn't:
This is the bit I missed, sorry. I thought that the s390 hardware mandates 8 byte alignment, but it really doesn't. So you're absolutely right, you don't need to set ARCH_SLAB_MINALIGN and the alignment calculation in slab is indeed broken for both, architecture and caller mandated alignments.
Pekka
Quoted 12 lines · Pekka Enberg
Hi Heiko,
Quoted 8 lines · Heiko Carstens
Sorry, I should have mentioned it: on s390 (32 bit) we set #define
ARCH_KMALLOC_MINALIGN8.
This is needed since our common I/O layer allocates data structures that need
to have an eight byte alignment. Now, if I turn onDEBUG_SLAB, nothing works anymore, simply because the slab cache code ignoresARCH_KMALLOC_MINALIGNand
uses anBYTES_PER_WORDalignment instead, which it shouldn't:
Quoted 5 lines
This is the bit I missed, sorry. I thought that the s390 hardware mandates 8 byte alignment, but it really doesn't. So you're absolutely right, you don't need to set
ARCH_SLAB_MINALIGNand the alignment calculation in slab is indeed broken for both, architecture and caller mandated alignments.
Well that is a bit far reaching. What is broken is that SLAB_RED_ZONE and SLAB_STORE_USER ignore any given alignment. If you want to fix that then you need to modify how both debugging methods work.
Quoted 5 lines · Pekka Enberg
Quoted 5 lines
This is the bit I missed, sorry. I thought that the s390 hardware mandates 8 byte alignment, but it really doesn't. So you're absolutely right, you don't need to set
ARCH_SLAB_MINALIGNand the alignment calculation in slab is indeed broken for both, architecture and caller mandated alignments.
Quoted 3 lines · Christoph Lameter
Well that is a bit far reaching. What is broken is that
SLAB_RED_ZONEandSLAB_STORE_USERignore any given alignment. If you want to fix that then you need to modify how both debugging methods work.
Not sure I understand what you mean. Isn't it enough that we disable debugging if architecture or caller mandated alignment is greater than BYTES_PER_WORD?
Pekka
Quoted 8 lines · Pekka J Enberg
Quoted 3 lines · Christoph Lameter
Well that is a bit far reaching. What is broken is that
SLAB_RED_ZONEandSLAB_STORE_USERignore any given alignment. If you want to fix that then you need to modify how both debugging methods work.Not sure I understand what you mean. Isn't it enough that we disable debugging if architecture or caller mandated alignment is greater than
BYTES_PER_WORD?
If you disable them then we are fine. I think the main "bug" is that we create the caches with ARCH_KMALLOC_MINALIGN in kmem_cache_init but allow debug options on them. It seemss that we need to be able to disable debugging from kmem_cache_init.
Quoted 4 lines · Christoph Lameter
If you disable them then we are fine. I think the main "bug" is that we create the caches with
ARCH_KMALLOC_MINALIGNinkmem_cache_initbut allow debug options on them. It seemss that we need to be able to disable debugging fromkmem_cache_init.
No, as Heiko explained, but bug is that we fail to respect architecture and caller mandated alignment when CONFIG_SLAB_DEBUG is enabled. With this patch (or Heiko's), we should be okay: http://lkml.org/lkml/2006/7/26/93
Note that this will fix the kmem_cache_init() case too. If ARCH_KMALLOC_MINALIGN is greater than BYTES_PER_WORD, we'll disable debugging for those caches. It's obviously ok to have debugging for kmem_cache_init caches too if ARCH_KMALLOC_MINALIGN is greater than or equal to BYTES_PER_WORD.
Pekka
Quoted 5 lines · Pekka J Enberg
Note that this will fix the
kmem_cache_init()case too. IfARCH_KMALLOC_MINALIGNis greater thanBYTES_PER_WORD, we'll disable debugging for those caches. It's obviously ok to have debugging forkmem_cache_initcaches too ifARCH_KMALLOC_MINALIGNis greater than or equal toBYTES_PER_WORD.
Eh, meant "if ARCH_KMALLOC_MINALIGN is less than or equal to BYTES_PER_WORD" obviously.
Quoted 9 lines · Pekka J Enberg
Quoted 5 lines · Pekka J Enberg
Note that this will fix the
kmem_cache_init()case too. IfARCH_KMALLOC_MINALIGNis greater thanBYTES_PER_WORD, we'll disable debugging for those caches. It's obviously ok to have debugging forkmem_cache_initcaches too ifARCH_KMALLOC_MINALIGNis greater than or equal toBYTES_PER_WORD.Eh, meant "if
ARCH_KMALLOC_MINALIGNis less than or equal toBYTES_PER_WORD" obviously.
Your patch only deals with ARCH_SLAB_MINALIGN. kmem_cache_create() never uses ARCH_KMALLOC_MINALIGN only kmem_cache_init() does by passing it to kmem_cache_create. ARCH_KMALLOC_MINALIGN will still be ignored.
Quoted 3 lines · Christoph Lameter
Your patch only deals with
ARCH_SLAB_MINALIGN.kmem_cache_create()never usesARCH_KMALLOC_MINALIGNonlykmem_cache_init()does by passing it tokmem_cache_create.ARCH_KMALLOC_MINALIGNwill still be ignored.
Yes, in which case the caller mandated align will be, well, ARCH_KMALLOC_MINALIGN. The patch changes kmem_cache_create to respect caller mandated alignment too.
Pekka
Quoted 8 lines · Pekka Enberg
Quoted 3 lines · Christoph Lameter
Your patch only deals with
ARCH_SLAB_MINALIGN.kmem_cache_create()never usesARCH_KMALLOC_MINALIGNonlykmem_cache_init()does by passing it tokmem_cache_create.ARCH_KMALLOC_MINALIGNwill still be ignored.Yes, in which case the caller mandated align will be, well,
ARCH_KMALLOC_MINALIGN. The patch changeskmem_cache_createto respect caller mandated alignment too.
As far as I understood Heiko s390 does not set ARCH_SLAB_MINALIGN because they do not want alignent for all caches.
The following patch adds an option SLAB_DEBUG_OVERRIDE to switch off debugging if its on by default. S390 would have to set ARCH_KMALLOC_FLAGS to SLAB_DEBUG_OVERRIDE. The flag will then be passed in kmem_cache_init to kmem_cache_create(). This approach also preserves the existing slab behavior for all other archs.
include/linux/slab.h +1 -0
@@ -46,6 +46,7 @@ typedef struct kmem_cache kmem_cache_t;#define SLAB_PANIC 0x00040000UL/* panic if kmem_cache_create() fails */ #define SLAB_DESTROY_BY_RCU 0x00080000UL/* defer freeing pages to RCU */ #define SLAB_MEM_SPREAD 0x00100000UL/* Spread some memory over cpuset */ +#define SLAB_DEBUG_OVERRIDE 0x00200000UL/* Do not debug this slab */ /* flags passed to a constructor func */ #define SLAB_CTOR_CONSTRUCTOR 0x001UL/* if not set, then deconstructor */
mm/slab.c +5 -2
@@ -2055,8 +2055,11 @@ kmem_cache_create (const char *name, siz* above the next power of two: caches with object sizes just above a * power of two have a significant amount of internal fragmentation. */ -if (size <4096 ||fls (size -1 ) ==fls (size-1 +3 *BYTES_PER_WORD )) - flags |=SLAB_RED_ZONE |SLAB_STORE_USER ; + +if (!(flags &DEBUG_OVERRIDE ) && + size <4096 || + (fls (size -1 ) ==fls (size-1 +3 *BYTES_PER_WORD ))) + flags |=SLAB_RED_ZONE |SLAB_STORE_USER ;if (!(flags &SLAB_DESTROY_BY_RCU )) flags |=SLAB_POISON ;#endif
Quoted 5 lines · Christoph Lameter
The following patch adds an option
SLAB_DEBUG_OVERRIDEto switch off debugging if its on by default. S390 would have to setARCH_KMALLOC_FLAGStoSLAB_DEBUG_OVERRIDE. The flag will then be passed inkmem_cache_inittokmem_cache_create(). This approach also preserves the existing slab behavior for all other archs.
Please read my patch again. The rules are simple: we must disable debugging if architecture OR caller mandated alignment is greater than BYTES_PER_WORD. Note: for kmem_cache_init() the caller mandated alignment _is_ ARCH_KMALLOC_MINALIGN.
My patch takes care of _both_ ARCH_KMALLOC_MINALIGN and ARCH_SLAB_MINALIGN.
Pekka
Quoted 11 lines · Pekka J Enberg
Quoted 5 lines · Christoph Lameter
The following patch adds an option
SLAB_DEBUG_OVERRIDEto switch off debugging if its on by default. S390 would have to setARCH_KMALLOC_FLAGStoSLAB_DEBUG_OVERRIDE. The flag will then be passed inkmem_cache_inittokmem_cache_create(). This approach also preserves the existing slab behavior for all other archs.Please read my patch again. The rules are simple: we must disable debugging if architecture OR caller mandated alignment is greater than
BYTES_PER_WORD. Note: forkmem_cache_init()the caller mandated alignment _is_ARCH_KMALLOC_MINALIGN.
We intentionally discard the caller mandated alignment for debugging purposes.
Quoted 2 lines
My patch takes care of _both_
ARCH_KMALLOC_MINALIGNandARCH_SLAB_MINALIGN.
And it changes the basic way that slab debugging works.
Hi Christoph,
Quoted 2 lines · Christoph Lameter
We intentionally discard the caller mandated alignment for debugging purposes.
Disagreed. The caller mandated alignment is not a hint. It is the required minimum alignment for objects.
Quoted 1 line · Christoph Lameter
And it changes the basic way that slab debugging works.
Look at kmem_cache_create, we turn off debugging for both caller and architecture mandated alignments already and the only reason we are not doing it for Heiko is because the architecture recommended default alignment is so large.
Pekka
Quoted 6 lines · Pekka Enberg
Quoted 2 lines · Christoph Lameter
We intentionally discard the caller mandated alignment for debugging purposes.
Disagreed. The caller mandated alignment is not a hint. It is the required minimum alignment for objects.
This has been with the slab for a long time. Lots of alignments are now ignored for the debugging case without a problem. Manfred intentionally put that in. Alignments passed to kmem_cache_create are there for performance reasons and not because unaligned object break the arch code.
Quoted 7 lines · Christoph Lameter
Quoted 1 line
And it changes the basic way that slab debugging works.
Look at
kmem_cache_create, we turn off debugging for both caller and architecture mandated alignments already and the only reason we are not doing it for Heiko is because the architecture recommended default alignment is so large.
We discard alignment for FORCED_DEBUG unless
1. object size > 4096
2. If the object size would increase unreasonably.
I simply added another case. That preseves the discarding of alignment for the FORCED_DEBUG case but allows an override if operations would be impossible for not correctly aligned objects for certain caches (like in the S/390 case).
Quoted 8 lines · Pekka Enberg
Hi Christoph,
Quoted 2 lines · Christoph Lameter
We intentionally discard the caller mandated alignment for debugging purposes.
There are two different types of alignment:
- SLAB_HWCACHE_ALIGN: it's a recommendation, it's regularly ignored.
- the align parameter, or ARCH_SLAB_MINALIGN: It's mandatory. For example the pgd structures must be 4 kB aligned, it's required by the hardware. And I think there was (is?) a structure where ptr & ~(size-1) was used to find the start of the structure.
Thus the patch is correct, it's a bug in the slab allocator. If HWCACHE_ALIGN is set, then the allocator ignores align or ARCH_SLAB_MINALIGN.
--
Manfred
Quoted 6 lines · Manfred Spraul
There are two different types of alignment:
-SLAB_HWCACHE_ALIGN: it's a recommendation, it's regularly ignored.
- the align parameter, orARCH_SLAB_MINALIGN: It's mandatory. For example the pgd structures must be 4 kB aligned, it's required by the hardware. And I think there was (is?) a structure where ptr & ~(size-1) was used to find the start of the structure.
I agree with the above if there is an issue there then lets fix it.
Quoted 2 lines
Thus the patch is correct, it's a bug in the slab allocator. If
HWCACHE_ALIGNis set, then the allocator ignores align orARCH_SLAB_MINALIGN.
But then Heiko does not want to set ARCH_SLAB_MINALIGN at all. This is not the issue we are discussing. In the DEBUG case he wants ARCH_KMALLOC_MINALIGN to be enforced even if ARCH_SLAB_MINALIGN is not set.
Quoted 3 lines · Christoph Lameter
Quoted 3 lines
Quoted 3 lines
Your patch only deals with
ARCH_SLAB_MINALIGN.kmem_cache_create()never usesARCH_KMALLOC_MINALIGNonlykmem_cache_init()does by passing it tokmem_cache_create.ARCH_KMALLOC_MINALIGNwill still be ignored.
Quoted 3 lines · Pekka Enberg
Quoted 3 lines
Yes, in which case the caller mandated align will be, well,
ARCH_KMALLOC_MINALIGN. The patch changeskmem_cache_createto respect caller mandated alignment too.
Quoted 2 lines · Christoph Lameter
As far as I understood Heiko s390 does not set
ARCH_SLAB_MINALIGNbecause they do not want alignent for all caches.
Correct. Heiko sets ARCH_KMALLOC_MINALIGN which will be passed as the 'align' parameter to kmem_cache_create -- also known as 'caller mandated alignment.'
My patch changes the code so that, if either architecture or caller mandated alignment is greater than BYTES_PER_WORD, kmem_cache_create will disable debugging. Do you now see why my patch is in fact _not_ ignoring ARCH_KMALLOC_MINALIGN, but instead respecting that.
Pekka
Quoted 4 lines · Pekka J Enberg
My patch changes the code so that, if either architecture or caller mandated alignment is greater than
BYTES_PER_WORD,kmem_cache_createwill disable debugging. Do you now see why my patch is in fact _not_ ignoringARCH_KMALLOC_MINALIGN, but instead respecting that.
And btw, I am referring to this patch: http://lkml.org/lkml/2006/7/26/93.
Not the one I posted initially.
Pekka