From: Li Zefan <lizf@cn.fujitsu.com>
To: Ingo Molnar <mingo@elte.hu>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Liming Wang <liming.wang@windriver.com>,
LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 6/7] ftrace: don't manipulate @pos in t_start()
Date: Wed, 24 Jun 2009 09:54:19 +0800 [thread overview]
Message-ID: <4A41874B.4090507@cn.fujitsu.com> (raw)
In-Reply-To: <4A4186C6.9090706@cn.fujitsu.com>
It's rather confusing that in t_start(), in some cases @pos is
incremented, and in some cases it's decremented and then incremented.
This patch rewrites t_start() in a much more general way.
Thus we fix a bug that if ftrace_filtered == 1, functions have tracer
hooks won't be printed, because the branch is always unreachable:
static void *t_start(...)
{
...
if (!p)
return t_hash_start(m, pos);
return p;
}
Before:
# echo 'sys_open' > /mnt/tracing/set_ftrace_filter
# echo 'sys_write:traceon:4' >> /mnt/tracing/set_ftrace_filter
sys_open
After:
# echo 'sys_open' > /mnt/tracing/set_ftrace_filter
# echo 'sys_write:traceon:4' >> /mnt/tracing/set_ftrace_filter
sys_open
sys_write:traceon:count=4
[ Impact: show selected functions when filter is on ]
Reviewed-by: Liming Wang <liming.wang@windriver.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
kernel/trace/ftrace.c | 19 ++++++++-----------
1 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index c06e9ab..7946938 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1466,8 +1466,6 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
iter->pg = iter->pg->next;
iter->idx = 0;
goto retry;
- } else {
- iter->idx = -1;
}
} else {
rec = &iter->pg->records[iter->idx++];
@@ -1496,6 +1494,7 @@ static void *t_start(struct seq_file *m, loff_t *pos)
{
struct ftrace_iterator *iter = m->private;
void *p = NULL;
+ loff_t l;
mutex_lock(&ftrace_lock);
/*
@@ -1507,23 +1506,21 @@ static void *t_start(struct seq_file *m, loff_t *pos)
if (*pos > 0)
return t_hash_start(m, pos);
iter->flags |= FTRACE_ITER_PRINTALL;
- (*pos)++;
return iter;
}
if (iter->flags & FTRACE_ITER_HASH)
return t_hash_start(m, pos);
- if (*pos > 0) {
- if (iter->idx < 0)
- return p;
- (*pos)--;
- iter->idx--;
+ iter->pg = ftrace_pages_start;
+ iter->idx = 0;
+ for (l = 0; l <= *pos; ) {
+ p = t_next(m, p, &l);
+ if (!p)
+ break;
}
- p = t_next(m, p, pos);
-
- if (!p)
+ if (!p && iter->flags & FTRACE_ITER_FILTER)
return t_hash_start(m, pos);
return p;
--
1.5.4.rc3
next prev parent reply other threads:[~2009-06-24 1:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-24 1:52 [PATCH 0/7] tracing: seqfile fixes, take 2 Li Zefan
2009-06-24 1:52 ` [PATCH 1/7] tracing/events: don't increment @pos in s_start() Li Zefan
2009-06-24 9:45 ` [tip:tracing/urgent] tracing/events: Don't " tip-bot for Li Zefan
2009-06-24 1:52 ` [PATCH 2/7] tracing_bprintk: don't increment @pos in t_start() Li Zefan
2009-06-24 9:45 ` [tip:tracing/urgent] tracing_bprintk: Don't " tip-bot for Li Zefan
2009-06-24 1:53 ` [PATCH 3/7] trace_stat: don't increment @pos in seq start() Li Zefan
2009-06-24 9:46 ` [tip:tracing/urgent] trace_stat: Don't " tip-bot for Li Zefan
2009-06-24 1:53 ` [PATCH 4/7] tracing: reset iterator in t_start() Li Zefan
2009-06-24 9:46 ` [tip:tracing/urgent] tracing: Reset " tip-bot for Li Zefan
2009-06-24 1:54 ` [PATCH 5/7] ftrace: don't increment @pos in g_start() Li Zefan
2009-06-24 9:46 ` [tip:tracing/urgent] ftrace: Don't " tip-bot for Li Zefan
2009-06-24 1:54 ` Li Zefan [this message]
2009-06-24 9:46 ` [tip:tracing/urgent] ftrace: Don't manipulate @pos in t_start() tip-bot for Li Zefan
2009-06-24 1:54 ` [PATCH 7/7] ftrace: fix t_hash_start() Li Zefan
2009-06-24 9:46 ` [tip:tracing/urgent] ftrace: Fix t_hash_start() tip-bot for Li Zefan
2009-06-24 9:03 ` [PATCH 0/7] tracing: seqfile fixes, take 2 Ingo Molnar
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=4A41874B.4090507@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=fweisbec@gmail.com \
--cc=liming.wang@windriver.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