All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Greear <greearb@candelatech.com>
To: linux-kernel <linux-kernel@vger.kernel.org>
Subject: suggestion for lock debugging.
Date: Tue, 13 Feb 2007 17:58:40 -0800	[thread overview]
Message-ID: <45D26CD0.1000303@candelatech.com> (raw)

While playing around with lockdep (nice tool!) I thought
it might be nice to store the file-name and line where
the lock was acquired.  For the generic case, this could be done
with the __FILE__ and __LINE__ compiler macros, but for highly interesting
locks (ie, rtnl in my case), you could pass in the __FILE__ and __LINE__
where rtnl_lock() is called, something like:


+++ b/include/linux/rtnetlink.h
@@ -1042,7 +1042,8 @@ __rta_reserve(struct sk_buff *skb, int attrtype, int attrlen)
  extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);

  /* RTNL is used as a global lock for all changes to network configuration  */
-extern void rtnl_lock(void);
+#define rtnl_lock() __rtnl_lock(__FILE__, __LINE__);
+extern void __rtnl_lock(const char* fname, int fline);
  extern void rtnl_unlock(void);
  extern int rtnl_trylock(void);

/* pass this off to lockdep and have it store the info for
* later printing, instead of this current hack below that stores
* it in a global variable...
*/
+void __rtnl_lock(const char* fname, int fline)
  {
  	mutex_lock(&rtnl_mutex);
+	rtnl_locked_fname = fname;
+	rtnl_locked_fline = fline;
  }


I have a hacked up patch that allows lockdep to save and print
this info, but I'm not clear on exactly how to pass the fname, fline info
through mutex_lock and on to lockdep's methods....

Thanks,
Ben


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


                 reply	other threads:[~2007-02-14  2:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=45D26CD0.1000303@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.