Skip to content

Commit 441dae8

Browse files
Joel Fernandesrostedt
authored andcommitted
tracing: Add support for display of tgid in trace output
Earlier patches introduced ability to record the tgid using the 'record-tgid' option. Here we read the tgid and output it if the option is enabled. Link: http://lkml.kernel.org/r/20170626053844.5746-3-joelaf@google.com Cc: kernel-team@android.com Cc: Ingo Molnar <mingo@redhat.com> Tested-by: Michael Sartain <mikesart@gmail.com> Signed-off-by: Joel Fernandes <joelaf@google.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent d914ba3 commit 441dae8

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

kernel/trace/trace.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3319,23 +3319,29 @@ static void print_event_info(struct trace_buffer *buf, struct seq_file *m)
33193319
seq_puts(m, "#\n");
33203320
}
33213321

3322-
static void print_func_help_header(struct trace_buffer *buf, struct seq_file *m)
3322+
static void print_func_help_header(struct trace_buffer *buf, struct seq_file *m,
3323+
unsigned int flags)
33233324
{
3325+
bool tgid = flags & TRACE_ITER_RECORD_TGID;
3326+
33243327
print_event_info(buf, m);
3325-
seq_puts(m, "# TASK-PID CPU# TIMESTAMP FUNCTION\n"
3326-
"# | | | | |\n");
3328+
3329+
seq_printf(m, "# TASK-PID CPU# %s TIMESTAMP FUNCTION\n", tgid ? "TGID " : "");
3330+
seq_printf(m, "# | | | %s | |\n", tgid ? " | " : "");
33273331
}
33283332

3329-
static void print_func_help_header_irq(struct trace_buffer *buf, struct seq_file *m)
3333+
static void print_func_help_header_irq(struct trace_buffer *buf, struct seq_file *m,
3334+
unsigned int flags)
33303335
{
3331-
print_event_info(buf, m);
3332-
seq_puts(m, "# _-----=> irqs-off\n"
3333-
"# / _----=> need-resched\n"
3334-
"# | / _---=> hardirq/softirq\n"
3335-
"# || / _--=> preempt-depth\n"
3336-
"# ||| / delay\n"
3337-
"# TASK-PID CPU# |||| TIMESTAMP FUNCTION\n"
3338-
"# | | | |||| | |\n");
3336+
bool tgid = flags & TRACE_ITER_RECORD_TGID;
3337+
3338+
seq_printf(m, "# %s _-----=> irqs-off\n", tgid ? " " : "");
3339+
seq_printf(m, "# %s / _----=> need-resched\n", tgid ? " " : "");
3340+
seq_printf(m, "# %s| / _---=> hardirq/softirq\n", tgid ? " " : "");
3341+
seq_printf(m, "# %s|| / _--=> preempt-depth\n", tgid ? " " : "");
3342+
seq_printf(m, "# %s||| / delay\n", tgid ? " " : "");
3343+
seq_printf(m, "# TASK-PID CPU#%s|||| TIMESTAMP FUNCTION\n", tgid ? " TGID " : "");
3344+
seq_printf(m, "# | | | %s|||| | |\n", tgid ? " | " : "");
33393345
}
33403346

33413347
void
@@ -3651,9 +3657,11 @@ void trace_default_header(struct seq_file *m)
36513657
} else {
36523658
if (!(trace_flags & TRACE_ITER_VERBOSE)) {
36533659
if (trace_flags & TRACE_ITER_IRQ_INFO)
3654-
print_func_help_header_irq(iter->trace_buffer, m);
3660+
print_func_help_header_irq(iter->trace_buffer,
3661+
m, trace_flags);
36553662
else
3656-
print_func_help_header(iter->trace_buffer, m);
3663+
print_func_help_header(iter->trace_buffer, m,
3664+
trace_flags);
36573665
}
36583666
}
36593667
}

kernel/trace/trace_output.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,15 @@ int trace_print_context(struct trace_iterator *iter)
597597
trace_seq_printf(s, "%16s-%-5d [%03d] ",
598598
comm, entry->pid, iter->cpu);
599599

600+
if (tr->trace_flags & TRACE_ITER_RECORD_TGID) {
601+
unsigned int tgid = trace_find_tgid(entry->pid);
602+
603+
if (!tgid)
604+
trace_seq_printf(s, "(-----) ");
605+
else
606+
trace_seq_printf(s, "(%5d) ", tgid);
607+
}
608+
600609
if (tr->trace_flags & TRACE_ITER_IRQ_INFO)
601610
trace_print_lat_fmt(s, entry);
602611

0 commit comments

Comments
 (0)