]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
tracing: Save the last hist command's associated event name
authorTom Zanussi <tom.zanussi@linux.intel.com>
Sun, 31 Mar 2019 23:48:16 +0000 (18:48 -0500)
committerSteven Rostedt (VMware) <rostedt@goodmis.org>
Tue, 2 Apr 2019 22:24:07 +0000 (18:24 -0400)
In preparation for making use of the new trace error log, save the
subsystem and event name associated with the last hist command - it
will be passed as the location param in the event_log_err() calls.

Link: http://lkml.kernel.org/r/eb0fd1362be8f39facb86c83eecf441b7a5876f8.1554072478.git.tom.zanussi@linux.intel.com
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
kernel/trace/trace_events_hist.c

index 795aa203837733f6968f26ae1f8f4ca7b399f695..0de702bf148fb05a8f9a80631804b49d5fda8436 100644 (file)
@@ -535,15 +535,34 @@ static struct track_data *track_data_alloc(unsigned int key_len,
        return data;
 }
 
-static char last_hist_cmd[MAX_FILTER_STR_VAL];
+static char last_cmd[MAX_FILTER_STR_VAL];
+static char last_cmd_loc[MAX_FILTER_STR_VAL];
+
 static char hist_err_str[MAX_FILTER_STR_VAL];
 
-static void last_cmd_set(char *str)
+static void last_cmd_set(struct trace_event_file *file, char *str)
 {
+       const char *system = NULL, *name = NULL;
+       struct trace_event_call *call;
+
        if (!str)
                return;
 
-       strncpy(last_hist_cmd, str, MAX_FILTER_STR_VAL - 1);
+       strncpy(last_cmd, str, MAX_FILTER_STR_VAL - 1);
+
+       if (file) {
+               call = file->event_call;
+
+               system = call->class->system;
+               if (system) {
+                       name = trace_event_name(call);
+                       if (!name)
+                               system = NULL;
+               }
+       }
+
+       if (system)
+               snprintf(last_cmd_loc, MAX_FILTER_STR_VAL, "hist:%s:%s", system, name);
 }
 
 static void hist_err(char *str, char *var)
@@ -583,6 +602,8 @@ static void hist_err_event(char *str, char *system, char *event, char *var)
 static void hist_err_clear(void)
 {
        hist_err_str[0] = '\0';
+       last_cmd[0] = '\0';
+       last_cmd_loc[0] = '\0';
 }
 
 static bool have_hist_err(void)
@@ -5438,8 +5459,8 @@ static int hist_show(struct seq_file *m, void *v)
        }
 
        if (have_hist_err()) {
-               seq_printf(m, "\nERROR: %s\n", hist_err_str);
-               seq_printf(m, "  Last command: %s\n", last_hist_cmd);
+               seq_printf(m, "\n%s: error: \n", hist_err_str);
+               seq_printf(m, "  Last command: %s\n", last_cmd);
        }
 
  out_unlock:
@@ -6043,8 +6064,8 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,
        lockdep_assert_held(&event_mutex);
 
        if (glob && strlen(glob)) {
-               last_cmd_set(param);
                hist_err_clear();
+               last_cmd_set(file, param);
        }
 
        if (!param)