Skip to contentSkip to conversation

slob: push the min alignment to long long

PATCH Applied Sebastian Andrzej Siewior 6 participants 19 messages Jun 14, 2011 – Jun 23, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 slob: push the min alignment to long long

In SLOB ARCH_KMALLOC_MINALIGN is 4 on 32bit platforms by default. On powerpc and some other architectures except x86 the default alignment of u64 is 8. The leads to __alignof__(struct ipt_entry) being 8 instead of 4 which is enforced by SLOB.
This leads funny behavior where "iptables -nvL -t nat" does not work on the first invocation but on the second. The network code has more than one check of this kind for the correct alignment of the allocated struct. I personally don't understand why u64 needs 8byte alignment on a 32bit platform since all access happens via two 4byte reads/writes. I know that x86_32 has a 64bit cmpxchg instruction but they have also the 4byte alignment of u64, remember?
David S. Miller says "An allocator needs to provide memory with the maximum alignment that might be required for types on a given architecture. " [0] and the fact that gcc on x86 doesn't do it is actually gcc's fault. Therefore I'm changing the default alignment of SLOB to 8. This fixes my netfilter problems (and probably other) and we have consistent behavior across all SL*B allocators.

[0] http://www.spinics.net/lists/netfilter/msg51123.html

---
 include/linux/slob_def.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
include/linux/slob_def.h +2 -2
index 4382db0..019f713 100644
@@ -4,11 +4,11 @@
 #ifdef ARCH_DMA_MINALIGN
 #define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN
 #else
-#define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long)
+#define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long)
 #endif
 
 #ifndef ARCH_SLAB_MINALIGN
-#define ARCH_SLAB_MINALIGN __alignof__(unsigned long)
+#define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
 #endif
 
 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
Signature · 1 line
1.7.4.4
#1 lore raw
Quoted 3 lines · Sebastian Andrzej Siewior

Therefore I'm changing the default alignment of SLOB to 8. This fixes my netfilter problems (and probably other) and we have consistent behavior across all SL*B allocators.

If you do that then all slab allocators do the same and we may move that alignment stuff into include/linux/slab.h instead.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#2 lore raw
In reply to Sebastian Andrzej Siewior

Maybe this would work too?

Subject: slauob: Unify alignment definition

Every slab has its on alignment definition in include/linux/sl?b_def.h. Extract those and define a common set in include/linux/slab.h.

SLOB: As notes sometimes we need double word alignment on 32 bit. This gives all structures allocated by SLOB a unsigned long long alignment like the others do.

SLAB: If ARCH_SLAB_MINALIGN is not set SLAB would set ARCH_SLAB_MINALIGN to zero meaning no alignment at all. Give it the default unsigned long long alignment.

---
 include/linux/slab.h     |   10 ++++++++++
 include/linux/slab_def.h |   26 --------------------------
 include/linux/slob_def.h |   10 ----------
 include/linux/slub_def.h |   10 ----------
 4 files changed, 10 insertions(+), 46 deletions(-)
include/linux/slab.h +10 -0
Index: linux-2.6/include/linux/slab.h
===================================================================
@@ -133,6 +133,16 @@ unsigned int kmem_cache_size(struct kmem
 #define KMALLOC_MAX_SIZE	(1UL << KMALLOC_SHIFT_HIGH)
 #define KMALLOC_MAX_ORDER	(KMALLOC_SHIFT_HIGH - PAGE_SHIFT)
 
+#ifdef ARCH_DMA_MINALIGN
+#define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN
+#else
+#define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long)
+#endif
+
+#ifndef ARCH_SLAB_MINALIGN
+#define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
+#endif
+
 /*
  * Common kmalloc functions provided by all allocators
  */
include/linux/slab_def.h +0 -26
Index: linux-2.6/include/linux/slab_def.h
===================================================================
@@ -18,32 +18,6 @@
 #include <trace/events/kmem.h>
 
 /*
- * 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 the alignment of a 64-bit integer.
- * ARCH_KMALLOC_MINALIGN allows that.
- * Note that increasing this value may disable some debug features.
- */
-#ifdef ARCH_DMA_MINALIGN
-#define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN
-#else
-#define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long)
-#endif
-
-#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
-
-/*
  * struct kmem_cache
  *
  * manages a cache.
include/linux/slob_def.h +0 -10
Index: linux-2.6/include/linux/slob_def.h
===================================================================
@@ -1,16 +1,6 @@
 #ifndef __LINUX_SLOB_DEF_H
 #define __LINUX_SLOB_DEF_H
 
-#ifdef ARCH_DMA_MINALIGN
-#define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN
-#else
-#define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long)
-#endif
-
-#ifndef ARCH_SLAB_MINALIGN
-#define ARCH_SLAB_MINALIGN __alignof__(unsigned long)
-#endif
-
 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
 
 static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
include/linux/slub_def.h +0 -10
Index: linux-2.6/include/linux/slub_def.h
===================================================================
@@ -113,16 +113,6 @@ struct kmem_cache {
 
 #define KMALLOC_SHIFT_LOW ilog2(KMALLOC_MIN_SIZE)
 
-#ifdef ARCH_DMA_MINALIGN
-#define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN
-#else
-#define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long)
-#endif
-
-#ifndef ARCH_SLAB_MINALIGN
-#define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
-#endif
-
 /*
  * Maximum kmalloc object size handled by SLUB. Larger object allocations
  * are passed through to the page allocator. The page allocator "fastpath"

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#8 lore raw
In reply to Sebastian Andrzej Siewior
Quoted 4 lines · Sebastian Andrzej Siewior

In SLOB ARCH_KMALLOC_MINALIGN is 4 on 32bit platforms by default. On powerpc and some other architectures except x86 the default alignment of u64 is 8. The leads to __alignof__(struct ipt_entry) being 8 instead of 4 which is enforced by SLOB.

Ok, so you claim that ARCH_KMALLOC_MINALIGN is not set on some architectures, and thus SLOB does the wrong thing.

Doesn't that rather obviously mean that the affected architectures should define ARCH_KMALLOC_MINALIGN? Because, well, they have an "architecture-specific minimum kmalloc alignment"?

This change will regress SLOB everywhere where '4' was the right answer.

Signature · 9 lines
Mathematics is the supreme nostalgia of our time.


--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#3 lore raw
In reply to Christoph Lameter
Quoted 1 line · * Christoph Lameter | 2011-06-14 16:16:36 [-0500]:

Maybe this would work too?

Yep, it does. Would you please be so kind to push this stable?

Sebastian

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#9 lore raw
In reply to Matt Mackall
Quoted 6 lines · * Matt Mackall | 2011-06-14 17:05:40 [-0500]:

Ok, so you claim that ARCH_KMALLOC_MINALIGN is not set on some architectures, and thus SLOB does the wrong thing.

Doesn't that rather obviously mean that the affected architectures should define ARCH_KMALLOC_MINALIGN? Because, well, they have an "architecture-specific minimum kmalloc alignment"?

nope, if nothing is defined SLOB asumes that alignment of long is the way go. Unfortunately alignment of u64 maybe larger than of u32.

Quoted 1 line

This change will regress SLOB everywhere where '4' was the right answer.

I doubt that 4 was the correct answer. On x86_32 you still get 4. Everything else might be miss-aligned for u64 types.

Sebastian

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#10 lore raw
Quoted 11 lines · Sebastian Andrzej Siewior
Quoted 6 lines · * Matt Mackall | 2011-06-14 17:05:40 [-0500]:

Ok, so you claim that ARCH_KMALLOC_MINALIGN is not set on some architectures, and thus SLOB does the wrong thing.

Doesn't that rather obviously mean that the affected architectures should define ARCH_KMALLOC_MINALIGN? Because, well, they have an "architecture-specific minimum kmalloc alignment"?

nope, if nothing is defined SLOB asumes that alignment of long is the way go. Unfortunately alignment of u64 maybe larger than of u32.

I understand that. I guess we have a different idea of what constitutes "architecture-specific" and what constitutes "normal".

But I guess I can be persuaded that most architectures now expect 64-bit alignment of u64s.

Signature · 9 lines
Mathematics is the supreme nostalgia of our time.


--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#11 lore raw
Quoted 10 lines · Matt Mackall
Quoted 9 lines · Sebastian Andrzej Siewior
Quoted 6 lines · * Matt Mackall | 2011-06-14 17:05:40 [-0500]:

Ok, so you claim that ARCH_KMALLOC_MINALIGN is not set on some architectures, and thus SLOB does the wrong thing.

Doesn't that rather obviously mean that the affected architectures should define ARCH_KMALLOC_MINALIGN? Because, well, they have an "architecture-specific minimum kmalloc alignment"?

Quoted 8 lines
Quoted 2 lines

nope, if nothing is defined SLOB asumes that alignment of long is the way go. Unfortunately alignment of u64 maybe larger than of u32.

I understand that. I guess we have a different idea of what constitutes "architecture-specific" and what constitutes "normal".

But I guess I can be persuaded that most architectures now expect 64-bit alignment of u64s.

Changing the alignment for everyone is likely to cause less problems in the future. Matt, are there any practical reasons why we shouldn't do that?

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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#12 lore raw
Quoted 17 lines · Pekka Enberg
Quoted 16 lines · Matt Mackall
Quoted 11 lines · Sebastian Andrzej Siewior
Quoted 6 lines · * Matt Mackall | 2011-06-14 17:05:40 [-0500]:

Ok, so you claim that ARCH_KMALLOC_MINALIGN is not set on some architectures, and thus SLOB does the wrong thing.

Doesn't that rather obviously mean that the affected architectures should define ARCH_KMALLOC_MINALIGN? Because, well, they have an "architecture-specific minimum kmalloc alignment"?

nope, if nothing is defined SLOB asumes that alignment of long is the way go. Unfortunately alignment of u64 maybe larger than of u32.

I understand that. I guess we have a different idea of what constitutes "architecture-specific" and what constitutes "normal".

Quoted 6 lines
Quoted 2 lines

But I guess I can be persuaded that most architectures now expect 64-bit alignment of u64s.

Changing the alignment for everyone is likely to cause less problems in the future. Matt, are there any practical reasons why we shouldn't do that?

Unless you audit all architectures to check that things are sensible, it's a trade: regressing performance on one arch to improve correctness on another. On the one hand, regressions trump improvement. On the other, correctness trumps performance.

In general, I think the right thing is to require every arch to explicitly document its alignment requirements via defines in the kernel headers so that random hackers don't have to scour the internet for datasheets on obscure architectures they don't care about. We should have no defaults and refuse to compile on any arch that doesn't have the define which will ensure someone somewhere actually thinks about it for each arch.

But as I don't have time to push that vision, I'll let it slide.

Signature · 9 lines
Mathematics is the supreme nostalgia of our time.


--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#18 lore raw
In reply to Sebastian Andrzej Siewior

From: Sebastian Andrzej Siewior <[email protected]>
Date: Wed, 15 Jun 2011 22:12:02 +0200

Quoted 1 line

I doubt that 4 was the correct answer. On x86_32 you still get 4.

No in certain circumstances with current gcc versions.

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#13 lore raw
In reply to Matt Mackall

From: Matt Mackall <[email protected]>
Date: Wed, 15 Jun 2011 15:55:55 -0500

Quoted 4 lines

In general, I think the right thing is to require every arch to explicitly document its alignment requirements via defines in the kernel headers so that random hackers don't have to scour the internet for datasheets on obscure architectures they don't care about.

Blink... because the compiler doesn't provide a portable way to do this, right? :-)

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#14 lore raw
Quoted 10 lines · David Miller

From: Matt Mackall <[email protected]>
Date: Wed, 15 Jun 2011 15:55:55 -0500

Quoted 4 lines

In general, I think the right thing is to require every arch to explicitly document its alignment requirements via defines in the kernel headers so that random hackers don't have to scour the internet for datasheets on obscure architectures they don't care about.

Blink... because the compiler doesn't provide a portable way to do this, right? :-)

Because I, on x86, cannot deduce the alignment requirements of, say, CRIS without doing significant research. So answering a question like "are there any architectures where assumption X fails" is obnoxiously hard, rather than being a grep.

I also don't think it's a given there's a portable way to deduce the alignment requirements due to the existence of arch-specific quirks. If an arch wants to kmalloc its weird crypto or SIMD context and those want 128-bit alignment, we're not going to want to embed that knowledge in the generic code, but instead tweak an arch define.

Also note that not having generic defaults forces each new architectures to (nominally) examine each assumption rather than discover they inherited an incorrect default somewhere down the road.

Signature · 9 lines
Mathematics is the supreme nostalgia of our time.


--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#15 lore raw
Quoted 14 lines · Matt Mackall
Quoted 2 lines

Blink... because the compiler doesn't provide a portable way to do this, right? :-)

Because I, on x86, cannot deduce the alignment requirements of, say, CRIS without doing significant research. So answering a question like "are there any architectures where assumption X fails" is obnoxiously hard, rather than being a grep.

I also don't think it's a given there's a portable way to deduce the alignment requirements due to the existence of arch-specific quirks. If an arch wants to kmalloc its weird crypto or SIMD context and those want 128-bit alignment, we're not going to want to embed that knowledge in the generic code, but instead tweak an arch define.

Quoted 3 lines

Also note that not having generic defaults forces each new architectures to (nominally) examine each assumption rather than discover they inherited an incorrect default somewhere down the road.

I don't agree. I think we should either provide defaults that work for everyone and let architectures override them (which AFAICT Christoph's patch does) or we flat out #error if architectures don't specify alignment requirements. The current solution seems to be the worst one from practical point of view.

This doesn't seem to be a *regression* per se so I'll queue Christoph's patch for 3.1 and mark it for 3.0-stable.

Pekka

#16 lore raw
Quoted 15 lines · Pekka Enberg
Quoted 14 lines · Matt Mackall
Quoted 2 lines

Blink... because the compiler doesn't provide a portable way to do this, right? :-)

Because I, on x86, cannot deduce the alignment requirements of, say, CRIS without doing significant research. So answering a question like "are there any architectures where assumption X fails" is obnoxiously hard, rather than being a grep.

I also don't think it's a given there's a portable way to deduce the alignment requirements due to the existence of arch-specific quirks. If an arch wants to kmalloc its weird crypto or SIMD context and those want 128-bit alignment, we're not going to want to embed that knowledge in the generic code, but instead tweak an arch define.

Quoted 8 lines
Quoted 3 lines

Also note that not having generic defaults forces each new architectures to (nominally) examine each assumption rather than discover they inherited an incorrect default somewhere down the road.

I don't agree. I think we should either provide defaults that work for everyone and let architectures override them (which AFAICT Christoph's patch does) or we flat out #error if architectures don't specify alignment requirements.

Uh, isn't the latter precisely what I say above?

Quoted 2 lines

The current solution seems to be the worst one
from practical point of view.

Good, because no one's advocating for it.

Quoted 4 lines

This doesn't seem to be a *regression* per se so I'll queue Christoph's patch for 3.1 and mark it for 3.0-stable.

Pekka

Signature · 9 lines
Mathematics is the supreme nostalgia of our time.


--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#17 lore raw
Quoted 11 lines · Matt Mackall
Quoted 4 lines

I don't agree. I think we should either provide defaults that work for everyone and let architectures override them (which AFAICT Christoph's patch does) or we flat out #error if architectures don't specify alignment requirements.

Uh, isn't the latter precisely what I say above?

Quoted 2 lines

The current solution seems to be the worst one
from practical point of view.

Good, because no one's advocating for it.

Sorry, I totally misunderstood what you wrote!

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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

Applied
#4 lore raw
In reply to Christoph Lameter
Quoted 8 lines · Christoph Lameter

Maybe this would work too?

Subject: slauob: Unify alignment definition

Every slab has its on alignment definition in include/linux/sl?b_def.h. Extract those and define a common set in include/linux/slab.h.

Quoted 7 lines

SLOB: As notes sometimes we need double word alignment on 32 bit. This gives all structures allocated by SLOB a unsigned long long alignment like the others do.

SLAB: If ARCH_SLAB_MINALIGN is not set SLAB would set ARCH_SLAB_MINALIGN to zero meaning no alignment at all. Give it the default unsigned long long alignment.

Applied, thanks!

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#5 lore raw
In reply to Christoph Lameter
Quoted 48 lines · Christoph Lameter

Index: linux-2.6/include/linux/slab.h
===================================================================

include/linux/slab.h +10 -0
@@ -133,6 +133,16 @@ unsigned int kmem_cache_size(struct kmem
 #define KMALLOC_MAX_SIZE	(1UL << KMALLOC_SHIFT_HIGH)
 #define KMALLOC_MAX_ORDER	(KMALLOC_SHIFT_HIGH - PAGE_SHIFT)
 
+#ifdef ARCH_DMA_MINALIGN
+#define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN
+#else
+#define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long)
+#endif
+
+#ifndef ARCH_SLAB_MINALIGN
+#define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
+#endif
+
 /*
  * Common kmalloc functions provided by all allocators
  */

Index: linux-2.6/include/linux/slab_def.h
===================================================================

include/linux/slab_def.h +0 -19
@@ -18,32 +18,6 @@
 #include <trace/events/kmem.h>
 
 /*
- * 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 the alignment of a 64-bit integer.
- * ARCH_KMALLOC_MINALIGN allows that.
- * Note that increasing this value may disable some debug features.
- */
-#ifdef ARCH_DMA_MINALIGN
-#define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN
-#else
-#define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long)
-#endif
-
-#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.

include/linux/slab_def.h line 23

Quoted 10 lines
include/linux/slab_def.h +0 -7
- * If possible: Do not enable this flag for CONFIG_DEBUG_SLAB, it disables
- * some debug features.
- */
-#define ARCH_SLAB_MINALIGN 0
-#endif
-
-/*
  * struct kmem_cache
  *
  * manages a cache.

Looks like we lost some valuable information in the comments when this got moved to slab.h :(

#6 lore raw
Quoted 6 lines · David Rientjes
Quoted 3 lines

* struct kmem_cache
*
* manages a cache.

Looks like we lost some valuable information in the comments when this got moved to slab.h :(

Ok. If we want a description for these defines then lets use this.

Subject: slab allocators: Provide generic description of alignment defines

Provide description for alignment defines.

---
 include/linux/slab.h |   10 ++++++++++
 1 file changed, 10 insertions(+)
include/linux/slab.h +10 -0
Index: linux-2.6/include/linux/slab.h
===================================================================
@@ -133,12 +133,22 @@ unsigned int kmem_cache_size(struct kmem
 #define KMALLOC_MAX_SIZE	(1UL << KMALLOC_SHIFT_HIGH)
 #define KMALLOC_MAX_ORDER	(KMALLOC_SHIFT_HIGH - PAGE_SHIFT)
 
+/*
+ * Some archs want to perform DMA into kmalloc caches and need a guaranteed
+ * alignment larger than the alignment of a 64-bit integer.
+ * Setting ARCH_KMALLOC_MINALIGN in arch headers allows that.
+ */
 #ifdef ARCH_DMA_MINALIGN
 #define ARCH_KMALLOC_MINALIGN ARCH_DMA_MINALIGN
 #else
 #define ARCH_KMALLOC_MINALIGN __alignof__(unsigned long long)
 #endif
 
+/*
+ * Setting ARCH_SLAB_MINALIGN in arch headers allows a different alignment.
+ * Intended for arches that get misalignment faults even for 64 bit integer
+ * aligned buffers.
+ */
 #ifndef ARCH_SLAB_MINALIGN
 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
 #endif
reviewer Acked-by
#7 lore raw
Quoted 5 lines · Christoph Lameter

Subject: slab allocators: Provide generic description of alignment defines

Provide description for alignment defines.

Thanks!

--
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/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>