Skip to contentSkip to conversation

build error: sparsemem + SLOB

DISCUSSION Randy Dunlap 5 participants 16 messages Nov 20, 2006 – Nov 21, 2006

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

LD .tmp_vmlinux1
mm/built-in.o: In function `sparse_index_init':
sparse.c:(.text.sparse_index_init+0x19): undefined reference to `slab_is_available'
make: *** [.tmp_vmlinux1] Error 1

mm/sparse.c: line 35 uses slab_is_available() but SLAB=n, SLOB=y.

---
~Randy
full config: http://oss.oracle.com/~rdunlap/configs/config-slob-sparse
(a randconfig)

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

#1 lore raw
Quoted 7 lines

LD .tmp_vmlinux1
mm/built-in.o: In function `sparse_index_init':
sparse.c:(.text.sparse_index_init+0x19): undefined reference to `slab_is_available'
make: *** [.tmp_vmlinux1] Error 1

mm/sparse.c: line 35 uses slab_is_available() but SLAB=n, SLOB=y.

Hmm.
To be honest, I don't know that embedded people would like to use sparsemem. mem_section[] array might be too big for them.
But, they may expect reduce power consumption of memory by memory hotplug.

Anyway, this is fix.

------------
This patch is to fix compile error when SLOB is on with sparsemem.

LD .tmp_vmlinux1
mm/built-in.o: In function `sparse_index_init':
sparse.c:(.text.sparse_index_init+0x19): undefined reference to `slab_is_available'
make: *** [.tmp_vmlinux1] Error 1

mm/sparse.c: line 35 uses slab_is_available() but SLAB=n, SLOB=y.

This patch is for 2.6.19-rc5-mm2.

------------

 include/linux/slab.h |    9 +++++++++
 mm/slob.c            |    4 ++++
 mm/sparse.c          |    2 +-
 3 files changed, 14 insertions(+), 1 deletion(-)
include/linux/slab.h +9 -0
Index: 19-rc5-mm2/include/linux/slab.h
===================================================================
@@ -210,6 +210,8 @@ static inline void *kcalloc(size_t n, si
 	return kzalloc(n * size, flags);
 }
 
+#define kmem_is_available() slab_is_available()
+
 extern void kfree(const void *);
 extern unsigned int ksize(const void *);
 extern int slab_is_available(void);
@@ -260,6 +262,13 @@ extern void kmem_set_shrinker(kmem_cache
 #else /* CONFIG_SLOB */
 
 /* SLOB allocator routines */
+extern int slob_initialized;
+
+#define kmem_is_available() slob_is_available()
+static inline int slob_is_available(void)
+{
+	return slob_initialized;
+}
 
 void kmem_cache_init(void);
 struct kmem_cache *kmem_cache_create(const char *c, size_t, size_t,
mm/slob.c +4 -0
Index: 19-rc5-mm2/mm/slob.c
===================================================================
@@ -61,6 +61,8 @@ static DEFINE_SPINLOCK(block_lock);
 
 static void slob_free(void *b, int size);
 
+int slob_initialized= 0;
+
 static void *slob_alloc(size_t size, gfp_t gfp, int align)
 {
 	slob_t *prev, *cur, *aligned = 0;
@@ -337,4 +339,6 @@ void kmem_cache_init(void)
 		free_page((unsigned long)p);
 
 	mod_timer(&slob_timer, jiffies + HZ);
+	slob_initialized = 1;
+
 }
mm/sparse.c +1 -1
Index: 19-rc5-mm2/mm/sparse.c
===================================================================
@@ -50,7 +50,7 @@ static struct mem_section *sparse_index_
 	unsigned long array_size = SECTIONS_PER_ROOT *
 				   sizeof(struct mem_section);
 
-	if (slab_is_available())
+	if (kmem_is_available())
 		section = kmalloc_node(array_size, GFP_KERNEL, nid);
 	else
 		section = alloc_bootmem_node(NODE_DATA(nid), array_size);
Signature · 8 lines
Yasunori Goto 


--
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>
author Acked-by
#2 lore raw
Quoted 9 lines · Yasunori Goto
Quoted 7 lines

LD .tmp_vmlinux1
mm/built-in.o: In function `sparse_index_init':
sparse.c:(.text.sparse_index_init+0x19): undefined reference to `slab_is_available'
make: *** [.tmp_vmlinux1] Error 1

mm/sparse.c: line 35 uses slab_is_available() but SLAB=n, SLOB=y.

Quoted 6 lines

Hmm.
To be honest, I don't know that embedded people would like to use sparsemem. mem_section[] array might be too big for them.
But, they may expect reduce power consumption of memory by memory hotplug.

Anyway, this is fix.

Quoted 83 lines

------------
This patch is to fix compile error when SLOB is on with sparsemem.

LD .tmp_vmlinux1
mm/built-in.o: In function `sparse_index_init':
sparse.c:(.text.sparse_index_init+0x19): undefined reference to `slab_is_available'
make: *** [.tmp_vmlinux1] Error 1

mm/sparse.c: line 35 uses slab_is_available() but SLAB=n, SLOB=y.

This patch is for 2.6.19-rc5-mm2.

------------

 include/linux/slab.h |    9 +++++++++
 mm/slob.c            |    4 ++++
 mm/sparse.c          |    2 +-
 3 files changed, 14 insertions(+), 1 deletion(-)

Index: 19-rc5-mm2/include/linux/slab.h
===================================================================

include/linux/slab.h +9 -0
@@ -210,6 +210,8 @@ static inline void *kcalloc(size_t n, si
 	return kzalloc(n * size, flags);
 }
 
+#define kmem_is_available() slab_is_available()
+
 extern void kfree(const void *);
 extern unsigned int ksize(const void *);
 extern int slab_is_available(void);
@@ -260,6 +262,13 @@ extern void kmem_set_shrinker(kmem_cache
 #else /* CONFIG_SLOB */
 
 /* SLOB allocator routines */
+extern int slob_initialized;
+
+#define kmem_is_available() slob_is_available()
+static inline int slob_is_available(void)
+{
+	return slob_initialized;
+}
 
 void kmem_cache_init(void);
 struct kmem_cache *kmem_cache_create(const char *c, size_t, size_t,

Index: 19-rc5-mm2/mm/slob.c
===================================================================

mm/slob.c +4 -0
@@ -61,6 +61,8 @@ static DEFINE_SPINLOCK(block_lock);
 
 static void slob_free(void *b, int size);
 
+int slob_initialized= 0;
+
 static void *slob_alloc(size_t size, gfp_t gfp, int align)
 {
 	slob_t *prev, *cur, *aligned = 0;
@@ -337,4 +339,6 @@ void kmem_cache_init(void)
 		free_page((unsigned long)p);
 
 	mod_timer(&slob_timer, jiffies + HZ);
+	slob_initialized = 1;
+
 }

Index: 19-rc5-mm2/mm/sparse.c
===================================================================

mm/sparse.c +1 -1
@@ -50,7 +50,7 @@ static struct mem_section *sparse_index_
 	unsigned long array_size = SECTIONS_PER_ROOT *
 				   sizeof(struct mem_section);
 
-	if (slab_is_available())
+	if (kmem_is_available())
 		section = kmalloc_node(array_size, GFP_KERNEL, nid);
 	else
 		section = alloc_bootmem_node(NODE_DATA(nid), array_size);
Signature · 7 lines
~Randy

--
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>
#3 lore raw
In reply to Randy Dunlap
Quoted 1 line · Randy Dunlap

mm/sparse.c: line 35 uses slab_is_available() but SLAB=n, SLOB=y.

I wonder if its worth bothering about SLOB?

As far as I can tell SLOB is fundamentally racy since it does not support SLAB_DESTROY_BY_RCU correctly. F.e. The constructor for the anon_vma will be called on alloc without regard for RCU, we free an item and reuse it without regard to RCU. This can potentially mess up the anon_vma locking state while we access it.

Is SLOB used at all or have we been lucky so far?

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

#4 lore raw
Quoted 5 lines · Christoph Lameter
Quoted 1 line · Randy Dunlap

mm/sparse.c: line 35 uses slab_is_available() but SLAB=n, SLOB=y.

I wonder if its worth bothering about SLOB?

It's OK with me to make some combination of SLOB and SPARSEMEM an invalid config, as long as that is implemented in Kconfig.

Quoted 3 lines

As far as I can tell SLOB is fundamentally racy since it does not support SLAB_DESTROY_BY_RCU correctly. F.e. The constructor for the anon_vma will be called on alloc without regard for RCU, we free an item and reuse it without regard to RCU. This can potentially mess up the anon_vma locking state while we access it.

Is SLOB used at all or have we been lucky so far?

Signature · 7 lines
~Randy

--
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>
#5 lore raw
In reply to Christoph Lameter
Quoted 6 lines · Christoph Lameter

As far as I can tell SLOB is fundamentally racy since it does not support SLAB_DESTROY_BY_RCU correctly. F.e. The constructor for the anon_vma will be called on alloc without regard for RCU, we free an item and reuse it without regard to RCU. This can potentially mess up the anon_vma locking state while we access it.

Good find!

Quoted 1 line

Is SLOB used at all or have we been lucky so far?

Lucky so far. Well, we'd actually have to be quite unlucky to ever see what page_lock_anon_vma/SLAB_DESTROY_BY_RCU are guarding against.

But you're absolutely right that users should not be exposed to such unsafety. I'd say SLOB should be disallowed if SMP.

Hugh

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

#6 lore raw
Quoted 10 lines · Hugh Dickins
Quoted 6 lines · Christoph Lameter

As far as I can tell SLOB is fundamentally racy since it does not support SLAB_DESTROY_BY_RCU correctly. F.e. The constructor for the anon_vma will be called on alloc without regard for RCU, we free an item and reuse it without regard to RCU. This can potentially mess up the anon_vma locking state while we access it.

Good find!

Quoted 7 lines
Quoted 1 line

Is SLOB used at all or have we been lucky so far?

Lucky so far. Well, we'd actually have to be quite unlucky to ever see what page_lock_anon_vma/SLAB_DESTROY_BY_RCU are guarding against.

But you're absolutely right that users should not be exposed to such unsafety. I'd say SLOB should be disallowed if SMP.

SLOB is an O(N) allocator and is pretty poorly suited to running on anything like a modern desktop. Disallowing if SMP is probably reasonable, as even machines with multicore ARM or MIPS will probably have enough memory to make SLOB a bit painful.

Signature · 7 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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#7 lore raw
Quoted 16 lines · Hugh Dickins
Quoted 15 lines · Christoph Lameter
Quoted 6 lines

As far as I can tell SLOB is fundamentally racy since it does not support SLAB_DESTROY_BY_RCU correctly. F.e. The constructor for the anon_vma will be called on alloc without regard for RCU, we free an item and reuse it without regard to RCU. This can potentially mess up the anon_vma locking state while we access it.

Good find!

Quoted 1 line

Is SLOB used at all or have we been lucky so far?

Lucky so far. Well, we'd actually have to be quite unlucky to ever see what page_lock_anon_vma/SLAB_DESTROY_BY_RCU are guarding against.

Quoted 7 lines
Quoted 2 lines

But you're absolutely right that users should not be exposed to such unsafety. I'd say SLOB should be disallowed if SMP.

SLOB is an O(N) allocator and is pretty poorly suited to running on anything like a modern desktop. Disallowing if SMP is probably reasonable, as even machines with multicore ARM or MIPS will probably have enough memory to make SLOB a bit painful.

Ok. It's simple. This is fix.

----

This is to disallow to make SLOB with SMP or SPARSEMEM. This avoids latent troubles of SLOB with SLAB_DESTROY_BY_RCU. And fix compile error.

This patch is for 2.6.19-rc5-mm2.

----

 init/Kconfig |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
init/Kconfig +1 -1
Index: 19-rc5-mm2/init/Kconfig
===================================================================
@@ -465,7 +465,7 @@ config SHMEM
 
 config SLAB
 	default y
-	bool "Use full SLAB allocator" if EMBEDDED
+	bool "Use full SLAB allocator" if (EMBEDDED && !SMP && !SPARSEMEM)
 	help
 	  Disabling this replaces the advanced SLAB allocator and
 	  kmalloc support with the drastically simpler SLOB allocator.
Signature · 8 lines
Yasunori Goto 


--
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>
author Acked-by
#8 lore raw
Quoted 28 lines · On Tue, 21 Nov 2006 14:57:23 +0900 Yasunori Goto wrote:
Quoted 16 lines · Hugh Dickins
Quoted 15 lines · Christoph Lameter
Quoted 6 lines

As far as I can tell SLOB is fundamentally racy since it does not support SLAB_DESTROY_BY_RCU correctly. F.e. The constructor for the anon_vma will be called on alloc without regard for RCU, we free an item and reuse it without regard to RCU. This can potentially mess up the anon_vma locking state while we access it.

Good find!

Quoted 1 line

Is SLOB used at all or have we been lucky so far?

Lucky so far. Well, we'd actually have to be quite unlucky to ever see what page_lock_anon_vma/SLAB_DESTROY_BY_RCU are guarding against.

Quoted 7 lines
Quoted 2 lines

But you're absolutely right that users should not be exposed to such unsafety. I'd say SLOB should be disallowed if SMP.

SLOB is an O(N) allocator and is pretty poorly suited to running on anything like a modern desktop. Disallowing if SMP is probably reasonable, as even machines with multicore ARM or MIPS will probably have enough memory to make SLOB a bit painful.

Ok. It's simple. This is fix.

----

Quoted 8 lines

This is to disallow to make SLOB with SMP or SPARSEMEM. This avoids latent troubles of SLOB with SLAB_DESTROY_BY_RCU. And fix compile error.

This patch is for 2.6.19-rc5-mm2.

Thanks.

Quoted 20 lines

----

 init/Kconfig |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)

Index: 19-rc5-mm2/init/Kconfig
===================================================================

init/Kconfig +1 -1
@@ -465,7 +465,7 @@ config SHMEM
 
 config SLAB
 	default y
-	bool "Use full SLAB allocator" if EMBEDDED
+	bool "Use full SLAB allocator" if (EMBEDDED && !SMP && !SPARSEMEM)
 	help
 	  Disabling this replaces the advanced SLAB allocator and
 	  kmalloc support with the drastically simpler SLOB allocator.
Signature · 1 line
-- 

---
~Randy

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

#10 lore raw
In reply to Yasunori Goto
Quoted 19 lines · Yasunori Goto
Quoted 19 lines · Hugh Dickins
Quoted 17 lines · Christoph Lameter
Quoted 6 lines

As far as I can tell SLOB is fundamentally racy since it does not support SLAB_DESTROY_BY_RCU correctly. F.e. The constructor for the anon_vma will be called on alloc without regard for RCU, we free an item and reuse it without regard to RCU. This can potentially mess up the anon_vma locking state while we access it.

Good find!

Quoted 1 line

Is SLOB used at all or have we been lucky so far?

Lucky so far. Well, we'd actually have to be quite unlucky to ever see what page_lock_anon_vma/SLAB_DESTROY_BY_RCU are guarding against.

But you're absolutely right that users should not be exposed to such unsafety. I'd say SLOB should be disallowed if SMP.

Quoted 6 lines
Quoted 4 lines

SLOB is an O(N) allocator and is pretty poorly suited to running on anything like a modern desktop. Disallowing if SMP is probably reasonable, as even machines with multicore ARM or MIPS will probably have enough memory to make SLOB a bit painful.

Ok. It's simple. This is fix.

Are there any implications for preemptible kernels here?

Signature · 7 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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#11 lore raw
Quoted 1 line · Matt Mackall

Are there any implications for preemptible kernels here?

Matt: Would you mind if I replace SLOB with my new slab design? It is as memory efficient as yours (maybe even more since we do not have the header for each allocation). It can work efficiently in an SMP system (NUMA still under test). The code is more complex though. Still needs to mature.

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

#12 lore raw
Quoted 9 lines · Christoph Lameter
Quoted 1 line · Matt Mackall

Are there any implications for preemptible kernels here?

Matt: Would you mind if I replace SLOB with my new slab design? It is as memory efficient as yours (maybe even more since we do not have the header for each allocation). It can work efficiently in an SMP system (NUMA still under test). The code is more complex though. Still needs to mature.

How's the code size compare?

Signature · 7 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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#13 lore raw
In reply to Matt Mackall
Quoted 2 lines · Matt Mackall

Are there any implications for preemptible kernels here?

I believe not: because that code which relies upon SLAB_DESTROY_BY_RCU's guarantee already has to use rcu_read_lock(), which disables preemption.

Hugh

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

#14 lore raw
In reply to Hugh Dickins
Quoted 2 lines · Hugh Dickins

Lucky so far. Well, we'd actually have to be quite unlucky to ever see what page_lock_anon_vma/SLAB_DESTROY_BY_RCU are guarding against.

Hmmm... I had to repeatedly fix my new slab code when I broke DESTROY_BY_RCU. The machine wont even boot if that is not done 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/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#15 lore raw
Quoted 7 lines · Christoph Lameter
Quoted 2 lines · Hugh Dickins

Lucky so far. Well, we'd actually have to be quite unlucky to ever see what page_lock_anon_vma/SLAB_DESTROY_BY_RCU are guarding against.

Hmmm... I had to repeatedly fix my new slab code when I broke DESTROY_BY_RCU. The machine wont even boot if that is not done right.

I'm intrigued, and a little worried: won't even boot! Do you have some particular SGI monster in mind when you say "The machine"? Why was such a narrow (preemption disabled) window in page_lock_anon_vma so vulnerable? Swamped with many or slow-to-handle interrupts? Or was your slab code grossly over-eager in trying to free pages?

Hugh

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