aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorGlauber Costa <glommer@parallels.com>2012-12-18 17:22:31 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-18 18:02:13 -0500
commit6ccfb5bcf52bcf100fa085946f044fdbba015048 (patch)
tree51ceaa2eba8eabd07cca5de3e16b7c0cd85e41c2 /mm
parentba6c496ed834a37a26fc6fc87fc9aecb0fa0014d (diff)
slab: annotate on-slab caches nodelist locks
We currently provide lockdep annotation for kmalloc caches, and also caches that have SLAB_DEBUG_OBJECTS enabled. The reason for this is that we can quite frequently nest in the l3->list_lock lock, which is not something trivial to avoid. My proposal with this patch, is to extend this to caches whose slab management object lives within the slab as well ("on_slab"). The need for this arose in the context of testing kmemcg-slab patches. With such patchset, we can have per-memcg kmalloc caches. So the same path that led to nesting between kmalloc caches will could then lead to in-memcg nesting. Because they are not annotated, lockdep will trigger. Signed-off-by: Glauber Costa <glommer@parallels.com> Cc: Christoph Lameter <cl@linux.com> Cc: David Rientjes <rientjes@google.com> Cc: Frederic Weisbecker <fweisbec@redhat.com> Cc: Greg Thelen <gthelen@google.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: JoonSoo Kim <js1304@gmail.com> Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Cc: Mel Gorman <mel@csn.ul.ie> Cc: Michal Hocko <mhocko@suse.cz> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Cc: Rik van Riel <riel@redhat.com> Cc: Suleiman Souhlal <suleiman@google.com> Cc: Tejun Heo <tj@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r--mm/slab.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/mm/slab.c b/mm/slab.c
index 2c3a2e0394db..c26ab9fbe1f5 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -641,6 +641,26 @@ static void init_node_lock_keys(int q)
641 } 641 }
642} 642}
643 643
644static void on_slab_lock_classes_node(struct kmem_cache *cachep, int q)
645{
646 struct kmem_list3 *l3;
647 l3 = cachep->nodelists[q];
648 if (!l3)
649 return;
650
651 slab_set_lock_classes(cachep, &on_slab_l3_key,
652 &on_slab_alc_key, q);
653}
654
655static inline void on_slab_lock_classes(struct kmem_cache *cachep)
656{
657 int node;
658
659 VM_BUG_ON(OFF_SLAB(cachep));
660 for_each_node(node)
661 on_slab_lock_classes_node(cachep, node);
662}
663
644static inline void init_lock_keys(void) 664static inline void init_lock_keys(void)
645{ 665{
646 int node; 666 int node;
@@ -657,6 +677,14 @@ static inline void init_lock_keys(void)
657{ 677{
658} 678}
659 679
680static inline void on_slab_lock_classes(struct kmem_cache *cachep)
681{
682}
683
684static inline void on_slab_lock_classes_node(struct kmem_cache *cachep, int node)
685{
686}
687
660static void slab_set_debugobj_lock_classes_node(struct kmem_cache *cachep, int node) 688static void slab_set_debugobj_lock_classes_node(struct kmem_cache *cachep, int node)
661{ 689{
662} 690}
@@ -1385,6 +1413,9 @@ static int __cpuinit cpuup_prepare(long cpu)
1385 free_alien_cache(alien); 1413 free_alien_cache(alien);
1386 if (cachep->flags & SLAB_DEBUG_OBJECTS) 1414 if (cachep->flags & SLAB_DEBUG_OBJECTS)
1387 slab_set_debugobj_lock_classes_node(cachep, node); 1415 slab_set_debugobj_lock_classes_node(cachep, node);
1416 else if (!OFF_SLAB(cachep) &&
1417 !(cachep->flags & SLAB_DESTROY_BY_RCU))
1418 on_slab_lock_classes_node(cachep, node);
1388 } 1419 }
1389 init_node_lock_keys(node); 1420 init_node_lock_keys(node);
1390 1421
@@ -2489,7 +2520,8 @@ __kmem_cache_create (struct kmem_cache *cachep, unsigned long flags)
2489 WARN_ON_ONCE(flags & SLAB_DESTROY_BY_RCU); 2520 WARN_ON_ONCE(flags & SLAB_DESTROY_BY_RCU);
2490 2521
2491 slab_set_debugobj_lock_classes(cachep); 2522 slab_set_debugobj_lock_classes(cachep);
2492 } 2523 } else if (!OFF_SLAB(cachep) && !(flags & SLAB_DESTROY_BY_RCU))
2524 on_slab_lock_classes(cachep);
2493 2525
2494 return 0; 2526 return 0;
2495} 2527}