Skip to content

Commit cc991b8

Browse files
author
Ingo Molnar
committed
Merge branch 'tip/perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace into perf/core
2 parents b202952 + 39eaf7e commit cc991b8

3 files changed

Lines changed: 79 additions & 28 deletions

File tree

‎kernel/trace/trace.c‎

Lines changed: 64 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ static DECLARE_WAIT_QUEUE_HEAD(trace_wait);
338338
/* trace_flags holds trace_options default values */
339339
unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK |
340340
TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO | TRACE_ITER_SLEEP_TIME |
341-
TRACE_ITER_GRAPH_TIME | TRACE_ITER_RECORD_CMD | TRACE_ITER_OVERWRITE;
341+
TRACE_ITER_GRAPH_TIME | TRACE_ITER_RECORD_CMD | TRACE_ITER_OVERWRITE |
342+
TRACE_ITER_IRQ_INFO;
342343

343344
static int trace_stop_count;
344345
static DEFINE_RAW_SPINLOCK(tracing_start_lock);
@@ -426,6 +427,7 @@ static const char *trace_options[] = {
426427
"record-cmd",
427428
"overwrite",
428429
"disable_on_free",
430+
"irq-info",
429431
NULL
430432
};
431433

@@ -1843,6 +1845,33 @@ static void s_stop(struct seq_file *m, void *p)
18431845
trace_event_read_unlock();
18441846
}
18451847

1848+
static void
1849+
get_total_entries(struct trace_array *tr, unsigned long *total, unsigned long *entries)
1850+
{
1851+
unsigned long count;
1852+
int cpu;
1853+
1854+
*total = 0;
1855+
*entries = 0;
1856+
1857+
for_each_tracing_cpu(cpu) {
1858+
count = ring_buffer_entries_cpu(tr->buffer, cpu);
1859+
/*
1860+
* If this buffer has skipped entries, then we hold all
1861+
* entries for the trace and we need to ignore the
1862+
* ones before the time stamp.
1863+
*/
1864+
if (tr->data[cpu]->skipped_entries) {
1865+
count -= tr->data[cpu]->skipped_entries;
1866+
/* total is the same as the entries */
1867+
*total += count;
1868+
} else
1869+
*total += count +
1870+
ring_buffer_overrun_cpu(tr->buffer, cpu);
1871+
*entries += count;
1872+
}
1873+
}
1874+
18461875
static void print_lat_help_header(struct seq_file *m)
18471876
{
18481877
seq_puts(m, "# _------=> CPU# \n");
@@ -1855,12 +1884,35 @@ static void print_lat_help_header(struct seq_file *m)
18551884
seq_puts(m, "# \\ / ||||| \\ | / \n");
18561885
}
18571886

1858-
static void print_func_help_header(struct seq_file *m)
1887+
static void print_event_info(struct trace_array *tr, struct seq_file *m)
18591888
{
1860-
seq_puts(m, "# TASK-PID CPU# TIMESTAMP FUNCTION\n");
1889+
unsigned long total;
1890+
unsigned long entries;
1891+
1892+
get_total_entries(tr, &total, &entries);
1893+
seq_printf(m, "# entries-in-buffer/entries-written: %lu/%lu #P:%d\n",
1894+
entries, total, num_online_cpus());
1895+
seq_puts(m, "#\n");
1896+
}
1897+
1898+
static void print_func_help_header(struct trace_array *tr, struct seq_file *m)
1899+
{
1900+
print_event_info(tr, m);
1901+
seq_puts(m, "# TASK-PID CPU# TIMESTAMP FUNCTION\n");
18611902
seq_puts(m, "# | | | | |\n");
18621903
}
18631904

1905+
static void print_func_help_header_irq(struct trace_array *tr, struct seq_file *m)
1906+
{
1907+
print_event_info(tr, m);
1908+
seq_puts(m, "# _-----=> irqs-off\n");
1909+
seq_puts(m, "# / _----=> need-resched\n");
1910+
seq_puts(m, "# | / _---=> hardirq/softirq\n");
1911+
seq_puts(m, "# || / _--=> preempt-depth\n");
1912+
seq_puts(m, "# ||| / delay\n");
1913+
seq_puts(m, "# TASK-PID CPU# |||| TIMESTAMP FUNCTION\n");
1914+
seq_puts(m, "# | | | |||| | |\n");
1915+
}
18641916

18651917
void
18661918
print_trace_header(struct seq_file *m, struct trace_iterator *iter)
@@ -1869,32 +1921,14 @@ print_trace_header(struct seq_file *m, struct trace_iterator *iter)
18691921
struct trace_array *tr = iter->tr;
18701922
struct trace_array_cpu *data = tr->data[tr->cpu];
18711923
struct tracer *type = current_trace;
1872-
unsigned long entries = 0;
1873-
unsigned long total = 0;
1874-
unsigned long count;
1924+
unsigned long entries;
1925+
unsigned long total;
18751926
const char *name = "preemption";
1876-
int cpu;
18771927

18781928
if (type)
18791929
name = type->name;
18801930

1881-
1882-
for_each_tracing_cpu(cpu) {
1883-
count = ring_buffer_entries_cpu(tr->buffer, cpu);
1884-
/*
1885-
* If this buffer has skipped entries, then we hold all
1886-
* entries for the trace and we need to ignore the
1887-
* ones before the time stamp.
1888-
*/
1889-
if (tr->data[cpu]->skipped_entries) {
1890-
count -= tr->data[cpu]->skipped_entries;
1891-
/* total is the same as the entries */
1892-
total += count;
1893-
} else
1894-
total += count +
1895-
ring_buffer_overrun_cpu(tr->buffer, cpu);
1896-
entries += count;
1897-
}
1931+
get_total_entries(tr, &total, &entries);
18981932

18991933
seq_printf(m, "# %s latency trace v1.1.5 on %s\n",
19001934
name, UTS_RELEASE);
@@ -2170,8 +2204,12 @@ void trace_default_header(struct seq_file *m)
21702204
if (!(trace_flags & TRACE_ITER_VERBOSE))
21712205
print_lat_help_header(m);
21722206
} else {
2173-
if (!(trace_flags & TRACE_ITER_VERBOSE))
2174-
print_func_help_header(m);
2207+
if (!(trace_flags & TRACE_ITER_VERBOSE)) {
2208+
if (trace_flags & TRACE_ITER_IRQ_INFO)
2209+
print_func_help_header_irq(iter->tr, m);
2210+
else
2211+
print_func_help_header(iter->tr, m);
2212+
}
21752213
}
21762214
}
21772215

‎kernel/trace/trace.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ enum trace_iterator_flags {
655655
TRACE_ITER_RECORD_CMD = 0x100000,
656656
TRACE_ITER_OVERWRITE = 0x200000,
657657
TRACE_ITER_STOP_ON_FREE = 0x400000,
658+
TRACE_ITER_IRQ_INFO = 0x800000,
658659
};
659660

660661
/*

‎kernel/trace/trace_output.c‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,11 +627,23 @@ int trace_print_context(struct trace_iterator *iter)
627627
unsigned long usec_rem = do_div(t, USEC_PER_SEC);
628628
unsigned long secs = (unsigned long)t;
629629
char comm[TASK_COMM_LEN];
630+
int ret;
630631

631632
trace_find_cmdline(entry->pid, comm);
632633

633-
return trace_seq_printf(s, "%16s-%-5d [%03d] %5lu.%06lu: ",
634-
comm, entry->pid, iter->cpu, secs, usec_rem);
634+
ret = trace_seq_printf(s, "%16s-%-5d [%03d] ",
635+
comm, entry->pid, iter->cpu);
636+
if (!ret)
637+
return 0;
638+
639+
if (trace_flags & TRACE_ITER_IRQ_INFO) {
640+
ret = trace_print_lat_fmt(s, entry);
641+
if (!ret)
642+
return 0;
643+
}
644+
645+
return trace_seq_printf(s, " %5lu.%06lu: ",
646+
secs, usec_rem);
635647
}
636648

637649
int trace_print_lat_context(struct trace_iterator *iter)

0 commit comments

Comments
 (0)