public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Rabin Vincent <rabin@rab.in>
To: Huang Ying <ying.huang@intel.com>
Cc: Eric Sesterhenn <snakebyte@gmx.de>,
	linux-kernel@vger.kernel.org, peterz@infradead.org,
	mingo@redhat.com
Subject: Re: [PATCH] lockdep: handle chains involving classes defined in modules
Date: Sat, 9 Aug 2008 03:55:56 +0530	[thread overview]
Message-ID: <20080808222555.GA10656@debian> (raw)
In-Reply-To: <1218165877.22039.23.camel@caritas-dev.intel.com>

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");

  reply	other threads:[~2008-08-08 22:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-06 12:16 Oops when accessing /proc/lockdep_chains Eric Sesterhenn
2008-08-06 12:41 ` Eric Sesterhenn
2008-08-07 20:53   ` Rabin Vincent
2008-08-07 20:57     ` [PATCH] lockdep: handle chains involving classes defined in modules Rabin Vincent
2008-08-08  3:24       ` Huang Ying
2008-08-08 22:25         ` Rabin Vincent [this message]
2008-08-11  6:38           ` Huang Ying
2008-08-08  7:57       ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080808222555.GA10656@debian \
    --to=rabin@rab.in \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=snakebyte@gmx.de \
    --cc=ying.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox