Re: [PATCH] slub: Fix sysfs circular locking dependency
From: Christoph Lameter
Date: Wed Jan 05 2011 - 10:51:11 EST
On Tue, 4 Jan 2011, David Rientjes wrote:
> slub_lock protects slab_state following kmem_cache_init() if caches are
> created/destroyed prior to the sysfs slab initcall setting the global
> variable, so couldn't this leak the kobject if its initialization and add
> was deferred on kmem_cache_create() and added by slab_sysfs_init()?
Also note that the same lock inversion occurs in kmem_cache_create().
slub lock is taken and then sysfs operations are performed.
The problem is that slub_lock has multiple roles:
1. Protect the list of slab caches and the slab_state (thats why its
mainly used in kmem_cache_destroy and kmem_cache_create)
2. Protect against removal and adding of new cpus and nodes
If we could create another lock that protects against new cpus / nodes
being added and removed then we could take that lock in
IMHO the lock order must have the slub_lock at the top.
The other lock that would prevent adding/removal of nodes / cpu can be
taken in show_slab_objects and in the corresponding hotplug functions. We
do not need to take the lock at all in show_slab_objects cpu and memory
hotplug are not enabled. Maybe there is a hotplug specific lock that can
be used instead?
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/