From: Ingo Molnar <mingo@elte.hu>
To: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: linux-kernel@vger.kernel.org, Jason Baron <jbaron@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
Bill Huey <billh@gnuppy.monkey.org>
Subject: Re: [PATCH] lockdep: lock contention tracking
Date: Sun, 20 May 2007 20:05:22 +0200 [thread overview]
Message-ID: <20070520180522.GA20805@elte.hu> (raw)
In-Reply-To: <1179657026.5915.10.camel@lappy>
* Peter Zijlstra <a.p.zijlstra@chello.nl> wrote:
> Add lock contention tracking to lockdep
>
> [root@taijtu ~]# cat /proc/lockdep_contentions | sort -rnk 2 | head
> dcache_lock: 3000 0 [618] [<ffffffff8033badd>] _atomic_dec_and_lock+0x39/0x58 [17] [<ffffffff802d6dce>] sysfs_open_file+0x28/0x25a [160] [<ffffffff802a5b61>] d_instantiate+0x2a/0xad [52] [<ffffffff8029d926>] __link_path_walk+0x270/0xde9
> &inode->i_mutex: 235 0 [15] [<ffffffff8029b053>] pipe_read+0x74/0x39d [23] [<ffffffff8029a9f8>] pipe_wait+0x86/0x8d [105] [<ffffffff8029bc9a>] do_lookup+0x81/0x1ae [85] [<ffffffff802a0be7>] vfs_readdir+0x5c/0xa9
> &zone->lru_lock: 141 0 [11] [<ffffffff8027366b>] activate_page+0x37/0xd6 [75] [<ffffffff80273327>] release_pages+0xb2/0x16c [42] [<ffffffff80273443>] __pagevec_lru_add_active+0x62/0xe5 [12] [<ffffffff80273529>] __pagevec_lru_add+0x63/0xe2
looks really nice!
> 6 files changed, 266 insertions(+), 18 deletions(-)
wow, that's really simple!
in general i like this alot because it cleverly reuses all the lock API
wrappers and lock tracking infrastructure that lockdep already adds.
Acked-by: Ingo Molnar <mingo@elte.hu>
i'd suggest to add a CONFIG_DEBUG_LOCK_STAT Kconfig method to turn this
on without any of the other lock-dependency tracking costs that lockdep
has.
here are a few minor nits about the code:
> +struct lockdep_contention_point {
> + unsigned long ip;
> + atomic_t count;
> +};
i'd say rename this to "lock_contention_point" - this is not really a
lockdep thing. Lockdep offers the machinery to track lock usage, but
there's no "dependency" portion of this.
> + printk("%s/%d is trying to content lock (",
s/content/contend
> +static int lockdep_contentions_show(struct seq_file *m, void *v)
> +ssize_t lockdep_contentions_write(struct file *file, const char __user *buf,
s/lockdep/lock
> + for (i = 0; i < ARRAY_SIZE(class->contention_point);
> + i++)
> + class->contention_point[i].ip = 0;
(loop body needs curly braces because the whole construct is 3-line.)
> + entry = create_proc_entry("lockdep_contentions", S_IRUSR, NULL);
s/lockdep/lock
> @@ -20,7 +20,10 @@ void down_read(struct rw_semaphore *sem)
> might_sleep();
> rwsem_acquire_read(&sem->dep_map, 0, 0, _RET_IP_);
>
> - __down_read(sem);
> + if (!__down_read_trylock(sem)) {
> + lock_contended(&sem->dep_map, 1, _RET_IP_);
> + __down_read(sem);
> + }
heh, clever trick that avoids the touching of dozens of architectures
;-) I guess make this dependent on CONFIG_LOCK_STAT though, because gcc
cannot optimize this away even if lock_contended() is a NOP.
(same for the other trylock additions in rwsem.c and spinlock.c)
Ingo
next prev parent reply other threads:[~2007-05-20 18:05 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-20 10:30 [PATCH] lockdep: lock contention tracking Peter Zijlstra
2007-05-20 18:05 ` Ingo Molnar [this message]
2007-05-21 6:04 ` Bill Huey
2007-05-21 6:08 ` Ingo Molnar
2007-05-21 6:41 ` Bill Huey
2007-05-21 7:50 ` Ingo Molnar
2007-05-21 9:18 ` Bill Huey
2007-05-21 9:36 ` Ingo Molnar
2007-05-21 9:55 ` Christoph Hellwig
2007-05-21 10:21 ` Bill Huey
2007-05-21 10:58 ` Ingo Molnar
2007-05-21 19:17 ` Bill Huey
2007-05-21 10:19 ` Bill Huey
2007-05-21 10:28 ` Bill Huey
2007-05-21 12:46 ` Ingo Molnar
2007-05-21 19:09 ` Bill Huey
2007-05-21 20:58 ` Jason Baron
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=20070520180522.GA20805@elte.hu \
--to=mingo@elte.hu \
--cc=a.p.zijlstra@chello.nl \
--cc=billh@gnuppy.monkey.org \
--cc=jbaron@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox