Re: [PATCH 1/2] SLUB: Fix merged slab cache names
From: Linus Torvalds
Date: Tue Sep 14 2010 - 14:03:16 EST
On Tue, Sep 14, 2010 at 10:06 AM, Pekka Enberg <penberg@xxxxxxxxxx> wrote:
>
> @@ -3218,6 +3221,18 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
> down_write(&slub_lock);
> s = find_mergeable(size, align, flags, name, ctor);
> if (s) {
> + if (!(s->flags & SLAB_DYNAMIC_NAME)) {
> + const char *new_name;
> +
> + new_name = kstrdup(s->name, GFP_KERNEL);
> + if (!new_name)
> + goto err;
> +
> + s->name = new_name;
Once you do this, please actually update the name to list the first
few different names.
Since the SLAB_DYNAMIC_NAME test mean that this will only happen once,
I would suggest something like just doing
size = strlen(s->name) + strlen(name) + sizeof(", ...");
new_name = kmalloc(size, GFP_KERNEL);
if (!new_name)
return -ENOMEM;
snprintf(new_name, "%s, %s...", s->name, name);
so that you get the two first names listed. Sure, it will be
wrong/incomplete if there's lots of merging, but it will be visually
very obvious in /proc/slabinfo and in the debug messages.
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/