linux-stable/Documentation/trace
Steven Rostedt (VMware) a5e1aff589 tracing/histogram: Rename "cpu" to "common_cpu"
commit 1e3bac71c5 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 14:35:45 +02:00
..
coresight docs: trace: coresight-ect.rst: Fix a build warning 2020-05-19 16:31:16 +02:00
postprocess tweewide: Fix most Shebang lines 2021-05-22 11:40:55 +02:00
boottime-trace.rst Documentation: tracing: Add the startup timing of boot-time tracing 2020-09-21 21:06:04 -04: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 Replace HTTP links with HTTPS ones: documentation 2020-06-08 09:30:19 -06: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 PM: QoS: Simplify definitions of CPU latency QoS trace events 2020-02-13 11:26:39 +01:00
events.rst tracing: Add support for dynamic strings to synthetic events 2020-10-05 19:32:18 -04:00
ftrace-design.rst sh/ftrace: Move arch_ftrace_nmi_{enter,exit} into nmi exception 2020-05-19 15:51:18 +02:00
ftrace-uses.rst docs: trace-uses.rst: remove bogus c-domain tags 2020-10-15 07:49:40 +02:00
ftrace.rst It's been a busy cycle for documentation - hopefully the busiest for a 2020-08-04 22:47:54 -07:00
function-graph-fold.vim
histogram-design.rst Documentation: trace/histogram-design: drop doubled words 2020-07-05 14:40:55 -06:00
histogram.rst tracing/histogram: Rename "cpu" to "common_cpu" 2021-07-28 14:35:45 +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 docs: trace/index.rst: add histogram-design.rst 2020-07-23 14:15:59 -06:00
intel_th.rst docs: trace: fix a typo 2020-08-11 10:22:15 -06:00
kprobes.rst docs: Move kprobes.rst from staging/ to trace/ 2020-07-23 14:01:24 -06:00
kprobetrace.rst Updates for tracing and bootconfig: 2020-10-15 15:51:28 -07:00
mmiotrace.rst Replace HTTP links with HTTPS ones: documentation 2020-06-08 09:30:19 -06:00
ring-buffer-design.rst docs: trace: ring-buffer-design.rst: use the new SPDX tag 2020-09-24 11:07:44 -06:00
stm.rst Documentation: trace/stm: drop doubled words 2020-07-05 14:40:55 -06: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 tracepoints: Add helper to test if tracepoint is enabled in a header 2020-09-25 18:01:35 -04:00
uprobetracer.rst Documentation: tracing: Add %return suffix description 2020-09-21 21:06:03 -04:00