lkml.org 
[lkml]   [2006]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [patch] lockdep: annotate mm/slab.c

* Linus Torvalds <torvalds@osdl.org> wrote:

> Why isn't the "on_slab_key" local to just the init_lock_keys()
> function, and the #ifdef around it all?

yeah - find updated patch below.

Ingo

------->
Subject: lockdep: annotate mm/slab.c
From: Arjan van de Ven <arjan@infradead.org>
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>
---
mm/slab.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
Index: linux/mm/slab.c
===================================================================
--- linux.orig/mm/slab.c
+++ linux/mm/slab.c
@@ -674,6 +674,30 @@ static struct kmem_cache cache_cache = {
#endif
};

+/*
+ * Slab sometimes uses the kmalloc slabs to store the slab headers
+ * for other slabs "off slab".
+ * The locking for this is tricky in that it nests within the locks
+ * of all other slabs in a few places; to deal with this special
+ * locking we put on-slab caches into a separate lock-class.
+ */
+static inline void init_lock_keys(struct cache_sizes *s)
+{
+#ifdef CONFIG_LOCKDEP
+ static struct lock_class_key on_slab_key;
+ int q;
+
+ for (q = 0; q < MAX_NUMNODES; q++) {
+ if (!s->cs_cachep->nodelists[q] || OFF_SLAB(s->cs_cachep))
+ continue;
+ lockdep_set_class(&s->cs_cachep->nodelists[q]->list_lock,
+ &on_slab_key);
+ }
+#endif
+}
+
+
+
/* Guard access to the cache-chain. */
static DEFINE_MUTEX(cache_chain_mutex);
static struct list_head cache_chain;
@@ -1391,6 +1415,7 @@ void __init kmem_cache_init(void)
ARCH_KMALLOC_FLAGS|SLAB_PANIC,
NULL, NULL);
}
+ init_lock_keys(sizes);

sizes->cs_dmacachep = kmem_cache_create(names->name_dma,
sizes->cs_size,
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2006-07-13 21:25    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site