Skip to content

Commit 97d5320

Browse files
Li ZefanIngo Molnar
Li Zefan
authored and
Ingo Molnar
committed
trace_stat: Fix missing entry in stat file
One entry is missing in the output of a stat file. The cause is, when stat_seq_start() is called the 2nd time, we should start from the (pos-1)th elem in the rbtree but not pos, because pos == 0 is the header. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <4A891A65.70009@cn.fujitsu.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent ba8b3a4 commit 97d5320

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

kernel/trace/trace_stat.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,21 @@ static void *stat_seq_start(struct seq_file *s, loff_t *pos)
203203
{
204204
struct stat_session *session = s->private;
205205
struct rb_node *node;
206+
int n = *pos;
206207
int i;
207208

208209
/* Prevent from tracer switch or rbtree modification */
209210
mutex_lock(&session->stat_mutex);
210211

211212
/* If we are in the beginning of the file, print the headers */
212-
if (!*pos && session->ts->stat_headers)
213-
return SEQ_START_TOKEN;
213+
if (session->ts->stat_headers) {
214+
if (n == 0)
215+
return SEQ_START_TOKEN;
216+
n--;
217+
}
214218

215219
node = rb_first(&session->stat_root);
216-
for (i = 0; node && i < *pos; i++)
220+
for (i = 0; node && i < n; i++)
217221
node = rb_next(node);
218222

219223
return node;

0 commit comments

Comments
 (0)