From: John Kacur <jkacur@gmail.com>
To: Peter Zijlstra <peterz@infradead.org>,
LKML <linux-kernel@vger.kernel.org>
Cc: linux-rt-users <linux-rt-users@vger.kernel.org>,
Sven-Thorsten Dietrich <thebigcorporation@gmail.com>,
Clark Williams <williams@redhat.com>,
"Luis Claudio R. Goncalves" <lgoncalv@redhat.com>,
Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
Gregory Haskins <ghaskins@novell.com>
Subject: [PATCH] lockdep: Add nr_save_trace_invocations counter
Date: Thu, 22 Apr 2010 22:15:48 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.00.1004222208310.3155@localhost> (raw)
NOT FOR INCLUSION
I created this patch as a result of Peter Zilstra's request to get more
info from lockdep. This patch is not for inclusion, at least in its
present form, because it adds some redunant info to /proc/lockdep_stats
However, some of the fields are new, and it is worth examining, and / or
applying if you are looking at the MAX_STACK_TRACE_ENTRIES too big
problem.
I generated this patch against a recent tip/master but it applies without
conflicts to the latest rt kernel as well. Comments are welcome, in fact
they are appreciated.
>From 5181c0296dd1549e4e706ff25a4cd81a1d90137d Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Thu, 22 Apr 2010 17:02:42 +0200
Subject: [PATCH] lockdep: Add nr_save_trace_invocations counter
Add the nr_save_trace_invocations counter which counts the number of
time save_trace() is invoked when relevant for trace enteries.
This means, those invocations from mark_lock() and add_lock_to_list()
When called from mark_lock() we break it down into LOCKSTATE categories.
Signed-off-by: John Kacur <jkacur@redhat.com>
---
kernel/lockdep.c | 20 ++++++++++++++++++++
kernel/lockdep_internals.h | 2 ++
kernel/lockdep_proc.c | 23 +++++++++++++++++++++++
3 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 78325f8..f921576 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -371,6 +371,10 @@ static int verbose(struct lock_class *class)
unsigned long nr_stack_trace_entries;
static unsigned long stack_trace[MAX_STACK_TRACE_ENTRIES];
+/* Calls to save_trace() from mark_lock() and add_lock_to_list() only*/
+unsigned long nr_save_trace_invocations;
+unsigned long nr_save_trace_invocations_type[LOCK_USAGE_STATES];
+
static int save_trace(struct stack_trace *trace)
{
trace->nr_entries = 0;
@@ -410,6 +414,19 @@ static int save_trace(struct stack_trace *trace)
return 1;
}
+/*
+ * This function is only called from mark_lock() and add_lock_to_list()
+ * which are only called when holding the graph_lock. This counter
+ * piggybacks off of that lock
+ */
+static void inc_save_trace_invocations(enum lock_usage_bit new_bit)
+{
+ nr_save_trace_invocations++;
+ if (WARN_ON(new_bit >= LOCK_USAGE_STATES))
+ return;
+ nr_save_trace_invocations_type[new_bit]++;
+}
+
unsigned int nr_hardirq_chains;
unsigned int nr_softirq_chains;
unsigned int nr_process_chains;
@@ -449,6 +466,7 @@ static const char *usage_str[] =
#define LOCKDEP_STATE(__STATE) __USAGE(__STATE)
#include "lockdep_states.h"
#undef LOCKDEP_STATE
+#undef __USAGE
[LOCK_USED] = "INITIAL USE",
};
@@ -816,6 +834,7 @@ static int add_lock_to_list(struct lock_class *class, struct lock_class *this,
if (!entry)
return 0;
+ nr_save_trace_invocations++;
if (!save_trace(&entry->trace))
return 0;
@@ -2615,6 +2634,7 @@ static int mark_lock(struct task_struct *curr, struct held_lock *this,
hlock_class(this)->usage_mask |= new_mask;
+ inc_save_trace_invocations(new_bit);
if (!save_trace(hlock_class(this)->usage_traces + new_bit))
return 0;
diff --git a/kernel/lockdep_internals.h b/kernel/lockdep_internals.h
index 8d7d4b6..6149358 100644
--- a/kernel/lockdep_internals.h
+++ b/kernel/lockdep_internals.h
@@ -84,6 +84,8 @@ extern unsigned long nr_list_entries;
extern unsigned long nr_lock_chains;
extern int nr_chain_hlocks;
extern unsigned long nr_stack_trace_entries;
+extern unsigned long nr_save_trace_invocations;
+extern unsigned long nr_save_trace_invocations_type[LOCK_USAGE_STATES];
extern unsigned int nr_hardirq_chains;
extern unsigned int nr_softirq_chains;
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
index 59b76c8..ef5f372 100644
--- a/kernel/lockdep_proc.c
+++ b/kernel/lockdep_proc.c
@@ -215,8 +215,24 @@ static void lockdep_stats_debug_show(struct seq_file *m)
#endif
}
+#define __USAGE(__STATE) \
+[LOCK_USED_IN_##__STATE] = "LOCK_USED_IN_"__stringify(__STATE), \
+[LOCK_ENABLED_##__STATE] = "LOCK_ENABLED_"__stringify(__STATE), \
+[LOCK_USED_IN_##__STATE##_READ] = "LOCK_USED_IN_"__stringify(__STATE)"_READ", \
+[LOCK_ENABLED_##__STATE##_READ] = "LOCK_ENABLED_"__stringify(__STATE)"_READ",
+
+static const char *lockstate_tostr[] =
+{
+#define LOCKDEP_STATE(__STATE) __USAGE(__STATE)
+#include "lockdep_states.h"
+#undef LOCKDEP_STATE
+#undef __USAGE
+ [LOCK_USED] = "LOCK_USED",
+};
+
static int lockdep_stats_show(struct seq_file *m, void *v)
{
+ int bit;
struct lock_class *class;
unsigned long nr_unused = 0, nr_uncategorized = 0,
nr_irq_safe = 0, nr_irq_unsafe = 0,
@@ -307,6 +323,13 @@ static int lockdep_stats_show(struct seq_file *m, void *v)
nr_process_chains);
seq_printf(m, " stack-trace entries: %11lu [max: %lu]\n",
nr_stack_trace_entries, MAX_STACK_TRACE_ENTRIES);
+ seq_printf(m, " stack-trace invocations: %lu\n",
+ nr_save_trace_invocations);
+
+ for (bit=0; bit < LOCK_USAGE_STATES; bit++)
+ seq_printf(m, "\t%s: %lu\n", lockstate_tostr[bit],
+ nr_save_trace_invocations_type[bit]);
+
seq_printf(m, " combined max dependencies: %11u\n",
(nr_hardirq_chains + 1) *
(nr_softirq_chains + 1) *
--
1.6.6.1
next reply other threads:[~2010-04-22 20:15 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-22 20:15 John Kacur [this message]
2010-04-23 2:58 ` [PATCH] lockdep: Add nr_save_trace_invocations counter Yong Zhang
2010-04-23 6:52 ` Peter Zijlstra
2010-04-23 8:03 ` Yong Zhang
2010-04-23 7:24 ` John Kacur
2010-04-23 8:00 ` Yong Zhang
2010-04-23 8:05 ` Peter Zijlstra
2010-04-23 8:31 ` John Kacur
2010-04-23 8:31 ` John Kacur
2010-04-23 8:49 ` Yong Zhang
2010-04-23 9:40 ` John Kacur
2010-04-23 13:40 ` [PATCH] lockdep: reduce stack_trace usage Yong Zhang
2010-04-26 6:24 ` Yong Zhang
2010-05-03 12:11 ` Peter Zijlstra
2010-05-04 6:37 ` Yong Zhang
2010-05-04 6:57 ` [PATCH V2] " Yong Zhang
2010-05-04 12:56 ` Peter Zijlstra
2010-05-05 1:31 ` Yong Zhang
2010-05-05 9:09 ` Peter Zijlstra
2010-05-05 9:18 ` Yong Zhang
2010-05-07 18:40 ` [tip:core/locking] lockdep: Reduce " tip-bot for Yong Zhang
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=alpine.LFD.2.00.1004222208310.3155@localhost \
--to=jkacur@gmail.com \
--cc=ghaskins@novell.com \
--cc=lgoncalv@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=thebigcorporation@gmail.com \
--cc=williams@redhat.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 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.