Skip to contentSkip to conversation

FRV: Specify the minimum slab/kmalloc alignment

PATCH In review David Howells 2 participants 3 messages May 28, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 FRV: Specify the minimum slab/kmalloc alignment

From: David Howells <[email protected]>

Specify the minimum slab/kmalloc alignment to be 8 bytes. This fixes a crash when SLOB is selected as the memory allocator. The FRV arch needs this so that it can use the load- and store-double instructions without faulting. By default SLOB sets the minimum to be 4 bytes.

---

 include/asm-frv/mem-layout.h |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
include/asm-frv/mem-layout.h +7 -0
index 734a1d0..8a15c90 100644
@@ -31,6 +31,13 @@
 
 #define PAGE_MASK			(~(PAGE_SIZE-1))
 
+/*
+ * the slab must be aligned such that load- and store-double instructions don't
+ * fault if used
+ */
+#define	ARCH_KMALLOC_MINALIGN		(sizeof(long) * 2)
+#define	ARCH_SLAB_MINALIGN		(sizeof(long) * 2)
+
 /*****************************************************************************/
 /*
  * virtual memory layout from kernel's point of view
#1 lore raw

include/asm-frv/mem-layout.h line 39

Quoted 2 lines · David Howells
include/asm-frv/mem-layout.h +2 -0
+#define	ARCH_KMALLOC_MINALIGN		(sizeof(long) * 2)
+#define	ARCH_SLAB_MINALIGN		(sizeof(long) * 2)

This doesn't work if SLAB is selected and slab debugging is enabled as these are passed to the preprocessor.

David

#2 lore raw
Quoted 8 lines · On Wed, 28 May 2008 16:49:01 +0100 David Howells <[email protected]> wrote:

Review

Quoted 2 lines · David Howells
(quoted diff) +2 -0
+#define	ARCH_KMALLOC_MINALIGN		(sizeof(long) * 2)
+#define	ARCH_SLAB_MINALIGN		(sizeof(long) * 2)

This doesn't work if SLAB is selected and slab debugging is enabled as these are passed to the preprocessor.

So.. like this?

From: David Howells <[email protected]>

Specify the minimum slab/kmalloc alignment to be 8 bytes. This fixes a crash when SLOB is selected as the memory allocator. The FRV arch needs this so that it can use the load- and store-double instructions without faulting. By default SLOB sets the minimum to be 4 bytes.

We need to use literal constants here as slab evaluates these within cpp.

---

 include/asm-frv/mem-layout.h |    7 +++++++
 1 file changed, 7 insertions(+)
include/asm-frv/mem-layout.h renamed from include/asm-frv/mem-layout.h~frv-specify-the-minimum-slab-kmalloc-alignment +7 -0
diff -puN include/asm-frv/mem-layout.h~frv-specify-the-minimum-slab-kmalloc-alignment include/asm-frv/mem-layout.h
@@ -31,6 +31,13 @@
 
 #define PAGE_MASK			(~(PAGE_SIZE-1))
 
+/*
+ * the slab must be aligned such that load- and store-double instructions don't
+ * fault if used
+ */
+#define	ARCH_KMALLOC_MINALIGN		8 /* (sizeof(long) * 2) */
+#define	ARCH_SLAB_MINALIGN		8 /* (sizeof(long) * 2) */
+
 /*****************************************************************************/
 /*
  * virtual memory layout from kernel's point of view

_