From: Peter Zijlstra <a.p.zijlstra@chello.nl>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@elte.hu>, Bill Huey <billh@gnuppy.monkey.org>,
Jason Baron <jbaron@redhat.com>,
Steven Rostedt <rostedt@goodmis.org>,
Christoph Hellwig <hch@infradead.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Subject: [PATCH 6/7] lockdep: runtime configure prove_locking and lock_stat
Date: Wed, 23 May 2007 11:57:22 +0200 [thread overview]
Message-ID: <20070523095807.735979042@chello.nl> (raw)
In-Reply-To: 20070523072618.129001605@chello.nl
[-- Attachment #1: lockstat-sysctl.patch --]
[-- Type: text/plain, Size: 3523 bytes --]
Allow for runtime configuration of lockdep and lockstat.
/proc/sys/kernel/prove_locking
/proc/sys/kernel/lock_stat
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
kernel/lockdep.c | 27 +++++++++++++++++++++++++++
kernel/sysctl.c | 27 +++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
Index: linux-2.6/kernel/lockdep.c
===================================================================
--- linux-2.6.orig/kernel/lockdep.c 2007-05-23 01:14:03.000000000 +0200
+++ linux-2.6/kernel/lockdep.c 2007-05-23 01:14:25.000000000 +0200
@@ -42,6 +42,16 @@
#include "lockdep_internals.h"
+#ifdef CONFIG_PROVE_LOCKING
+int prove_locking = 1;
+module_param(prove_locking, int, 0644);
+#endif
+
+#ifdef CONFIG_LOCK_STAT
+int lock_stat = 1;
+module_param(lock_stat, int, 0644);
+#endif
+
/*
* lockdep_lock: protects the lockdep graph, the hashes and the
* class/list/hash allocators.
@@ -2091,9 +2101,13 @@ static int __lock_acquire(struct lockdep
hlock->waittime_stamp = 0;
hlock->holdtime_stamp = sched_clock();
#endif
+#ifdef CONFIG_PROVE_LOCKING
+ if (!prove_locking)
+ goto out_irqflags;
if (check != 2)
goto out_calc_hash;
+#endif
#ifdef CONFIG_TRACE_IRQFLAGS
/*
* If non-trylock use in a hardirq or softirq context, then
@@ -2138,6 +2152,7 @@ static int __lock_acquire(struct lockdep
}
}
#endif
+out_irqflags:
/* mark it as used: */
if (!mark_lock(curr, hlock, LOCK_USED))
return 0;
@@ -2190,6 +2205,8 @@ out_calc_hash:
curr->curr_chain_key = chain_key;
#ifdef CONFIG_PROVE_LOCKING
+ if (!prove_locking)
+ goto out_graph;
/*
* Trylock needs to maintain the stack of held locks, but it
* does not add new dependencies, because trylock can be done
@@ -2236,6 +2253,7 @@ out_calc_hash:
/* after lookup_chain_cache(): */
if (unlikely(!debug_locks))
return 0;
+out_graph:
#endif
curr->lockdep_depth++;
@@ -2349,6 +2367,9 @@ static void lock_release_holdtime(struct
{
unsigned long long holdtime;
+ if (!lock_stat)
+ return;
+
holdtime = sched_clock() - hlock->holdtime_stamp;
if (hlock->read)
@@ -2659,6 +2680,9 @@ void lock_contended(struct lockdep_map *
{
unsigned long flags;
+ if (!lock_stat)
+ return;
+
if (unlikely(current->lockdep_recursion))
return;
@@ -2675,6 +2699,9 @@ void lock_acquired(struct lockdep_map *l
{
unsigned long flags;
+ if (!lock_stat)
+ return;
+
if (unlikely(current->lockdep_recursion))
return;
Index: linux-2.6/kernel/sysctl.c
===================================================================
--- linux-2.6.orig/kernel/sysctl.c 2007-05-23 01:13:01.000000000 +0200
+++ linux-2.6/kernel/sysctl.c 2007-05-23 01:14:10.000000000 +0200
@@ -160,6 +160,13 @@ extern ctl_table inotify_table[];
int sysctl_legacy_va_layout;
#endif
+#ifdef CONFIG_PROVE_LOCKING
+extern int prove_locking;
+#endif
+
+#ifdef CONFIG_LOCK_STAT
+extern int lock_stat;
+#endif
/* The default sysctl tables: */
@@ -615,6 +622,26 @@ static ctl_table kern_table[] = {
.proc_handler = &proc_dointvec,
},
#endif
+#ifdef CONFIG_PROVE_LOCKING
+ {
+ .ctl_name = CTL_UNNUMBERED,
+ .procname = "prove_locking",
+ .data = &prove_locking,
+ .maxlen = sizeof(int),
+ .mode = 0664,
+ .proc_handler = &proc_dointvec,
+ },
+#endif
+#ifdef CONFIG_LOCK_STAT
+ {
+ .ctl_name = CTL_UNNUMBERED,
+ .procname = "lock_stat",
+ .data = &lock_stat,
+ .maxlen = sizeof(int),
+ .mode = 0664,
+ .proc_handler = &proc_dointvec,
+ },
+#endif
{ .ctl_name = 0 }
};
--
next prev parent reply other threads:[~2007-05-23 10:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-23 9:57 [PATCH 0/7] lock contention tracking -v2 Peter Zijlstra
2007-05-23 9:57 ` [PATCH 1/7] fix raw_spinlock_t vs lockdep Peter Zijlstra
2007-05-23 9:57 ` [PATCH 2/7] lockdep: isolate lock graph walking Peter Zijlstra
2007-05-23 9:57 ` [PATCH 3/7] lockdep: lock contention tracking Peter Zijlstra
2007-05-23 14:40 ` Jason Baron
2007-05-23 15:07 ` Peter Zijlstra
2007-05-23 16:11 ` Jason Baron
2007-05-23 17:23 ` Peter Zijlstra
2007-05-23 17:24 ` Jason Baron
2007-05-23 9:57 ` [PATCH 4/7] lockdep: add waittime to the lock statistics Peter Zijlstra
2007-05-23 9:57 ` [PATCH 5/7] lockdep: add holdtime " Peter Zijlstra
2007-05-23 9:57 ` Peter Zijlstra [this message]
2007-05-23 9:57 ` [PATCH 7/7] lockdep: scalable statistics Peter Zijlstra
2007-05-23 10:33 ` [PATCH 0/7] lock contention tracking -v2 Ingo Molnar
2007-05-23 21:57 ` Bill Huey
2007-05-23 15:10 ` [PATCH 8/7] new output format 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=20070523095807.735979042@chello.nl \
--to=a.p.zijlstra@chello.nl \
--cc=billh@gnuppy.monkey.org \
--cc=hch@infradead.org \
--cc=jbaron@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--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