linux-brain/Documentation/trace
Steven Rostedt (VMware) 59a9f75fb2 tracing/histogram: Rename "cpu" to "common_cpu"
commit 1e3bac71c5053c99d438771fc9fa5082ae5d90aa upstream.

Currently the histogram logic allows the user to write "cpu" in as an
event field, and it will record the CPU that the event happened on.

The problem with this is that there's a lot of events that have "cpu"
as a real field, and using "cpu" as the CPU it ran on, makes it
impossible to run histograms on the "cpu" field of events.

For example, if I want to have a histogram on the count of the
workqueue_queue_work event on its cpu field, running:

 ># echo 'hist:keys=cpu' > events/workqueue/workqueue_queue_work/trigger

Gives a misleading and wrong result.

Change the command to "common_cpu" as no event should have "common_*"
fields as that's a reserved name for fields used by all events. And
this makes sense here as common_cpu would be a field used by all events.

Now we can even do:

 ># echo 'hist:keys=common_cpu,cpu if cpu < 100' > events/workqueue/workqueue_queue_work/trigger
 ># cat events/workqueue/workqueue_queue_work/hist
 # event histogram
 #
 # trigger info: hist:keys=common_cpu,cpu:vals=hitcount:sort=hitcount:size=2048 if cpu < 100 [active]
 #

 { common_cpu:          0, cpu:          2 } hitcount:          1
 { common_cpu:          0, cpu:          4 } hitcount:          1
 { common_cpu:          7, cpu:          7 } hitcount:          1
 { common_cpu:          0, cpu:          7 } hitcount:          1
 { common_cpu:          0, cpu:          1 } hitcount:          1
 { common_cpu:          0, cpu:          6 } hitcount:          2
 { common_cpu:          0, cpu:          5 } hitcount:          2
 { common_cpu:          1, cpu:          1 } hitcount:          4
 { common_cpu:          6, cpu:          6 } hitcount:          4
 { common_cpu:          5, cpu:          5 } hitcount:         14
 { common_cpu:          4, cpu:          4 } hitcount:         26
 { common_cpu:          0, cpu:          0 } hitcount:         39
 { common_cpu:          2, cpu:          2 } hitcount:        184

Now for backward compatibility, I added a trick. If "cpu" is used, and
the field is not found, it will fall back to "common_cpu" and work as
it did before. This way, it will still work for old programs that use
"cpu" to get the actual CPU, but if the event has a "cpu" as a field, it
will get that event's "cpu" field, which is probably what it wants
anyway.

I updated the tracefs/README to include documentation about both the
common_timestamp and the common_cpu. This way, if that text is present in
the README, then an application can know that common_cpu is supported over
just plain "cpu".

Link: https://lkml.kernel.org/r/20210721110053.26b4f641@oasis.local.home

Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: stable@vger.kernel.org
Fixes: 8b7622bf94 ("tracing: Add cpu field for hist triggers")
Reviewed-by: Tom Zanussi <zanussi@kernel.org>
Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-28 13:31:00 +02:00
..
postprocess tweewide: Fix most Shebang lines 2021-05-22 11:38:30 +02:00
coresight-cpu-debug.rst Documentation: coresight: convert txt to rst 2019-07-31 13:13:45 -06:00
coresight.rst Documentation: coresight: convert txt to rst 2019-07-31 13:13:45 -06:00
events-kmem.rst trace doc: convert trace/events-kmem.txt to rst format 2018-03-07 10:25:54 -07:00
events-msr.rst trace doc: convert trace/events-msr.txt to rst format 2018-03-07 10:26:06 -07:00
events-nmi.rst trace doc: convert trace/events-nmi.txt to rst format 2018-03-07 10:26:02 -07:00
events-power.rst cpufreq: trace frequency limits change 2018-07-26 10:17:47 +02:00
events.rst docs: histogram.txt: convert it to ReST file format 2018-07-02 11:26:02 -06:00
ftrace-design.rst trace doc: convert trace/ftrace-design.txt to rst format 2018-03-07 10:22:57 -07:00
ftrace-uses.rst docs: Fix some broken references 2018-06-15 18:10:01 -03:00
ftrace.rst docs: ftrace: clarify when tracing is disabled by the trace file 2019-09-02 07:14:53 -06:00
function-graph-fold.vim tracing: Add vim script to enable folding for function_graph traces 2009-08-26 00:32:04 -04:00
histogram.rst tracing/histogram: Rename "cpu" to "common_cpu" 2021-07-28 13:31:00 +02:00
hwlat_detector.rst trace doc: convert trace/hwlat_detector.txt to rst fromat 2018-03-07 10:26:14 -07:00
index.rst Documentation: coresight: convert txt to rst 2019-07-31 13:13:45 -06:00
intel_th.rst intel_th: SPDX-ify the documentation 2019-05-03 18:14:29 +02:00
kprobetrace.rst tracing/probe: Add immediate parameter support 2019-08-31 12:19:39 -04:00
mmiotrace.rst trace doc: convert trace/mmiotrace.txt to rst format 2018-03-07 10:26:10 -07:00
ring-buffer-design.txt doc: fix double words 2014-03-21 13:16:58 +01:00
stm.rst stm class: SPDX-ify the documentation 2018-10-11 12:12:55 +02:00
sys-t.rst stm class: Document the MIPI SyS-T protocol usage 2018-10-11 12:12:55 +02:00
tracepoint-analysis.rst docs: Fix some broken references 2018-06-15 18:10:01 -03:00
tracepoints.rst trace doc: convert trace/tracepoints.txt to rst format 2018-03-07 10:23:23 -07:00
uprobetracer.rst tracing/probe: Add immediate parameter support 2019-08-31 12:19:39 -04:00