History

tracing: Add entries in buffer and total entries to default output header

Knowing the number of event entries in the ring buffer compared to the total number that were written is useful information. The latency format gives this information and there's no reason that the default format does not. This information is now added to the default header, along with the number of online CPUs: # tracer: nop # # entries-in-buffer/entries-written: 159836/64690869 #P:4 # # _-----=> irqs-off # / _----=> need-resched # | / _---=> hardirq/softirq # || / _--=> preempt-depth # ||| / delay # TASK-PID CPU# |||| TIMESTAMP FUNCTION # | | | |||| | | <idle>-0 [000] ...2 49.442971: local_touch_nmi <-cpu_idle <idle>-0 [000] d..2 49.442973: enter_idle <-cpu_idle <idle>-0 [000] d..2 49.442974: atomic_notifier_call_chain <-enter_idle <idle>-0 [000] d..2 49.442976: __atomic_notifier_call_chain <-atomic_notifier The above shows that the trace contains 159836 entries, but 64690869 were written. One could figure out that there were 64531033 entries that were dropped.

Steven Rostedt committed 14 years ago

Commit 39eaf7e1 parent 77271ce1 file · +47 −25Browse files

Showing the changes to kernel/trace (1 of 1 file). Show all

Unified · Split

kernel/trace/trace.c+47−25
@@ -1845,6 +1845,33 @@ static void s_stop(struct seq_file *m, void *p) · 1844 unmodified lines
18451845 trace_event_read_unlock();
18461846 }
18471847
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+
18481875 static void print_lat_help_header(struct seq_file *m)
18491876 {
18501877 seq_puts(m, "# _------=> CPU# \n");
@@ -1857,14 +1884,27 @@ static void print_lat_help_header(struct seq_file *m) · 6 unmodified lines
18571884 seq_puts(m, "# \\ / ||||| \\ | / \n");
18581885 }
18591886
1860−static void print_func_help_header(struct seq_file *m)
1887+static void print_event_info(struct trace_array *tr, struct seq_file *m)
18611888 {
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);
18621901 seq_puts(m, "# TASK-PID CPU# TIMESTAMP FUNCTION\n");
18631902 seq_puts(m, "# | | | | |\n");
18641903 }
18651904
1866−static void print_func_help_header_irq(struct seq_file *m)
1905+static void print_func_help_header_irq(struct trace_array *tr, struct seq_file *m)
18671906 {
1907+ print_event_info(tr, m);
18681908 seq_puts(m, "# _-----=> irqs-off\n");
18691909 seq_puts(m, "# / _----=> need-resched\n");
18701910 seq_puts(m, "# | / _---=> hardirq/softirq\n");
@@ -1881,32 +1921,14 @@ print_trace_header(struct seq_file *m, struct trace_iterator *iter) · 10 unmodified lines
18811921 struct trace_array *tr = iter->tr;
18821922 struct trace_array_cpu *data = tr->data[tr->cpu];
18831923 struct tracer *type = current_trace;
1884− unsigned long entries = 0;
1885− unsigned long total = 0;
1886− unsigned long count;
1924+ unsigned long entries;
1925+ unsigned long total;
18871926 const char *name = "preemption";
1888− int cpu;
18891927
18901928 if (type)
18911929 name = type->name;
18921930
1893−
1894− for_each_tracing_cpu(cpu) {
1895− count = ring_buffer_entries_cpu(tr->buffer, cpu);
1896− /*
1897− * If this buffer has skipped entries, then we hold all
1898− * entries for the trace and we need to ignore the
1899− * ones before the time stamp.
1900− */
1901− if (tr->data[cpu]->skipped_entries) {
1902− count -= tr->data[cpu]->skipped_entries;
1903− /* total is the same as the entries */
1904− total += count;
1905− } else
1906− total += count +
1907− ring_buffer_overrun_cpu(tr->buffer, cpu);
1908− entries += count;
1909− }
1931+ get_total_entries(tr, &total, &entries);
19101932
19111933 seq_printf(m, "# %s latency trace v1.1.5 on %s\n",
19121934 name, UTS_RELEASE);
@@ -2184,9 +2206,9 @@ void trace_default_header(struct seq_file *m) · 271 unmodified lines
21842206 } else {
21852207 if (!(trace_flags & TRACE_ITER_VERBOSE)) {
21862208 if (trace_flags & TRACE_ITER_IRQ_INFO)
2187− print_func_help_header_irq(m);
2209+ print_func_help_header_irq(iter->tr, m);
21882210 else
2189− print_func_help_header(m);
2211+ print_func_help_header(iter->tr, m);
21902212 }
21912213 }
21922214 }