lkml.org 
[lkml]   [2008]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] lockdep: handle chains involving classes defined in modules
On Fri, Aug 08, 2008 at 11:24:37AM +0800, Huang Ying wrote:
> On Fri, 2008-08-08 at 02:27 +0530, Rabin Vincent wrote:
> > /proc/lockdep_chains currently oopses after any module which creates and
> > uses a lock is unloaded. This is because one of the chains involves a
> > class which was defined in the module just unloaded.
> >
> > The classes are already correctly taken care of using the
> > all_lock_classes which keeps track of all active lock classses. Add a
> > similar all_lock_chains list and use it for keeping track of chains.
> >
[...]
>
> I think there is a simpler method to deal with this.

Yes. I went with the all_lock_chains list approach because there was
similar code already being used to keep track of lock_class structures.

> - Mark class as useless during zap_class()
> - When output lock_chain, if some classes are useless, do not output the
> class.

Like the patch below? I set ->key to NULL after zapping the class and
use that as a condition to not print the class' information. The only
issue is that with this patch there will be some chains output with no
locks listed under them.

---
lockdep: handle chains involving classes defined in modules

/proc/lockdep_chains currently oopses after any module which creates and
uses a lock is unloaded. This is because one of the chains involves a
class which was defined in the module just unloaded.

Solve this by marking the classes as unused and not printing information
about the unused classes.

Reported-by: Eric Sesterhenn <snakebyte@gmx.de>
Signed-off-by: Rabin Vincent <rabin@rab.in>

diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index d38a643..8ade874 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -2988,6 +2988,7 @@ static void zap_class(struct lock_class *class)
list_del_rcu(&class->hash_entry);
list_del_rcu(&class->lock_entry);

+ class->key = NULL;
}

static inline int within(const void *addr, void *start, unsigned long size)
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
index 9b0e940..f09b6c7 100644
--- a/kernel/lockdep_proc.c
+++ b/kernel/lockdep_proc.c
@@ -229,6 +229,9 @@ static int lc_show(struct seq_file *m, void *v)

for (i = 0; i < chain->depth; i++) {
class = lock_chain_get_class(chain, i);
+ if (!class->key)
+ continue;
+
seq_printf(m, "[%p] ", class->key);
print_name(m, class);
seq_puts(m, "\n");

\
 
 \ /
  Last update: 2008-08-09 00:29    [W:0.072 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site