OSDN Git Service

coresight: enable stm logging for trace events, marker and printk
authorShashank Mittal <mittals@codeaurora.org>
Fri, 20 May 2016 20:06:09 +0000 (13:06 -0700)
committerKyle Yan <kyan@codeaurora.org>
Tue, 24 May 2016 21:15:31 +0000 (14:15 -0700)
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: Pratik Patel <pratikp@codeaurora.org>
[spjoshi@codeaurora.org: 3.18 code fixup]
Signed-off-by: Sarangdhar Joshi <spjoshi@codeaurora.org>
[mittals@codeaurora.org: 4.4 code fixup]
Signed-off-by: Shashank Mittal <mittals@codeaurora.org>
include/linux/trace_events.h
include/trace/trace_events.h
kernel/trace/trace.c
kernel/trace/trace_events.c
kernel/trace/trace_syscalls.c
kernel/trace/trace_uprobe.c

index 429fdfc..f01c2ff 100644 (file)
@@ -8,6 +8,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;
@@ -231,7 +232,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,
@@ -500,6 +502,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
@@ -509,12 +512,16 @@ 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);
index de996cf..af0cb79 100644 (file)
@@ -682,7 +682,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
index 1e488a1..985f7a6 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/nmi.h>
 #include <linux/fs.h>
 #include <linux/sched/rt.h>
+#include <linux/coresight-stm.h>
 
 #include "trace.h"
 #include "trace_output.h"
@@ -2240,6 +2241,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);
        }
@@ -5265,8 +5267,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);
 
index 4f6ef69..52bb846 100644 (file)
@@ -285,14 +285,15 @@ static void output_printk(struct trace_event_buffer *fbuffer)
        spin_unlock_irqrestore(&tracepoint_iter_lock, flags);
 }
 
-void trace_event_buffer_commit(struct trace_event_buffer *fbuffer)
+void trace_event_buffer_commit(struct trace_event_buffer *fbuffer,
+                              unsigned long len)
 {
        if (tracepoint_printk)
                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);
 
index 0655afb..a01740a 100644 (file)
@@ -336,7 +336,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)
@@ -382,7 +382,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,
index d2f6d0b..23515a7 100644 (file)
@@ -821,7 +821,7 @@ static void __uprobe_trace_func(struct trace_uprobe *tu,
 
        memcpy(data, ucb->buf, tu->tp.size + dsize);
 
-       event_trigger_unlock_commit(trace_file, buffer, event, entry, 0, 0);
+       event_trigger_unlock_commit(trace_file, buffer, event, entry, 0, 0, 0);
 }
 
 /* uprobe handler */