mm: Make it easier to catch NULL cache names
Subsystems (2)
PATCH 1/1 mm: Make it easier to catch NULL cache names
Right now, if you inadvertently pass NULL to kmem_cache_create() at boot time, it crashes much later after boot somewhere deep inside sysfs which makes it very non obvious to figure out what's going on.
---
Yes, I did hit that :-) Something in ppc land using an array of caches and got the names array out of sync with changes to the list of indices.
mm/slub.c +2 -0
@@ -3292,6 +3292,8 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size, {struct kmem_cache *s; +BUG_ON (name ==NULL ); +down_write (&slub_lock); s =find_mergeable (size, align, flags, name, ctor);if (s) {
Signature · 9 lines
1.6.1.2.14.gf26b5 -- 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>
Quoted 4 lines · Benjamin Herrenschmidt
Right now, if you inadvertently pass NULL to
kmem_cache_create()at boot time, it crashes much later after boot somewhere deep inside sysfs which makes it very non obvious to figure out what's going on.
Please don't do BUG_ON() when there are alternatives.
In this case, something like
if (WARN_ON(!name)) return NULL;
would probably have worked too.
Linus
--
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>
Quoted 7 lines · Linus Torvalds
Quoted 4 lines · Benjamin Herrenschmidt
Right now, if you inadvertently pass NULL to
kmem_cache_create()at boot time, it crashes much later after boot somewhere deep inside sysfs which makes it very non obvious to figure out what's going on.
Quoted 8 lines
Please don't do
BUG_ON()when there are alternatives.In this case, something like
if (WARN_ON(!name)) return NULL;would probably have worked too.
Fair enough.. I'll send a new patch.
Cheers,
Ben.
--
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>
David Rientjes
reviewerQuoted 11 lines · Benjamin Herrenschmidt
Quoted 8 lines
Please don't do
BUG_ON()when there are alternatives.In this case, something like
if (WARN_ON(!name)) return NULL;would probably have worked too.
Fair enough.. I'll send a new patch.
Actually needs goto err, not return NULL, to appropriately panic when SLAB_PANIC is set.
--
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>
Quoted 9 lines · David Rientjes
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 7 lines
Please don't do
BUG_ON()when there are alternatives.In this case, something like
if (WARN_ON(!name)) return NULL;
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
would probably have worked too.
Fair enough.. I'll send a new patch.
Actually needs goto err, not return NULL, to appropriately panic when
SLAB_PANICis set.
Rats ! Why is it the trivial ones that are sooo hard :-)
New patch will have to wait til tomorrow, on my way home now.
Cheers,
Ben.
--
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>