Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ecffc8a8 authored by Douglas Anderson's avatar Douglas Anderson Committed by Steven Rostedt (VMware)
Browse files

tracing: Add trace_total_entries() / trace_total_entries_cpu()

These two new exported functions will be used in a future patch by
kdb_ftdump() to quickly skip all but the last few trace entries.

Link: http://lkml.kernel.org/r/20190319171206.97107-2-dianders@chromium.org



Acked-by: default avatarDaniel Thompson <daniel.thompson@linaro.org>
Suggested-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent dbfe6733
Loading
Loading
Loading
Loading
+50 −15
Original line number Diff line number Diff line
@@ -3493,16 +3493,11 @@ static void s_stop(struct seq_file *m, void *p)
}

static void
get_total_entries(struct trace_buffer *buf,
		  unsigned long *total, unsigned long *entries)
get_total_entries_cpu(struct trace_buffer *buf, unsigned long *total,
		      unsigned long *entries, int cpu)
{
	unsigned long count;
	int cpu;

	*total = 0;
	*entries = 0;

	for_each_tracing_cpu(cpu) {
	count = ring_buffer_entries_cpu(buf->buffer, cpu);
	/*
	 * If this buffer has skipped entries, then we hold all
@@ -3512,12 +3507,52 @@ get_total_entries(struct trace_buffer *buf,
	if (per_cpu_ptr(buf->data, cpu)->skipped_entries) {
		count -= per_cpu_ptr(buf->data, cpu)->skipped_entries;
		/* total is the same as the entries */
			*total += count;
		*total = count;
	} else
			*total += count +
		*total = count +
			ring_buffer_overrun_cpu(buf->buffer, cpu);
		*entries += count;
	*entries = count;
}

static void
get_total_entries(struct trace_buffer *buf,
		  unsigned long *total, unsigned long *entries)
{
	unsigned long t, e;
	int cpu;

	*total = 0;
	*entries = 0;

	for_each_tracing_cpu(cpu) {
		get_total_entries_cpu(buf, &t, &e, cpu);
		*total += t;
		*entries += e;
	}
}

unsigned long trace_total_entries_cpu(struct trace_array *tr, int cpu)
{
	unsigned long total, entries;

	if (!tr)
		tr = &global_trace;

	get_total_entries_cpu(&tr->trace_buffer, &total, &entries, cpu);

	return entries;
}

unsigned long trace_total_entries(struct trace_array *tr)
{
	unsigned long total, entries;

	if (!tr)
		tr = &global_trace;

	get_total_entries(&tr->trace_buffer, &total, &entries);

	return entries;
}

static void print_lat_help_header(struct seq_file *m)
+3 −0
Original line number Diff line number Diff line
@@ -721,6 +721,9 @@ void trace_init_global_iter(struct trace_iterator *iter);

void tracing_iter_reset(struct trace_iterator *iter, int cpu);

unsigned long trace_total_entries_cpu(struct trace_array *tr, int cpu);
unsigned long trace_total_entries(struct trace_array *tr);

void trace_function(struct trace_array *tr,
		    unsigned long ip,
		    unsigned long parent_ip,