diff options
author | Arjan van de Ven <arjan@infradead.org> | 2006-07-13 08:46:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-07-13 15:02:44 -0400 |
commit | f1aaee53f2877a7afa55e8245c241ff60a86367d (patch) | |
tree | 38ce12147987355d78be1c568941a01266262234 /mm/slab.c | |
parent | 873623dfabaa6ebbdc1ce16c1766a3c0ec5d9923 (diff) |
[PATCH] lockdep: annotate mm/slab.c
mm/slab.c uses nested locking when dealing with 'off-slab'
caches, in that case it allocates the slab header from the
(on-slab) kmalloc caches. Teach the lock validator about
this by putting all on-slab caches into a separate class.
this patch has no effect on non-lockdep kernels.
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/slab.c')
-rw-r--r-- | mm/slab.c | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -674,6 +674,37 @@ static struct kmem_cache cache_cache = { | |||
674 | #endif | 674 | #endif |
675 | }; | 675 | }; |
676 | 676 | ||
677 | #ifdef CONFIG_LOCKDEP | ||
678 | |||
679 | /* | ||
680 | * Slab sometimes uses the kmalloc slabs to store the slab headers | ||
681 | * for other slabs "off slab". | ||
682 | * The locking for this is tricky in that it nests within the locks | ||
683 | * of all other slabs in a few places; to deal with this special | ||
684 | * locking we put on-slab caches into a separate lock-class. | ||
685 | */ | ||
686 | static struct lock_class_key on_slab_key; | ||
687 | |||
688 | static inline void init_lock_keys(struct cache_sizes *s) | ||
689 | { | ||
690 | int q; | ||
691 | |||
692 | for (q = 0; q < MAX_NUMNODES; q++) { | ||
693 | if (!s->cs_cachep->nodelists[q] || OFF_SLAB(s->cs_cachep)) | ||
694 | continue; | ||
695 | lockdep_set_class(&s->cs_cachep->nodelists[q]->list_lock, | ||
696 | &on_slab_key); | ||
697 | } | ||
698 | } | ||
699 | |||
700 | #else | ||
701 | static inline void init_lock_keys(struct cache_sizes *s) | ||
702 | { | ||
703 | } | ||
704 | #endif | ||
705 | |||
706 | |||
707 | |||
677 | /* Guard access to the cache-chain. */ | 708 | /* Guard access to the cache-chain. */ |
678 | static DEFINE_MUTEX(cache_chain_mutex); | 709 | static DEFINE_MUTEX(cache_chain_mutex); |
679 | static struct list_head cache_chain; | 710 | static struct list_head cache_chain; |
@@ -1391,6 +1422,7 @@ void __init kmem_cache_init(void) | |||
1391 | ARCH_KMALLOC_FLAGS|SLAB_PANIC, | 1422 | ARCH_KMALLOC_FLAGS|SLAB_PANIC, |
1392 | NULL, NULL); | 1423 | NULL, NULL); |
1393 | } | 1424 | } |
1425 | init_lock_keys(sizes); | ||
1394 | 1426 | ||
1395 | sizes->cs_dmacachep = kmem_cache_create(names->name_dma, | 1427 | sizes->cs_dmacachep = kmem_cache_create(names->name_dma, |
1396 | sizes->cs_size, | 1428 | sizes->cs_size, |