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

Commit 944b758f authored by Shashank Mittal's avatar Shashank Mittal Committed by Mulu He
Browse files

coresight: enable stm logging for trace events, marker and printk



Dup ftrace event traffic and writes to trace_marker file from
userspace to STM. Also dup trace printk traffic to STM. This
allows Linux tracing and log data to be correlated with other
data transported over STM.

Change-Id: I4fcb42f2e97ab963fdc85853f4f3ea1f208bfc3c
Signed-off-by: default avatarPratik Patel <pratikp@codeaurora.org>
[spjoshi@codeaurora.org: 3.18 code fixup]
Signed-off-by: default avatarSarangdhar Joshi <spjoshi@codeaurora.org>
[mittals@codeaurora.org: 4.4 code fixup]
Signed-off-by: default avatarShashank Mittal <mittals@codeaurora.org>
[sadesai@codeaurora.org: 4.8 code fixup]
Signed-off-by: default avatarSatyajit Desai <sadesai@codeaurora.org>
Signed-off-by: default avatarRama Aparna Mallavarapu <aparnam@codeaurora.org>
parent e9b98347
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
#include <linux/hardirq.h>
#include <linux/perf_event.h>
#include <linux/tracepoint.h>
#include <linux/coresight-stm.h>

struct trace_array;
struct trace_buffer;
@@ -216,7 +217,8 @@ void *trace_event_buffer_reserve(struct trace_event_buffer *fbuffer,
				  struct trace_event_file *trace_file,
				  unsigned long len);

void trace_event_buffer_commit(struct trace_event_buffer *fbuffer);
void trace_event_buffer_commit(struct trace_event_buffer *fbuffer,
			       unsigned long len);

enum {
	TRACE_EVENT_FL_FILTERED_BIT,
+2 −1
Original line number Diff line number Diff line
@@ -719,7 +719,8 @@ trace_event_raw_event_##call(void *__data, proto) \
									\
	{ assign; }							\
									\
	trace_event_buffer_commit(&fbuffer);				\
	trace_event_buffer_commit(&fbuffer,				\
				  sizeof(*entry) + __data_size);	\
}
/*
 * The ftrace_test_probe is compiled out, it is only here as a build time check
+9 −3
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@
#include <linux/trace.h>
#include <linux/sched/clock.h>
#include <linux/sched/rt.h>
#include <linux/coresight-stm.h>

#include "trace.h"
#include "trace_output.h"
@@ -2376,14 +2377,15 @@ int tracepoint_printk_sysctl(struct ctl_table *table, int write,
	return ret;
}

void trace_event_buffer_commit(struct trace_event_buffer *fbuffer)
void trace_event_buffer_commit(struct trace_event_buffer *fbuffer,
			       unsigned long len)
{
	if (static_key_false(&tracepoint_printk_key.key))
		output_printk(fbuffer);

	event_trigger_unlock_commit(fbuffer->trace_file, fbuffer->buffer,
				    fbuffer->event, fbuffer->entry,
				    fbuffer->flags, fbuffer->pc);
				    fbuffer->flags, fbuffer->pc, len);
}
EXPORT_SYMBOL_GPL(trace_event_buffer_commit);

@@ -3001,6 +3003,7 @@ __trace_array_vprintk(struct ring_buffer *buffer,

	memcpy(&entry->buf, tbuffer, len + 1);
	if (!call_filter_check_discard(call, entry, buffer, event)) {
		stm_log(OST_ENTITY_TRACE_PRINTK, entry->buf, len + 1);
		__buffer_unlock_commit(buffer, event);
		ftrace_trace_stack(&global_trace, buffer, flags, 6, pc, NULL);
	}
@@ -6137,8 +6140,11 @@ tracing_mark_write(struct file *filp, const char __user *ubuf,
	if (entry->buf[cnt - 1] != '\n') {
		entry->buf[cnt] = '\n';
		entry->buf[cnt + 1] = '\0';
	} else
		stm_log(OST_ENTITY_TRACE_MARKER, entry->buf, cnt + 2);
	} else {
		entry->buf[cnt] = '\0';
		stm_log(OST_ENTITY_TRACE_MARKER, entry->buf, cnt + 1);
	}

	__buffer_unlock_commit(buffer, event);

+8 −2
Original line number Diff line number Diff line
@@ -1315,6 +1315,7 @@ __event_trigger_test_discard(struct trace_event_file *file,
 * @entry: The event itself
 * @irq_flags: The state of the interrupts at the start of the event
 * @pc: The state of the preempt count at the start of the event.
 * @len: The length of the payload data required for stm logging.
 *
 * This is a helper function to handle triggers that require data
 * from the event itself. It also tests the event against filters and
@@ -1324,12 +1325,17 @@ static inline void
event_trigger_unlock_commit(struct trace_event_file *file,
			    struct ring_buffer *buffer,
			    struct ring_buffer_event *event,
			    void *entry, unsigned long irq_flags, int pc)
			    void *entry, unsigned long irq_flags, int pc,
			    unsigned long len)
{
	enum event_trigger_type tt = ETT_NONE;

	if (!__event_trigger_test_discard(file, buffer, event, entry, &tt))
	if (!__event_trigger_test_discard(file, buffer, event, entry, &tt)) {
		if (len)
			stm_log(OST_ENTITY_FTRACE_EVENTS, entry, len);

		trace_buffer_unlock_commit(file->tr, buffer, event, irq_flags, pc);
	}

	if (tt)
		event_triggers_post_call(file, tt);
+2 −2
Original line number Diff line number Diff line
@@ -350,7 +350,7 @@ static void ftrace_syscall_enter(void *data, struct pt_regs *regs, long id)
	syscall_get_arguments(current, regs, 0, sys_data->nb_args, entry->args);

	event_trigger_unlock_commit(trace_file, buffer, event, entry,
				    irq_flags, pc);
				    irq_flags, pc, 0);
}

static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
@@ -396,7 +396,7 @@ static void ftrace_syscall_exit(void *data, struct pt_regs *regs, long ret)
	entry->ret = syscall_get_return_value(current, regs);

	event_trigger_unlock_commit(trace_file, buffer, event, entry,
				    irq_flags, pc);
				    irq_flags, pc, 0);
}

static int reg_event_syscall_enter(struct trace_event_file *file,
Loading