2017-07-09 11:42:39 +00:00
|
|
|
From: Tom Zanussi <tom.zanussi@linux.intel.com>
|
2018-01-31 19:59:07 +00:00
|
|
|
Date: Mon, 15 Jan 2018 20:52:03 -0600
|
2017-11-29 23:05:39 +00:00
|
|
|
Subject: [PATCH 29/37] tracing: Add cpu field for hist triggers
|
2018-01-31 19:59:07 +00:00
|
|
|
Origin: https://www.kernel.org/pub/linux/kernel/projects/rt/4.14/older/patches-4.14.15-rt13.tar.xz
|
2017-07-09 11:42:39 +00:00
|
|
|
|
|
|
|
A common key to use in a histogram is the cpuid - add a new cpu
|
2017-12-20 18:53:59 +00:00
|
|
|
'synthetic' field named 'cpu' for that purpose.
|
2017-07-09 11:42:39 +00:00
|
|
|
|
|
|
|
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
|
|
|
|
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
|
|
|
|
---
|
2017-12-20 18:53:59 +00:00
|
|
|
Documentation/trace/histogram.txt | 15 +++++++++++++++
|
2017-11-29 23:05:39 +00:00
|
|
|
kernel/trace/trace_events_hist.c | 28 +++++++++++++++++++++++++++-
|
2017-12-20 18:53:59 +00:00
|
|
|
2 files changed, 42 insertions(+), 1 deletion(-)
|
2017-07-09 11:42:39 +00:00
|
|
|
|
2017-11-29 23:05:39 +00:00
|
|
|
--- a/Documentation/trace/histogram.txt
|
|
|
|
+++ b/Documentation/trace/histogram.txt
|
2017-12-20 18:53:59 +00:00
|
|
|
@@ -172,6 +172,21 @@
|
2017-07-09 11:42:39 +00:00
|
|
|
The examples below provide a more concrete illustration of the
|
|
|
|
concepts and typical usage patterns discussed above.
|
|
|
|
|
2017-11-20 14:16:49 +00:00
|
|
|
+ 'special' event fields
|
2017-07-09 11:42:39 +00:00
|
|
|
+ ------------------------
|
|
|
|
+
|
2017-11-20 14:16:49 +00:00
|
|
|
+ There are a number of 'special event fields' available for use as
|
|
|
|
+ keys or values in a hist trigger. These look like and behave as if
|
|
|
|
+ they were actual event fields, but aren't really part of the event's
|
|
|
|
+ field definition or format file. They are however available for any
|
2017-07-09 11:42:39 +00:00
|
|
|
+ event, and can be used anywhere an actual event field could be.
|
2017-12-20 18:53:59 +00:00
|
|
|
+ They are:
|
2017-07-09 11:42:39 +00:00
|
|
|
+
|
2017-12-20 18:53:59 +00:00
|
|
|
+ common_timestamp u64 - timestamp (from ring buffer) associated
|
2017-07-09 11:42:39 +00:00
|
|
|
+ with the event, in nanoseconds. May be
|
|
|
|
+ modified by .usecs to have timestamps
|
|
|
|
+ interpreted as microseconds.
|
|
|
|
+ cpu int - the cpu on which the event occurred.
|
|
|
|
|
|
|
|
6.2 'hist' trigger examples
|
|
|
|
---------------------------
|
|
|
|
--- a/kernel/trace/trace_events_hist.c
|
|
|
|
+++ b/kernel/trace/trace_events_hist.c
|
2017-11-29 23:05:39 +00:00
|
|
|
@@ -227,6 +227,7 @@ enum hist_field_flags {
|
|
|
|
HIST_FIELD_FL_VAR = 1 << 12,
|
|
|
|
HIST_FIELD_FL_EXPR = 1 << 13,
|
|
|
|
HIST_FIELD_FL_VAR_REF = 1 << 14,
|
|
|
|
+ HIST_FIELD_FL_CPU = 1 << 15,
|
2017-07-09 11:42:39 +00:00
|
|
|
};
|
|
|
|
|
2017-11-20 14:16:49 +00:00
|
|
|
struct var_defs {
|
2018-01-31 19:59:07 +00:00
|
|
|
@@ -1164,6 +1165,16 @@ static u64 hist_field_timestamp(struct h
|
2017-07-09 11:42:39 +00:00
|
|
|
return ts;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static u64 hist_field_cpu(struct hist_field *hist_field,
|
|
|
|
+ struct tracing_map_elt *elt,
|
|
|
|
+ struct ring_buffer_event *rbe,
|
|
|
|
+ void *event)
|
|
|
|
+{
|
2017-11-20 14:16:49 +00:00
|
|
|
+ int cpu = smp_processor_id();
|
2017-07-09 11:42:39 +00:00
|
|
|
+
|
|
|
|
+ return cpu;
|
|
|
|
+}
|
|
|
|
+
|
2017-11-29 23:05:39 +00:00
|
|
|
static struct hist_field *
|
|
|
|
check_field_for_var_ref(struct hist_field *hist_field,
|
|
|
|
struct hist_trigger_data *var_data,
|
2018-01-31 19:59:07 +00:00
|
|
|
@@ -1602,6 +1613,8 @@ static const char *hist_field_name(struc
|
2017-07-09 11:42:39 +00:00
|
|
|
field_name = hist_field_name(field->operands[0], ++level);
|
|
|
|
else if (field->flags & HIST_FIELD_FL_TIMESTAMP)
|
2017-12-20 18:53:59 +00:00
|
|
|
field_name = "common_timestamp";
|
2017-07-09 11:42:39 +00:00
|
|
|
+ else if (field->flags & HIST_FIELD_FL_CPU)
|
|
|
|
+ field_name = "cpu";
|
|
|
|
else if (field->flags & HIST_FIELD_FL_EXPR ||
|
2017-11-29 23:05:39 +00:00
|
|
|
field->flags & HIST_FIELD_FL_VAR_REF) {
|
|
|
|
if (field->system) {
|
2018-01-31 19:59:07 +00:00
|
|
|
@@ -2109,6 +2122,15 @@ static struct hist_field *create_hist_fi
|
2017-07-09 11:42:39 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ if (flags & HIST_FIELD_FL_CPU) {
|
|
|
|
+ hist_field->fn = hist_field_cpu;
|
|
|
|
+ hist_field->size = sizeof(int);
|
2017-12-20 18:53:59 +00:00
|
|
|
+ hist_field->type = kstrdup("unsigned int", GFP_KERNEL);
|
2017-07-09 11:42:39 +00:00
|
|
|
+ if (!hist_field->type)
|
|
|
|
+ goto free;
|
|
|
|
+ goto out;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (WARN_ON_ONCE(!field))
|
|
|
|
goto out;
|
|
|
|
|
2018-01-05 09:53:38 +00:00
|
|
|
@@ -2345,7 +2367,9 @@ parse_field(struct hist_trigger_data *hi
|
2017-07-09 11:42:39 +00:00
|
|
|
hist_data->enable_timestamps = true;
|
|
|
|
if (*flags & HIST_FIELD_FL_TIMESTAMP_USECS)
|
|
|
|
hist_data->attrs->ts_in_usecs = true;
|
|
|
|
- } else {
|
|
|
|
+ } else if (strcmp(field_name, "cpu") == 0)
|
|
|
|
+ *flags |= HIST_FIELD_FL_CPU;
|
|
|
|
+ else {
|
|
|
|
field = trace_find_event_field(file->event_call, field_name);
|
2017-11-20 14:16:49 +00:00
|
|
|
if (!field || !field->size) {
|
|
|
|
field = ERR_PTR(-EINVAL);
|
2018-01-05 09:53:38 +00:00
|
|
|
@@ -4621,6 +4645,8 @@ static void hist_field_print(struct seq_
|
2017-07-09 11:42:39 +00:00
|
|
|
|
|
|
|
if (hist_field->flags & HIST_FIELD_FL_TIMESTAMP)
|
2017-12-20 18:53:59 +00:00
|
|
|
seq_puts(m, "common_timestamp");
|
2017-07-09 11:42:39 +00:00
|
|
|
+ else if (hist_field->flags & HIST_FIELD_FL_CPU)
|
|
|
|
+ seq_puts(m, "cpu");
|
2017-11-29 23:05:39 +00:00
|
|
|
else if (field_name) {
|
|
|
|
if (hist_field->flags & HIST_FIELD_FL_VAR_REF)
|
|
|
|
seq_putc(m, '$');
|