slab vs. slub kmem cache name inconsistency
Hi,
I just noticed that slub's kmem_cache_create() will kstrdup() the name, while slab doesn't. That's a little confusing, since when you look at slub you can easily get away with passing a string you built on the stack, while that will then lead to very strange results (and possibly crashes?) with slab. The slab kernel-doc string always says this:
* @name must be valid until the cache is destroyed. This implies that
* the module calling this has to destroy the cache before getting unloaded.
Is there any reason for this difference, or should slab also kstrdup(), or should slub not do it? Or maybe slub should have a "oops, name is on stack" warning/check?
johannes
--
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, Johannes.
2012/10/2 Johannes Berg <[email protected]>:
Quoted 7 lines
Hi,
I just noticed that slub's
kmem_cache_create()willkstrdup()the name, while slab doesn't. That's a little confusing, since when you look at slub you can easily get away with passing a string you built on the stack, while that will then lead to very strange results (and possibly crashes?) with slab.
As far as I know, this issue is already fixed. However, fix for this is not merged into mainline yet.
You can find the fix in common_for_cgroups branch of Pekka's git tree.
git://git.kernel.org/pub/scm/linux/kernel/git/penberg/linux.git
slab/common-for-cgroups
--
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,
Quoted 6 lines
Quoted 5 lines
I just noticed that slub's
kmem_cache_create()willkstrdup()the name, while slab doesn't. That's a little confusing, since when you look at slub you can easily get away with passing a string you built on the stack, while that will then lead to very strange results (and possibly crashes?) with slab.
Quoted 6 lines
As far as I know, this issue is already fixed. However, fix for this is not merged into mainline yet.
You can find the fix incommon_for_cgroupsbranch of Pekka's git tree.
git://git.kernel.org/pub/scm/linux/kernel/git/penberg/linux.git
slab/common-for-cgroups
Cool, yes, we have a commit there which addresses this:
Thanks!
johannes
--
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>
This should be fixed the merge window for 3.7. All allocators will do a kstrdup then.
Quoted 8 lines · Johannes Berg
Hi,
I just noticed that slub's
kmem_cache_create()willkstrdup()the name, while slab doesn't. That's a little confusing, since when you look at slub you can easily get away with passing a string you built on the stack, while that will then lead to very strange results (and possibly crashes?) with slab. The slab kernel-doc string always says this:
Quoted 9 lines
* @name must be valid until the cache is destroyed. This implies that
* the module calling this has to destroy the cache before getting unloaded.Is there any reason for this difference, or should slab also
kstrdup(), or should slub not do it? Or maybe slub should have a "oops, name is on stack" warning/check?johannes
--
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>