Ian Rogers
61e0a94463
perf string: Avoid undefined NULL+1
...
While the value NULL+1 is never used it triggers a ubsan warning.
Restructure and comment the loop to avoid this.
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20241120065224.286813-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-12 15:53:36 -03:00
Namhyung Kim
ad5d76aecd
perf tools: Avoid unaligned pointer operations
...
The sample data is 64-bit aligned basically but raw data starts with
32-bit length field and data follows. In perf_event__synthesize_sample
it treats the sample data as a 64-bit array. And it needs some trick
to update the raw data properly.
But it seems some compilers are not happy with this and the program dies
siliently. I found the sample parsing test failed without any messages
on affected systems.
Let's update the code to use a 32-bit pointer directly and make sure the
result is 64-bit aligned again. No functional changes intended.
Reviewed-by: Ian Rogers <irogers@google.com >
Reviewed-by: Kan Liang <kan.liang@linux.intel.com >
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20241128010325.946897-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-12 15:36:46 -03:00
James Clark
434fffa926
perf probe: Fix uninitialized variable
...
Since the linked fixes: commit, err is returned uninitialized due to the
removal of "return 0". Initialize err to fix it.
This fixes the following intermittent test failure on release builds:
$ perf test "testsuite_probe"
...
-- [ FAIL ] -- perf_probe :: test_invalid_options :: mutually exclusive options :: -L foo -V bar (output regexp parsing)
Regexp not found: \"Error: switch .+ cannot be used with switch .+\"
...
Fixes: 080e47b2a2 ("perf probe: Introduce quotation marks support")
Tested-by: Namhyung Kim <namhyung@kernel.org >
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org >
Signed-off-by: James Clark <james.clark@linaro.org >
Link: https://lore.kernel.org/r/20241211085525.519458-2-james.clark@linaro.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2024-12-11 21:40:46 -08:00
Zhongqiu Han
03edb7020b
perf bpf: Fix two memory leakages when calling perf_env__insert_bpf_prog_info()
...
If perf_env__insert_bpf_prog_info() returns false due to a duplicate bpf
prog info node insertion, the temporary info_node and info_linear memory
will leak. Add a check to ensure the memory is freed if the function
returns false.
Fixes: d56354dc49 ("perf tools: Save bpf_prog_info and BTF of new BPF programs")
Reviewed-by: Namhyung Kim <namhyung@kernel.org >
Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Yicong Yang <yangyicong@hisilicon.com >
Link: https://lore.kernel.org/r/20241205084500.823660-4-quic_zhonhan@quicinc.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-10 16:59:32 -03:00
Zhongqiu Han
a7da6c7030
perf header: Fix one memory leakage in process_bpf_prog_info()
...
Function __perf_env__insert_bpf_prog_info() will return without inserting
bpf prog info node into perf env again due to a duplicate bpf prog info
node insertion, causing the temporary info_linear and info_node memory to
leak. Modify the return type of this function to bool and add a check to
ensure the memory is freed if the function returns false.
Fixes: 606f972b13 ("perf bpf: Save bpf_prog_info information as headers to perf.data")
Reviewed-by: Namhyung Kim <namhyung@kernel.org >
Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Yicong Yang <yangyicong@hisilicon.com >
Link: https://lore.kernel.org/r/20241205084500.823660-3-quic_zhonhan@quicinc.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-10 16:59:32 -03:00
Zhongqiu Han
875d22980a
perf header: Fix one memory leakage in process_bpf_btf()
...
If __perf_env__insert_btf() returns false due to a duplicate btf node
insertion, the temporary node will leak. Add a check to ensure the memory
is freed if the function returns false.
Fixes: a70a112317 ("perf bpf: Save BTF information as headers to perf.data")
Reviewed-by: Namhyung Kim <namhyung@kernel.org >
Signed-off-by: Zhongqiu Han <quic_zhonhan@quicinc.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Song Liu <song@kernel.org >
Cc: Yicong Yang <yangyicong@hisilicon.com >
Link: https://lore.kernel.org/r/20241205084500.823660-2-quic_zhonhan@quicinc.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-10 16:59:32 -03:00
Masami Hiramatsu (Google)
b223564fe1
perf probe: Replace unacceptable characters when generating event name
...
Replace unacceptable characters with '_' when generating event name from
the probing function name.
This is not for a C program. For the a C program, it will continue to
remove suffixes.
Note that this language checking depends on the debuginfo. So without
the debuginfo, perf probe will always replaces unacceptable characters
with '_'.
For example.
$ ./perf probe -x cro3 -D \"cro3::cmd::servo::run_show\"
p:probe_cro3/cro3_cmd_servo_run_show /work/cro3/target/x86_64-unknown-linux-gnu/debug/cro3:0x197530
$ ./perf probe -x /work/go/example/outyet/main -D 'main.(*Server).poll'
p:probe_main/main_Server_poll /work/go/example/outyet/main:0x353040
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Alexander Lobakin <aleksander.lobakin@intel.com >
Cc: Dima Kogan <dima@secretsauce.net >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com >
Link: https://lore.kernel.org/r/173145728160.2747044.18089011235495186810.stgit@mhiramat.roam.corp.google.com
[ Removed some extra tabs in the new struct fields ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-10 15:41:10 -03:00
Gabriele Monaco
690a052a6d
perf ftrace latency: Add --max-latency option
...
This patch adds a max-latency option as discussed, in case the number of
buckets is more than 22, we don't observe the setting (for now, let's
say).
By default or if 0 is passed, the value is automatically determined
based on the number of buckets, range and minimum, so that we fill all
available buffers (equivalent to the behaviour before this patch).
We now get something like this:
# perf ftrace latency --bucket-range=20 \
--min-latency 10 \
--max-latency=100 \
-T switch_mm_irqs_off -a sleep 2
# DURATION | COUNT | GRAPH |
0 - 10 us | 1731 | ################ |
10 - 30 us | 1 | |
30 - 50 us | 0 | |
50 - 70 us | 0 | |
70 - 90 us | 0 | |
90 - 100 us | 0 | |
100 - ... us | 0 | |
Note the maximum is observed also if it doesn't cover completely a full
range (the second to last range is 10us long to let the last start at
100 sharp), this looks to me more sensible and eases the computations,
since we don't need to account for the range while filling the buckets.
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Clark Williams <williams@redhat.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Link: https://lore.kernel.org/r/20241112181214.1171244-5-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-10 15:16:40 -03:00
Arnaldo Carvalho de Melo
08b875b6bf
perf ftrace latency: Introduce --min-latency to narrow down into a latency range
...
Things below and over will be in the first and last, outlier, buckets.
Without it:
# perf ftrace latency --use-nsec --use-bpf \
--bucket-range=200 \
-T switch_mm_irqs_off -a sleep 2
# DURATION | COUNT | GRAPH |
0 - 200 ns | 0 | |
200 - 400 ns | 44 | |
400 - 600 ns | 291 | # |
600 - 800 ns | 506 | ## |
800 - 1000 ns | 148 | |
1.00 - 1.20 us | 581 | ## |
1.20 - 1.40 us | 2199 | ########## |
1.40 - 1.60 us | 1048 | #### |
1.60 - 1.80 us | 1448 | ###### |
1.80 - 2.00 us | 1091 | ##### |
2.00 - 2.20 us | 517 | ## |
2.20 - 2.40 us | 318 | # |
2.40 - 2.60 us | 370 | # |
2.60 - 2.80 us | 271 | # |
2.80 - 3.00 us | 150 | |
3.00 - 3.20 us | 85 | |
3.20 - 3.40 us | 48 | |
3.40 - 3.60 us | 40 | |
3.60 - 3.80 us | 22 | |
3.80 - 4.00 us | 13 | |
4.00 - 4.20 us | 14 | |
4.20 - ... us | 626 | ## |
#
# perf ftrace latency --use-nsec --use-bpf \
--bucket-range=20 --min-latency=1200 \
-T switch_mm_irqs_off -a sleep 2
# DURATION | COUNT | GRAPH |
0 - 1200 ns | 1243 | ##### |
1.20 - 1.22 us | 141 | |
1.22 - 1.24 us | 202 | |
1.24 - 1.26 us | 209 | |
1.26 - 1.28 us | 219 | |
1.28 - 1.30 us | 208 | |
1.30 - 1.32 us | 245 | # |
1.32 - 1.34 us | 246 | # |
1.34 - 1.36 us | 224 | # |
1.36 - 1.38 us | 219 | |
1.38 - 1.40 us | 206 | |
1.40 - 1.42 us | 190 | |
1.42 - 1.44 us | 190 | |
1.44 - 1.46 us | 146 | |
1.46 - 1.48 us | 140 | |
1.48 - 1.50 us | 125 | |
1.50 - 1.52 us | 115 | |
1.52 - 1.54 us | 102 | |
1.54 - 1.56 us | 87 | |
1.56 - 1.58 us | 90 | |
1.58 - 1.60 us | 85 | |
1.60 - ... us | 5487 | ######################## |
#
Now we want focus on the latencies starting at 1.2us, with a finer
grained range of 20ns:
This is all on a live system, so statistically interesting, but not
narrowing down on the same numbers, so a 'perf ftrace latency record'
seems interesting to then use all on the same snapshot of latencies.
A --max-latency counterpart should come next, at first limiting the
max-latency to 20 * bucket-size, as we have a fixed buckets array with
20 + 2 entries (+ for the outliers) and thus would need to make it
larger for higher latencies.
We also may need a way to ask for not considering the out of range
values (first and last buckets) when drawing the buckets bars.
Co-developed-by: Gabriele Monaco <gmonaco@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Clark Williams <williams@redhat.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Link: https://lore.kernel.org/r/20241112181214.1171244-4-acme@kernel.org
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-10 15:16:27 -03:00
Arnaldo Carvalho de Melo
e8536dd47a
perf ftrace latency: Introduce --bucket-range to ask for linear bucketing
...
In addition to showing it exponentially, using log2() to figure out the
histogram index, allow for showing it linearly:
The preexisting more, the default:
# perf ftrace latency --use-nsec --use-bpf \
-T switch_mm_irqs_off -a sleep 2
# DURATION | COUNT | GRAPH |
0 - 1 ns | 0 | |
1 - 2 ns | 0 | |
2 - 4 ns | 0 | |
4 - 8 ns | 0 | |
8 - 16 ns | 0 | |
16 - 32 ns | 0 | |
32 - 64 ns | 0 | |
64 - 128 ns | 238 | # |
128 - 256 ns | 1704 | ########## |
256 - 512 ns | 672 | ### |
512 - 1024 ns | 4458 | ########################## |
1 - 2 us | 677 | #### |
2 - 4 us | 5 | |
4 - 8 us | 0 | |
8 - 16 us | 0 | |
16 - 32 us | 0 | |
32 - 64 us | 0 | |
64 - 128 us | 0 | |
128 - 256 us | 0 | |
256 - 512 us | 0 | |
512 - 1024 us | 0 | |
1 - ... ms | 0 | |
#
The new histogram mode:
# perf ftrace latency --bucket-range=150 --use-nsec --use-bpf \
-T switch_mm_irqs_off -a sleep 2
# DURATION | COUNT | GRAPH |
0 - 1 ns | 0 | |
1 - 151 ns | 265 | # |
151 - 301 ns | 1797 | ########### |
301 - 451 ns | 258 | # |
451 - 601 ns | 289 | # |
601 - 751 ns | 2049 | ############# |
751 - 901 ns | 967 | ###### |
901 - 1051 ns | 513 | ### |
1.05 - 1.20 us | 114 | |
1.20 - 1.35 us | 559 | ### |
1.35 - 1.50 us | 189 | # |
1.50 - 1.65 us | 137 | |
1.65 - 1.80 us | 32 | |
1.80 - 1.95 us | 2 | |
1.95 - 2.10 us | 0 | |
2.10 - 2.25 us | 1 | |
2.25 - 2.40 us | 1 | |
2.40 - 2.55 us | 0 | |
2.55 - 2.70 us | 0 | |
2.70 - 2.85 us | 0 | |
2.85 - 3.00 us | 1 | |
3.00 - ... us | 4 | |
#
Co-developed-by: Gabriele Monaco <gmonaco@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Clark Williams <williams@redhat.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@kernel.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Thomas Gleixner <tglx@linutronix.de >
Link: https://lore.kernel.org/r/20241112181214.1171244-3-acme@kernel.org
Signed-off-by: Gabriele Monaco <gmonaco@redhat.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-10 15:16:01 -03:00
Ian Rogers
3f61a12b08
perf hwmon_pmu: Use openat rather than dup to refresh directory
...
The hwmon PMU test will make a temp directory, open the directory with
O_DIRECTORY then fill it with contents. As the open is before the
filling the contents the later fdopendir may reflect the initial empty
state, meaning no events are seen. Change to re-open the directory,
rather than dup the fd, so the latest contents are seen.
Minor tweaks/additions to debug messages.
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Arnaldo Carvalho de Melo <acme@kernel.org >
Link: https://lore.kernel.org/r/20241206042306.1055913-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2024-12-09 15:00:03 -08:00
Ian Rogers
9a4426120d
perf hwmon_pmu: Use openat rather than dup to refresh directory
...
The hwmon PMU test will make a temp directory, open the directory with
O_DIRECTORY then fill it with contents. As the open is before the
filling the contents the later fdopendir may reflect the initial empty
state, meaning no events are seen. Change to re-open the directory,
rather than dup the fd, so the latest contents are seen.
Minor tweaks/additions to debug messages.
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20241206042306.1055913-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-09 18:15:30 -03:00
Ian Rogers
6c8310e838
perf evsel: Allow evsel__newtp without libtraceevent
...
Switch from reading the tracepoint format to reading the id directly for
the evsel config. This avoids the need to initialize libtraceevent,
plugins, etc. It is sufficient for many tracepoint commands to work
like:
$ perf stat -e sched:sched_switch true
To populate evsel->tp_format, do lazy initialization using libtraceevent
in the evsel__tp_format function (the sys and name are saved in
evsel__newtp_idx for this purpose).
Reading the id should be indicative of the format failing to load, but
if not an error is reported in evsel__tp_format. This could happen for a
tracepoint with a format that fails to parse.
As tracepoints can be parsed without libtraceevent with this, remove the
associated #ifdefs in parse-events.c.
By only lazily parsing the tracepoint format information it is hoped
this will help improve the performance of code using tracepoints but not
the format information. It also cuts down on the build and ifdef logic.
Reviewed-by: Namhyung Kim <namhyung@kernel.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Ben Gainey <ben.gainey@arm.com >
Cc: Colin Ian King <colin.i.king@gmail.com >
Cc: Dominique Martinet <asmadeus@codewreck.org >
Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Oliver Upton <oliver.upton@linux.dev >
Cc: Paran Lee <p4ranlee@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org >
Cc: Thomas Falcon <thomas.falcon@intel.com >
Cc: Weilin Wang <weilin.wang@intel.com >
Cc: Yang Jihong <yangjihong@bytedance.com >
Cc: Yang Li <yang.lee@linux.alibaba.com >
Cc: Ze Gao <zegao2021@gmail.com >
Cc: Zixian Cai <fzczx123@gmail.com >
Cc: zhaimingbing <zhaimingbing@cmss.chinamobile.com >
Link: https://lore.kernel.org/r/20241118225345.889810-7-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-09 17:52:42 -03:00
Ian Rogers
c46d634a03
perf evsel: Add/use accessor for tp_format
...
Add an accessor function for tp_format. Rather than search+replace
uses try to use a variable and reuse it. Add additional NULL checks
when accessing/using the value. Make sure the PTR_ERR is nulled out on
error path in evsel__newtp_idx.
Reviewed-by: Namhyung Kim <namhyung@kernel.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Ben Gainey <ben.gainey@arm.com >
Cc: Colin Ian King <colin.i.king@gmail.com >
Cc: Dominique Martinet <asmadeus@codewreck.org >
Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Oliver Upton <oliver.upton@linux.dev >
Cc: Paran Lee <p4ranlee@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org >
Cc: Thomas Falcon <thomas.falcon@intel.com >
Cc: Weilin Wang <weilin.wang@intel.com >
Cc: Yang Jihong <yangjihong@bytedance.com >
Cc: Yang Li <yang.lee@linux.alibaba.com >
Cc: Ze Gao <zegao2021@gmail.com >
Cc: Zixian Cai <fzczx123@gmail.com >
Cc: zhaimingbing <zhaimingbing@cmss.chinamobile.com >
Link: https://lore.kernel.org/r/20241118225345.889810-6-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-09 17:52:42 -03:00
Ian Rogers
800c93ffaf
perf trace-event: Always build trace-event-info.c
...
trace-event-info.c has no libtraceevent dependencies, always build it
and use it in builtin-record and perf_event_attr printing.
Reviewed-by: Namhyung Kim <namhyung@kernel.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Ben Gainey <ben.gainey@arm.com >
Cc: Colin Ian King <colin.i.king@gmail.com >
Cc: Dominique Martinet <asmadeus@codewreck.org >
Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Oliver Upton <oliver.upton@linux.dev >
Cc: Paran Lee <p4ranlee@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org >
Cc: Thomas Falcon <thomas.falcon@intel.com >
Cc: Weilin Wang <weilin.wang@intel.com >
Cc: Yang Jihong <yangjihong@bytedance.com >
Cc: Yang Li <yang.lee@linux.alibaba.com >
Cc: Ze Gao <zegao2021@gmail.com >
Cc: Zixian Cai <fzczx123@gmail.com >
Cc: zhaimingbing <zhaimingbing@cmss.chinamobile.com >
Link: https://lore.kernel.org/r/20241118225345.889810-5-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-09 17:52:42 -03:00
Ian Rogers
f7264150b4
perf trace-event: Constify print arguments
...
Capture that these functions don't mutate their input.
Reviewed-by: Namhyung Kim <namhyung@kernel.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Ben Gainey <ben.gainey@arm.com >
Cc: Colin Ian King <colin.i.king@gmail.com >
Cc: Dominique Martinet <asmadeus@codewreck.org >
Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Oliver Upton <oliver.upton@linux.dev >
Cc: Paran Lee <p4ranlee@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org >
Cc: Thomas Falcon <thomas.falcon@intel.com >
Cc: Weilin Wang <weilin.wang@intel.com >
Cc: Yang Jihong <yangjihong@bytedance.com >
Cc: Yang Li <yang.lee@linux.alibaba.com >
Cc: Ze Gao <zegao2021@gmail.com >
Cc: Zixian Cai <fzczx123@gmail.com >
Cc: zhaimingbing <zhaimingbing@cmss.chinamobile.com >
Link: https://lore.kernel.org/r/20241118225345.889810-4-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-09 17:52:42 -03:00
Ian Rogers
925c25efca
perf env: Ensure failure broken topology file reads are always -1 encoded
...
get_core_id returns 0 on success and a negative errno value on error.
Currently the error can only be -1, but fixing this to be any errno
value breaks perf:
https://lore.kernel.org/lkml/Zzu4Sdebve-NXEMX@google.com/
To avoid this, make sure all error values are written as -1.
Reviewed-by: Namhyung Kim <namhyung@kernel.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Andi Kleen <ak@linux.intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Ben Gainey <ben.gainey@arm.com >
Cc: Colin Ian King <colin.i.king@gmail.com >
Cc: Dominique Martinet <asmadeus@codewreck.org >
Cc: Ilkka Koskinen <ilkka@os.amperecomputing.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Oliver Upton <oliver.upton@linux.dev >
Cc: Paran Lee <p4ranlee@gmail.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Steven Rostedt (VMware) <rostedt@goodmis.org >
Cc: Thomas Falcon <thomas.falcon@intel.com >
Cc: Weilin Wang <weilin.wang@intel.com >
Cc: Yang Jihong <yangjihong@bytedance.com >
Cc: Yang Li <yang.lee@linux.alibaba.com >
Cc: Ze Gao <zegao2021@gmail.com >
Cc: Zixian Cai <fzczx123@gmail.com >
Cc: zhaimingbing <zhaimingbing@cmss.chinamobile.com >
Link: https://lore.kernel.org/r/20241118225345.889810-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-09 17:52:42 -03:00
Arnaldo Carvalho de Melo
dcf900429d
perf btf: Make the sigtrap test helper to find a member by name widely available
...
By introducing a tools/perf/util/btf.c to collect utilities not yet
available via libbpf, the first being a way to find a member by name
once we get the type_id for the struct.
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-09 17:52:41 -03:00
Ian Rogers
4b8a7c0327
perf pmu: Remove use of perf_cpu_map__read()
...
Remove use of a FILE and switch to reading a string that is then
passed to perf_cpu_map__new().
Being able to remove perf_cpu_map__read() avoids duplicated parsing logic.
Reviewed-by: Leo Yan <leo.yan@arm.com >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ben Gainey <ben.gainey@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Kyle Meyer <kyle.meyer@hpe.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20241206044035.1062032-6-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-09 17:52:41 -03:00
Ian Rogers
02b5ed8a6a
perf cpumap: Reduce transitive dependencies on libperf MAX_NR_CPUS
...
libperf exposes MAX_NR_CPUS via tools/lib/perf/include/internal/cpumap.h
which is internal.
The preferred dependency should be the definition in tools/perf/perf.h.
Add the includes of perf.h so that MAX_NR_CPUS can be hidden in libperf.
Reviewed-by: Leo Yan <leo.yan@arm.com >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ben Gainey <ben.gainey@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Kyle Meyer <kyle.meyer@hpe.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20241206044035.1062032-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-09 17:52:41 -03:00
Kyle Meyer
9a1e106550
perf: Increase MAX_NR_CPUS to 4096
...
Systems have surpassed 2048 CPUs. Increase MAX_NR_CPUS to 4096.
Bitmaps declared with MAX_NR_CPUS bits will increase from 256B to 512B,
cpus_runtime will increase from 81960B to 163880B, and max_entries will
increase from 8192B to 16384B.
Reviewed-by: Ian Rogers <irogers@google.com >
Reviewed-by: Leo Yan <leo.yan@arm.com >
Signed-off-by: Kyle Meyer <kyle.meyer@hpe.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ben Gainey <ben.gainey@arm.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20241206044035.1062032-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-09 17:52:41 -03:00
Ilkka Koskinen
9e7a00ec6a
perf arm-spe: Add support for SPE Data Source packet on AmpereOne
...
Decode SPE Data Source packets on AmpereOne. The field is IMPDEF.
Reviewed-by: Leo Yan <leo.yan@arm.com >
Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Graham Woodward <graham.woodward@arm.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linux.dev >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Will Deacon <will@kernel.org >
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20241108202946.16835-3-ilkka@os.amperecomputing.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-09 17:52:41 -03:00
Ilkka Koskinen
ccdc9e9c5e
perf arm-spe: Prepare for adding data source packet implementations for other cores
...
Split Data Source Packet handling to prepare adding support for
other implementations.
Reviewed-by: Leo Yan <leo.yan@arm.com >
Signed-off-by: Ilkka Koskinen <ilkka@os.amperecomputing.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Graham Woodward <graham.woodward@arm.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linux.dev >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Will Deacon <will@kernel.org >
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20241108202946.16835-2-ilkka@os.amperecomputing.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-09 17:52:41 -03:00
Leo Yan
a9d2217556
libperf cpumap: Refactor perf_cpu_map__merge()
...
The perf_cpu_map__merge() function has two arguments, 'orig' and
'other'. The function definition might cause confusion as it could give
the impression that the CPU maps in the two arguments are copied into a
new allocated structure, which is then returned as the result.
The purpose of the function is to merge the CPU map 'other' into the CPU
map 'orig'. This commit changes the 'orig' argument to a pointer to
pointer, so the new result will be updated into 'orig'.
The return value is changed to an int type, as an error number or 0 for
success.
Update callers and tests for the new function definition.
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com >
Signed-off-by: Leo Yan <leo.yan@arm.com >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Link: https://lore.kernel.org/r/20241107125308.41226-2-leo.yan@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-09 17:52:41 -03:00
Arnaldo Carvalho de Melo
b2b95a2d78
perf disasm: Return a proper error when not determining the file type
...
Before:
⬢ [acme@toolbox a]$ perf annotate --stdio2 -i acme-perf-injected.data 'java.lang.String com.fasterxml.jackson.core.sym.CharsToNameCanonicalizer.findSymbol(char[], int, int, int)'
Error:
Couldn't annotate java.lang.String com.fasterxml.jackson.core.sym.CharsToNameCanonicalizer.findSymbol(char[], int, int, int):
Internal error: Invalid -1 error code
⬢ [acme@toolbox a]$
After:
⬢ [acme@toolbox a]$ perf annotate --stdio2 -i acme-perf-injected.data 'java.lang.String com.fasterxml.jackson.core.sym.CharsToNameCanonicalizer.findSymbol(char[], int, int, int)'
Error:
Couldn't annotate java.lang.String com.fasterxml.jackson.core.sym.CharsToNameCanonicalizer.findSymbol(char[], int, int, int):
Couldn't determine the file /tmp/perf-3308868.map type.
⬢ [acme@toolbox a]$
Reported-by: Francesco Nigro <fnigro@redhat.com >
Reported-by: Ilan Green <igreen@redhat.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: James Clark <james.clark@linaro.org >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Stephane Eranian <eranian@google.com >
Cc: Yonatan Goldschmidt <yonatan.goldschmidt@granulate.io >
Link: https://lore.kernel.org/lkml/Z092D9-r_iOgwIWM@x1
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-12-09 17:51:53 -03:00
Namhyung Kim
c33aea446b
perf tools: Fix precise_ip fallback logic
...
Sometimes it returns other than EOPNOTSUPP for invalid precise_ip so
it cannot check the error code. Let's move the fallback after the
missing feature checks so that it can handle EINVAL as well. This also
aligns well with the existing behavior which blindly turns off the
precise_ip but we check the missing features correctly now.
Fixes: af954f76ee ("perf tools: Check fallback error and order")
Reported-by: kernel test robot <oliver.sang@intel.com >
Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Closes: https://lore.kernel.org/oe-lkp/202411301431.799e5531-lkp@intel.com
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Link: https://lore.kernel.org/r/Z1DV0lN8qHSysX7f@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2024-12-05 15:15:29 -08:00
Arnaldo Carvalho de Melo
88a6e2f67c
perf machine: Initialize machine->env to address a segfault
...
Its used from trace__run(), for the 'perf trace' live mode, i.e. its
strace-like, non-perf.data file processing mode, the most common one.
The trace__run() function will set trace->host using machine__new_host()
that is supposed to give a machine instance representing the running
machine, and since we'll use perf_env__arch_strerrno() to get the right
errno -> string table, we need to use machine->env, so initialize it in
machine__new_host().
Before the patch:
(gdb) run trace --errno-summary -a sleep 1
<SNIP>
Summary of events:
gvfs-afc-volume (3187), 2 events, 0.0%
syscall calls errors total min avg max stddev
(msec) (msec) (msec) (msec) (%)
--------------- -------- ------ -------- --------- --------- --------- ------
pselect6 1 0 0.000 0.000 0.000 0.000 0.00%
GUsbEventThread (3519), 2 events, 0.0%
syscall calls errors total min avg max stddev
(msec) (msec) (msec) (msec) (%)
--------------- -------- ------ -------- --------- --------- --------- ------
poll 1 0 0.000 0.000 0.000 0.000 0.00%
<SNIP>
Program received signal SIGSEGV, Segmentation fault.
0x00000000005caba0 in perf_env__arch_strerrno (env=0x0, err=110) at util/env.c:478
478 if (env->arch_strerrno == NULL)
(gdb) bt
#0 0x00000000005caba0 in perf_env__arch_strerrno (env=0x0, err=110) at util/env.c:478
#1 0x00000000004b75d2 in thread__dump_stats (ttrace=0x14f58f0, trace=0x7fffffffa5b0, fp=0x7ffff6ff74e0 <_IO_2_1_stderr_>) at builtin-trace.c:4673
#2 0x00000000004b78bf in trace__fprintf_thread (fp=0x7ffff6ff74e0 <_IO_2_1_stderr_>, thread=0x10fa0b0, trace=0x7fffffffa5b0) at builtin-trace.c:4708
#3 0x00000000004b7ad9 in trace__fprintf_thread_summary (trace=0x7fffffffa5b0, fp=0x7ffff6ff74e0 <_IO_2_1_stderr_>) at builtin-trace.c:4747
#4 0x00000000004b656e in trace__run (trace=0x7fffffffa5b0, argc=2, argv=0x7fffffffde60) at builtin-trace.c:4456
#5 0x00000000004ba43e in cmd_trace (argc=2, argv=0x7fffffffde60) at builtin-trace.c:5487
#6 0x00000000004c0414 in run_builtin (p=0xec3068 <commands+648>, argc=5, argv=0x7fffffffde60) at perf.c:351
#7 0x00000000004c06bb in handle_internal_command (argc=5, argv=0x7fffffffde60) at perf.c:404
#8 0x00000000004c0814 in run_argv (argcp=0x7fffffffdc4c, argv=0x7fffffffdc40) at perf.c:448
#9 0x00000000004c0b5d in main (argc=5, argv=0x7fffffffde60) at perf.c:560
(gdb)
After:
root@number:~# perf trace -a --errno-summary sleep 1
<SNIP>
pw-data-loop (2685), 1410 events, 16.0%
syscall calls errors total min avg max stddev
(msec) (msec) (msec) (msec) (%)
--------------- -------- ------ -------- --------- --------- --------- ------
epoll_wait 188 0 983.428 0.000 5.231 15.595 8.68%
ioctl 94 0 0.811 0.004 0.009 0.016 2.82%
read 188 0 0.322 0.001 0.002 0.006 5.15%
write 141 0 0.280 0.001 0.002 0.018 8.39%
timerfd_settime 94 0 0.138 0.001 0.001 0.007 6.47%
gnome-control-c (179406), 1848 events, 20.9%
syscall calls errors total min avg max stddev
(msec) (msec) (msec) (msec) (%)
--------------- -------- ------ -------- --------- --------- --------- ------
poll 222 0 959.577 0.000 4.322 21.414 11.40%
recvmsg 150 0 0.539 0.001 0.004 0.013 5.12%
write 300 0 0.442 0.001 0.001 0.007 3.29%
read 150 0 0.183 0.001 0.001 0.009 5.53%
getpid 102 0 0.101 0.000 0.001 0.008 7.82%
root@number:~#
Fixes: 54373b5d53 ("perf env: Introduce perf_env__arch_strerrno()")
Reported-by: Veronika Molnarova <vmolnaro@redhat.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Acked-by: Veronika Molnarova <vmolnaro@redhat.com >
Acked-by: Michael Petlan <mpetlan@redhat.com >
Tested-by: Michael Petlan <mpetlan@redhat.com >
Link: https://lore.kernel.org/r/Z0XffUgNSv_9OjOi@x1
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2024-12-03 10:07:31 -08:00
Namhyung Kim
23c44f6c83
perf tools: Fix build-id event recording
...
The build-id events written at the end of the record session are broken
due to unexpected data. The write_buildid() writes the fixed length
event first and then variable length filename.
But a recent change made it write more data in the padding area
accidentally. So readers of the event see zero-filled data for the
next entry and treat it incorrectly. This resulted in wrong kernel
symbols because the kernel DSO loaded a random vmlinux image in the
path as it didn't have a valid build-id.
Fixes: ae39ba1655 ("perf inject: Fix build ID injection")
Reported-by: Linus Torvalds <torvalds@linux-foundation.org >
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com >
Reviewed-by: Ian Rogers <irogers@google.com >
Link: https://lore.kernel.org/r/Z0aRFFW9xMh3mqKB@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2024-12-02 12:36:20 -08:00
Ian Rogers
6d78089da9
perf tests: Fix hwmon parsing with PMU name test
...
Incorrectly the hwmon with PMU name test didn't pass "true". Fix and
address issue with hwmon_pmu__config_terms needing to load events - a
load bearing assert fired. Also fix missing list deletion when putting
the hwmon test PMU and lower some debug warnings to make the hwmon PMU
less spammy in verbose mode.
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Namhyung Kim <namhyung@kernel.org >
Link: https://lore.kernel.org/r/20241121000955.536930-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2024-11-22 13:38:39 -08:00
Ian Rogers
62878b400f
perf hwmon_pmu: Ensure hwmon key union is zeroed before use
...
Non-zero values led to mismatches in testing. This was reproducible
with -fsanitize=undefined.
Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org >
Closes: https://lore.kernel.org/lkml/Zzdtj0PEWEX3ATwL@x1/
Signed-off-by: Ian Rogers <irogers@google.com >
Acked-by: Namhyung Kim <namhyung@kernel.org >
Link: https://lore.kernel.org/r/20241119230033.115369-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2024-11-22 13:38:39 -08:00
Hao Ge
bd077a53ad
perf bpf-filter: Return -ENOMEM directly when pfi allocation fails
...
Directly return -ENOMEM when pfi allocation fails,
instead of performing other operations on pfi.
Fixes: 0fe2b18ddc ("perf bpf-filter: Support multiple events properly")
Signed-off-by: Hao Ge <gehao@kylinos.cn >
Acked-by: Namhyung Kim <namhyung@kernel.org >
Cc: hao.ge@linux.dev
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20241113030537.26732-1-hao.ge@linux.dev
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2024-11-22 13:36:00 -08:00
Dr. David Alan Gilbert
85c60a01b8
perf: Remove unused del_perf_probe_events()
...
del_perf_probe_events() last use was removed by commit 3d6dfae889
("perf parse-events: Remove BPF event support")
Remove it.
It was the last user of probe_file__del_events(), so remove it as well.
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20241022002940.302946-1-linux@treblig.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-16 17:07:31 -03:00
Ian Rogers
8f997865ee
perf pmu: Move pmu_metrics_table__find and remove ARM override
...
Move pmu_metrics_table__find() to the jevents.py generated pmu-events.c
and remove indirection override for ARM.
The movement removes perf_pmu__find_metrics_table that exists to enable
the ARM override.
The ARM override isn't necessary as just the CPUID, not PMU, is used in
the metric table lookup.
On non-ARM the CPU argument is just ignored for the CPUID, for ARM -1 is
passed so that the CPUID for the first logical CPU is read.
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Xu Yang <xu.yang_2@nxp.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Ben Zong-You Xie <ben717@andestech.com >
Cc: Benjamin Gray <bgray@linux.ibm.com >
Cc: Bibo Mao <maobibo@loongson.cn >
Cc: Clément Le Goffic <clement.legoffic@foss.st.com >
Cc: Dima Kogan <dima@secretsauce.net >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Huacai Chen <chenhuacai@kernel.org >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linux.dev >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sandipan Das <sandipan.das@amd.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yicong Yang <yangyicong@hisilicon.com >
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-riscv@lists.infradead.org
Link: https://lore.kernel.org/r/20241107162035.52206-9-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-16 16:42:36 -03:00
Ian Rogers
494c403ff1
perf header: Pass a perf_cpu rather than a PMU to get_cpuid_str
...
On ARM the cpuid is dependent on the core type of the CPU in
question. The PMU was passed for the sake of the CPU map but this
means in places a temporary PMU is created just to pass a CPU
value. Just pass the CPU and fix up the callers.
As there are no longer PMU users in header.h, shuffle forward
declarations earlier to work around build failures.
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Xu Yang <xu.yang_2@nxp.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Ben Zong-You Xie <ben717@andestech.com >
Cc: Benjamin Gray <bgray@linux.ibm.com >
Cc: Bibo Mao <maobibo@loongson.cn >
Cc: Clément Le Goffic <clement.legoffic@foss.st.com >
Cc: Dima Kogan <dima@secretsauce.net >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Huacai Chen <chenhuacai@kernel.org >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linux.dev >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sandipan Das <sandipan.das@amd.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yicong Yang <yangyicong@hisilicon.com >
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-riscv@lists.infradead.org
Link: https://lore.kernel.org/r/20241107162035.52206-7-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-16 16:40:30 -03:00
Ian Rogers
7463ee17a7
perf header: Avoid transitive PMU includes
...
Currently satisfied via header.h. Note, pmu.h includes parse-events.h.
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Xu Yang <xu.yang_2@nxp.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Ben Zong-You Xie <ben717@andestech.com >
Cc: Benjamin Gray <bgray@linux.ibm.com >
Cc: Bibo Mao <maobibo@loongson.cn >
Cc: Clément Le Goffic <clement.legoffic@foss.st.com >
Cc: Dima Kogan <dima@secretsauce.net >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Huacai Chen <chenhuacai@kernel.org >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linux.dev >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sandipan Das <sandipan.das@amd.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yicong Yang <yangyicong@hisilicon.com >
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-riscv@lists.infradead.org
Link: https://lore.kernel.org/r/20241107162035.52206-6-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-16 16:39:59 -03:00
Ian Rogers
538737da96
perf arm64 header: Use cpu argument in get_cpuid
...
Use the cpu to read the MIDR file requested. If the "any" value (-1) is
passed that keep the behavior of returning the first MIDR file that can
be read.
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Xu Yang <xu.yang_2@nxp.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Ben Zong-You Xie <ben717@andestech.com >
Cc: Benjamin Gray <bgray@linux.ibm.com >
Cc: Bibo Mao <maobibo@loongson.cn >
Cc: Clément Le Goffic <clement.legoffic@foss.st.com >
Cc: Dima Kogan <dima@secretsauce.net >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Huacai Chen <chenhuacai@kernel.org >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linux.dev >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sandipan Das <sandipan.das@amd.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yicong Yang <yangyicong@hisilicon.com >
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-riscv@lists.infradead.org
Link: https://lore.kernel.org/r/20241107162035.52206-5-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-16 16:39:04 -03:00
Ian Rogers
cec0d6572a
perf header: Refactor get_cpuid to take a CPU for ARM
...
ARM BIG.little has no notion of a constant CPUID for both core
types. To reflect this reality, change the get_cpuid function to also
pass in a possibly unused logical cpu.
If the dummy value (-1) is passed in then ARM can, as currently happens,
select the first logical CPU's "CPUID".
The changes to ARM getcpuid happen in a follow up change.
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Xu Yang <xu.yang_2@nxp.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Ben Zong-You Xie <ben717@andestech.com >
Cc: Benjamin Gray <bgray@linux.ibm.com >
Cc: Bibo Mao <maobibo@loongson.cn >
Cc: Clément Le Goffic <clement.legoffic@foss.st.com >
Cc: Dima Kogan <dima@secretsauce.net >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Huacai Chen <chenhuacai@kernel.org >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linux.dev >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sandipan Das <sandipan.das@amd.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yicong Yang <yangyicong@hisilicon.com >
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-riscv@lists.infradead.org
Link: https://lore.kernel.org/r/20241107162035.52206-4-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-16 16:37:54 -03:00
Ian Rogers
c6fafe36ba
perf header: Move is_cpu_online to numa bench
...
The helper function is only used in the NUMA benchmark as typically
online CPUs are determined through perf_cpu_map__new_online_cpus().
Reduce the scope of the function for now.
Reviewed-by: James Clark <james.clark@linaro.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Tested-by: Xu Yang <xu.yang_2@nxp.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Alexandre Ghiti <alexghiti@rivosinc.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Ben Zong-You Xie <ben717@andestech.com >
Cc: Benjamin Gray <bgray@linux.ibm.com >
Cc: Bibo Mao <maobibo@loongson.cn >
Cc: Clément Le Goffic <clement.legoffic@foss.st.com >
Cc: Dima Kogan <dima@secretsauce.net >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Huacai Chen <chenhuacai@kernel.org >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Leo Yan <leo.yan@linux.dev >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Ravi Bangoria <ravi.bangoria@amd.com >
Cc: Sandipan Das <sandipan.das@amd.com >
Cc: Will Deacon <will@kernel.org >
Cc: Yicong Yang <yangyicong@hisilicon.com >
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-riscv@lists.infradead.org
Link: https://lore.kernel.org/r/20241107162035.52206-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-16 16:36:47 -03:00
Dr. David Alan Gilbert
264708b8ac
perf util: Remove kernel version deadcode
...
fetch_kernel_version() has been unused since Ian's 2023 commit
3d6dfae889 ("perf parse-events: Remove BPF event support")
Remove it, and it's helpers.
I noticed there are a bunch of kernel-version macros that are also
unused nearby.
Also remove them.
Reviewed-by: Ian Rogers <irogers@google.com >
Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20241116155850.113129-1-linux@treblig.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-16 16:30:39 -03:00
Masami Hiramatsu (Google)
080e47b2a2
perf probe: Introduce quotation marks support
...
In non-C languages, it is possible to have ':' in the function names.
It is possible to escape it with backslashes, but if there are too many
backslashes, it is annoying.
This introduce quotation marks (`"` or `'`) support.
For example, without quotes, we have to pass it as below
$ perf probe -x cro3 -L "cro3\:\:cmd\:\:servo\:\:run_show"
<run_show@/work/cro3/src/cmd/servo.rs:0>
0 fn run_show(args: &ArgsShow) -> Result<()> {
1 let list = ServoList::discover()?;
2 let s = list.find_by_serial(&args.servo)?;
3 if args.json {
4 println!("{s}");
With quotes, we can more naturally write the function name as below;
$ perf probe -x cro3 -L \"cro3::cmd::servo::run_show\"
<run_show@/work/cro3/src/cmd/servo.rs:0>
0 fn run_show(args: &ArgsShow) -> Result<()> {
1 let list = ServoList::discover()?;
2 let s = list.find_by_serial(&args.servo)?;
3 if args.json {
4 println!("{s}");
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Alexander Lobakin <aleksander.lobakin@intel.com >
Cc: Dima Kogan <dima@secretsauce.net >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com >
Link: https://lore.kernel.org/r/173099116941.2431889.11609129616090100386.stgit@mhiramat.roam.corp.google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-14 16:56:32 -03:00
Masami Hiramatsu (Google)
313026f3ce
perf string: Add strpbrk_esq() and strdup_esq() for escape and quote
...
strpbrk_esq() and strdup_esq() are new variants for strpbrk() and
strdup() which handles escaped characters and quoted strings.
- strpbrk_esq() searches specified set of characters but ignores the
escaped characters and quoted strings.
e.g. strpbrk_esq("'quote\d' \queue quiz", "qd") returns "quiz".
- strdup_esq() duplicates string but removes backslash and quotes which
is used for quotation. It also keeps the string (including backslash)
in the quoted part.
e.g. strdup_esq("'quote\d' \queue quiz") returns "quote\d queue quiz".
The (single, double) quotes in the quoted part should be escaped by
backslash. In this case, strdup_esq() removes that backslash.
The same quotes must be paired. If you use double quotation, you need
to use the double quotation to close the quoted part.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Alexander Lobakin <aleksander.lobakin@intel.com >
Cc: Dima Kogan <dima@secretsauce.net >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com >
Link: https://lore.kernel.org/r/173099116045.2431889.15772916605719019533.stgit@mhiramat.roam.corp.google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-14 16:56:32 -03:00
Masami Hiramatsu (Google)
b9e577225c
perf probe: Accept FUNC@* to specify function name explicitly
...
In Golang, the function name will have the '.', and 'perf probe'
misinterprets it as a file name.
To mitigate this situation, introduce `function@*` so that user can
explicitly specify that it is a function name.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Alexander Lobakin <aleksander.lobakin@intel.com >
Cc: Dima Kogan <dima@secretsauce.net >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com >
Link: https://lore.kernel.org/r/173099115149.2431889.13682110856853358354.stgit@mhiramat.roam.corp.google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-14 16:56:32 -03:00
Masami Hiramatsu (Google)
47fa0f99a9
perf probe: Fix to ignore escaped characters in --lines option
...
Use strbprk_esc() and strdup_esc() to ignore escaped characters in
--lines option. This has been done for other options, but only --lines
option doesn't.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Alexander Lobakin <aleksander.lobakin@intel.com >
Cc: Dima Kogan <dima@secretsauce.net >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com >
Link: https://lore.kernel.org/r/173099114272.2431889.4820591557298941207.stgit@mhiramat.roam.corp.google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-14 16:56:32 -03:00
Masami Hiramatsu (Google)
e7c70ee7c9
perf probe: Fix error message for failing to find line range
...
With --lines option, if perf-probe fails to find the specified line, it
warns as "Debuginfo analysis failed." but this misleads user as the
debuginfo is broken.
Fix this message to "Specified source line(LINESPEC) is not found." so
that user can understand the error correctly.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org >
Cc: Alexander Lobakin <aleksander.lobakin@intel.com >
Cc: Dima Kogan <dima@secretsauce.net >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com >
Link: https://lore.kernel.org/r/173099113381.2431889.16263147678401426107.stgit@mhiramat.roam.corp.google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-14 16:56:32 -03:00
Jean-Philippe Romain
d99b312572
perf list: Fix topic and pmu_name argument order
...
Fix function definitions to match header file declaration. Fix two
callers to pass the arguments in the right order.
On Intel Tigerlake, before:
```
$ perf list -j|grep "\"Topic\""|sort|uniq
"Topic": "cache",
"Topic": "cpu",
"Topic": "floating point",
"Topic": "frontend",
"Topic": "memory",
"Topic": "other",
"Topic": "pfm icl",
"Topic": "pfm ix86arch",
"Topic": "pfm perf_raw",
"Topic": "pipeline",
"Topic": "tool",
"Topic": "uncore interconnect",
"Topic": "uncore memory",
"Topic": "uncore other",
"Topic": "virtual memory",
$ perf list -j|grep "\"Unit\""|sort|uniq
"Unit": "cache",
"Unit": "cpu",
"Unit": "cstate_core",
"Unit": "cstate_pkg",
"Unit": "i915",
"Unit": "icl",
"Unit": "intel_bts",
"Unit": "intel_pt",
"Unit": "ix86arch",
"Unit": "msr",
"Unit": "perf_raw",
"Unit": "power",
"Unit": "tool",
"Unit": "uncore_arb",
"Unit": "uncore_clock",
"Unit": "uncore_imc_free_running_0",
"Unit": "uncore_imc_free_running_1",
```
After:
```
$ perf list -j|grep "\"Topic\""|sort|uniq
"Topic": "cache",
"Topic": "floating point",
"Topic": "frontend",
"Topic": "memory",
"Topic": "other",
"Topic": "pfm icl",
"Topic": "pfm ix86arch",
"Topic": "pfm perf_raw",
"Topic": "pipeline",
"Topic": "tool",
"Topic": "uncore interconnect",
"Topic": "uncore memory",
"Topic": "uncore other",
"Topic": "virtual memory",
$ perf list -j|grep "\"Unit\""|sort|uniq
"Unit": "cpu",
"Unit": "cstate_core",
"Unit": "cstate_pkg",
"Unit": "i915",
"Unit": "icl",
"Unit": "intel_bts",
"Unit": "intel_pt",
"Unit": "ix86arch",
"Unit": "msr",
"Unit": "perf_raw",
"Unit": "power",
"Unit": "tool",
"Unit": "uncore_arb",
"Unit": "uncore_clock",
"Unit": "uncore_imc_free_running_0",
"Unit": "uncore_imc_free_running_1",
```
Fixes: e5c6109f48 ("perf list: Reorganize to use callbacks to allow honouring command line options")
Reviewed-by: Kan Liang <kan.liang@linux.intel.com >
Signed-off-by: Jean-Philippe Romain <jean-philippe.romain@foss.st.com >
Tested-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Junhao He <hejunhao3@huawei.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20241109025801.560378-1-irogers@google.com
[ I fixed the two callers and added it to Jean-Phillippe's original change. ]
Signed-off-by: Ian Rogers <irogers@google.com >
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-13 16:27:35 -03:00
Andrew Kreimer
463c203165
perf tools: Fix typos Muliplier -> Multiplier
...
There are some typos in fprintf messages.
Fix them via codespell.
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com >
Signed-off-by: Andrew Kreimer <algonell@gmail.com >
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com >
Cc: Ian Rogers <irogers@google.com >
Cc: Ingo Molnar <mingo@redhat.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Mark Rutland <mark.rutland@arm.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Peter Zijlstra <peterz@infradead.org >
Link: https://lore.kernel.org/r/20241108134728.25515-1-algonell@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-13 16:27:35 -03:00
Arnaldo Carvalho de Melo
a6e8a58de6
perf disasm: Allow configuring what disassemblers to use
...
The perf tools annotation code used for a long time parsing the output
of binutils's objdump (or its reimplementations, like llvm's) to then
parse and augment it with samples, allow navigation, etc.
More recently disassemblers from the capstone and llvm (libraries, not
parsing the output of tools using those libraries to mimic binutils's
objdump output) were introduced.
So when all those methods are available, there is a static preference
for a series of attempts of disassembling a binary, with the 'llvm,
capstone, objdump' sequence being hard coded.
This patch allows users to change that sequence, specifying via a 'perf
config' 'annotate.disassemblers' entry which and in what order
disassemblers should be attempted.
As alluded to in the comments in the source code of this series, this
flexibility is useful for users and developers alike, elliminating the
requirement to rebuild the tool with some specific set of libraries to
see how the output of disassembling would be for one of these methods.
root@x1:~# rm -f ~/.perfconfig
root@x1:~# perf annotate -v --stdio2 update_load_avg
<SNIP>
symbol__disassemble:
filename=/usr/lib/debug/lib/modules/6.11.4-201.fc40.x86_64/vmlinux,
sym=update_load_avg, start=0xffffffffb6148fe0, en>
annotating [0x6ff7170]
/usr/lib/debug/lib/modules/6.11.4-201.fc40.x86_64/vmlinux :
[0x7407ca0] update_load_avg
Disassembled with llvm
annotate.disassemblers=llvm,capstone,objdump
Samples: 66 of event 'cpu_atom/cycles/P', 10000 Hz,
Event count (approx.): 5185444, [percent: local period]
update_load_avg()
/usr/lib/debug/lib/modules/6.11.4-201.fc40.x86_64/vmlinux
Percent 0xffffffff81148fe0 <update_load_avg>:
1.61 pushq %r15
pushq %r14
1.00 pushq %r13
movl %edx,%r13d
1.90 pushq %r12
pushq %rbp
movq %rsi,%rbp
pushq %rbx
movq %rdi,%rbx
subq $0x18,%rsp
15.14 movl 0x1a4(%rdi),%eax
root@x1:~# perf config annotate.disassemblers=capstone
root@x1:~# cat ~/.perfconfig
# this file is auto-generated.
[annotate]
disassemblers = capstone
root@x1:~#
root@x1:~# perf annotate -v --stdio2 update_load_avg
<SNIP>
Disassembled with capstone
annotate.disassemblers=capstone
Samples: 66 of event 'cpu_atom/cycles/P', 10000 Hz,
Event count (approx.): 5185444, [percent: local period]
update_load_avg()
/usr/lib/debug/lib/modules/6.11.4-201.fc40.x86_64/vmlinux
Percent 0xffffffff81148fe0 <update_load_avg>:
1.61 pushq %r15
pushq %r14
1.00 pushq %r13
movl %edx,%r13d
1.90 pushq %r12
pushq %rbp
movq %rsi,%rbp
pushq %rbx
movq %rdi,%rbx
subq $0x18,%rsp
15.14 movl 0x1a4(%rdi),%eax
root@x1:~# perf config annotate.disassemblers=objdump,capstone
root@x1:~# perf config annotate.disassemblers
annotate.disassemblers=objdump,capstone
root@x1:~# cat ~/.perfconfig
# this file is auto-generated.
[annotate]
disassemblers = objdump,capstone
root@x1:~# perf annotate -v --stdio2 update_load_avg
Executing: objdump --start-address=0xffffffff81148fe0 \
--stop-address=0xffffffff811497aa \
-d --no-show-raw-insn -S -C "$1"
Disassembled with objdump
annotate.disassemblers=objdump,capstone
Samples: 66 of event 'cpu_atom/cycles/P', 10000 Hz,
Event count (approx.): 5185444, [percent: local period]
update_load_avg()
/usr/lib/debug/lib/modules/6.11.4-201.fc40.x86_64/vmlinux
Percent
Disassembly of section .text:
ffffffff81148fe0 <update_load_avg>:
#define DO_ATTACH 0x4
ffffffff81148fe0 <update_load_avg>:
#define DO_ATTACH 0x4
#define DO_DETACH 0x8
/* Update task and its cfs_rq load average */
static inline void update_load_avg(struct cfs_rq *cfs_rq,
struct sched_entity *se,
int flags)
{
1.61 push %r15
push %r14
1.00 push %r13
mov %edx,%r13d
1.90 push %r12
push %rbp
mov %rsi,%rbp
push %rbx
mov %rdi,%rbx
sub $0x18,%rsp
}
/* rq->task_clock normalized against any time
this cfs_rq has spent throttled */
static inline u64 cfs_rq_clock_pelt(struct cfs_rq *cfs_rq)
{
if (unlikely(cfs_rq->throttle_count))
15.14 mov 0x1a4(%rdi),%eax
root@x1:~#
After adding a way to select the disassembler from the command line a
'perf test' comparing the output of the various diassemblers should be
introduced, to test these codebases.
Acked-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Steinar H. Gunderson <sesse@google.com >
Link: https://lore.kernel.org/r/20241111151734.1018476-4-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-13 16:27:35 -03:00
Arnaldo Carvalho de Melo
1f7393adf6
perf disasm: Define stubs for the LLVM and capstone disassemblers
...
This reduces the number of ifdefs in the main symbol__disassemble()
method and paves the way for allowing the user to configure the
disassemblers of preference.
Acked-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Aditya Bodkhe <Aditya.Bodkhe1@ibm.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Steinar H. Gunderson <sesse@google.com >
Link: https://lore.kernel.org/r/20241111151734.1018476-3-acme@kernel.org
[ Applied fixes from Masami Hiramatsu and Aditya Bodkhe for when capstone devel files are not available ]
Link: https://lore.kernel.org/r/B78FB6DF-24E9-4A3C-91C9-535765EC0E2A@ibm.com
Link: https://lore.kernel.org/r/173145729034.2747044.453926054000880254.stgit@mhiramat.roam.corp.google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-13 16:20:32 -03:00
Arnaldo Carvalho de Melo
4c1d8f0547
perf disasm: Introduce symbol__disassemble_objdump()
...
With the first disassemble method in perf, the parsing of objdump
output, just like we have for llvm and capstone.
This paves the way to allow the user to specify what disassemblers are
preferred and to also to at some point allow building without the
objdump method.
Acked-by: Ian Rogers <irogers@google.com >
Cc: Adrian Hunter <adrian.hunter@intel.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: Jiri Olsa <jolsa@kernel.org >
Cc: Kan Liang <kan.liang@linux.intel.com >
Cc: Namhyung Kim <namhyung@kernel.org >
Cc: Steinar H. Gunderson <sesse@google.com >
Link: https://lore.kernel.org/r/20241111151734.1018476-2-acme@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com >
2024-11-11 14:26:37 -03:00
Ian Rogers
3ef6b89a12
perf dwarf-regs: Remove get_arch_regstr code
...
get_arch_regstr no longer exists so remove declaration. Associated ifs
and switches are made unconditional.
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org >
Signed-off-by: Ian Rogers <irogers@google.com >
Cc: Anup Patel <anup@brainfault.org >
Cc: Yang Jihong <yangjihong@bytedance.com >
Cc: Palmer Dabbelt <palmer@dabbelt.com >
Cc: David S. Miller <davem@davemloft.net >
Cc: Albert Ou <aou@eecs.berkeley.edu >
Cc: Shenlin Liang <liangshenlin@eswincomputing.com >
Cc: Nick Terrell <terrelln@fb.com >
Cc: Guilherme Amadio <amadio@gentoo.org >
Cc: Steinar H. Gunderson <sesse@google.com >
Cc: Changbin Du <changbin.du@huawei.com >
Cc: Alexander Lobakin <aleksander.lobakin@intel.com >
Cc: Przemek Kitszel <przemyslaw.kitszel@intel.com >
Cc: Huacai Chen <chenhuacai@kernel.org >
Cc: Guo Ren <guoren@kernel.org >
Cc: Masahiro Yamada <masahiroy@kernel.org >
Cc: Will Deacon <will@kernel.org >
Cc: James Clark <james.clark@linaro.org >
Cc: Mike Leach <mike.leach@linaro.org >
Cc: Chen Pei <cp0613@linux.alibaba.com >
Cc: Leo Yan <leo.yan@linux.dev >
Cc: Oliver Upton <oliver.upton@linux.dev >
Cc: Aditya Gupta <adityag@linux.ibm.com >
Cc: Kajol Jain <kjain@linux.ibm.com >
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com >
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-riscv@lists.infradead.org
Cc: Bibo Mao <maobibo@loongson.cn >
Cc: John Garry <john.g.garry@oracle.com >
Cc: Atish Patra <atishp@rivosinc.com >
Cc: Dima Kogan <dima@secretsauce.net >
Cc: Paul Walmsley <paul.walmsley@sifive.com >
Cc: Dr. David Alan Gilbert <linux@treblig.org >
Cc: linux-csky@vger.kernel.org
Link: https://lore.kernel.org/r/20241108234606.429459-20-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org >
2024-11-09 08:39:14 -08:00