Skip to content

Commit a1a05bb

Browse files
tzanussirostedt
authored andcommitted
tracing: Save the last hist command's associated event name
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 <[email protected]> Acked-by: Namhyung Kim <[email protected]> Signed-off-by: Tom Zanussi <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 8a06290 commit a1a05bb

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

kernel/trace/trace_events_hist.c

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -535,15 +535,34 @@ static struct track_data *track_data_alloc(unsigned int key_len,
535535
return data;
536536
}
537537

538-
static char last_hist_cmd[MAX_FILTER_STR_VAL];
538+
static char last_cmd[MAX_FILTER_STR_VAL];
539+
static char last_cmd_loc[MAX_FILTER_STR_VAL];
540+
539541
static char hist_err_str[MAX_FILTER_STR_VAL];
540542

541-
static void last_cmd_set(char *str)
543+
static void last_cmd_set(struct trace_event_file *file, char *str)
542544
{
545+
const char *system = NULL, *name = NULL;
546+
struct trace_event_call *call;
547+
543548
if (!str)
544549
return;
545550

546-
strncpy(last_hist_cmd, str, MAX_FILTER_STR_VAL - 1);
551+
strncpy(last_cmd, str, MAX_FILTER_STR_VAL - 1);
552+
553+
if (file) {
554+
call = file->event_call;
555+
556+
system = call->class->system;
557+
if (system) {
558+
name = trace_event_name(call);
559+
if (!name)
560+
system = NULL;
561+
}
562+
}
563+
564+
if (system)
565+
snprintf(last_cmd_loc, MAX_FILTER_STR_VAL, "hist:%s:%s", system, name);
547566
}
548567

549568
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)
583602
static void hist_err_clear(void)
584603
{
585604
hist_err_str[0] = '\0';
605+
last_cmd[0] = '\0';
606+
last_cmd_loc[0] = '\0';
586607
}
587608

588609
static bool have_hist_err(void)
@@ -5438,8 +5459,8 @@ static int hist_show(struct seq_file *m, void *v)
54385459
}
54395460

54405461
if (have_hist_err()) {
5441-
seq_printf(m, "\nERROR: %s\n", hist_err_str);
5442-
seq_printf(m, " Last command: %s\n", last_hist_cmd);
5462+
seq_printf(m, "\n%s: error: \n", hist_err_str);
5463+
seq_printf(m, " Last command: %s\n", last_cmd);
54435464
}
54445465

54455466
out_unlock:
@@ -6043,8 +6064,8 @@ static int event_hist_trigger_func(struct event_command *cmd_ops,
60436064
lockdep_assert_held(&event_mutex);
60446065

60456066
if (glob && strlen(glob)) {
6046-
last_cmd_set(param);
60476067
hist_err_clear();
6068+
last_cmd_set(file, param);
60486069
}
60496070

60506071
if (!param)

0 commit comments

Comments
 (0)