License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 07:07:57 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2012-03-15 12:09:17 -07:00
|
|
|
#ifndef __PMU_H
|
|
|
|
#define __PMU_H
|
|
|
|
|
2014-04-25 12:31:02 -07:00
|
|
|
#include <linux/bitmap.h>
|
2017-06-16 07:57:54 -07:00
|
|
|
#include <linux/compiler.h>
|
2012-11-19 15:21:03 -07:00
|
|
|
#include <linux/perf_event.h>
|
2021-04-27 00:01:18 -07:00
|
|
|
#include <linux/list.h>
|
2013-04-20 11:02:29 -07:00
|
|
|
#include <stdbool.h>
|
2023-01-20 07:36:55 -07:00
|
|
|
#include <stdio.h>
|
perf tools: Add term support for parse_events_error
Allowing event's term processing to report back error, like:
$ perf record -e 'cpu/even=0x1/' ls
event syntax error: 'cpu/even=0x1/'
\___ unknown term
valid terms: pc,any,inv,edge,cmask,event,in_tx,ldlat,umask,in_tx_cp,offcore_rsp,config,config1,config2,name,period,branch_type
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1429729824-13932-7-git-send-email-jolsa@kernel.org
[ Renamed 'error' variables to 'err', not to clash with util.h error() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-22 12:10:21 -07:00
|
|
|
#include "parse-events.h"
|
2020-03-17 04:02:15 -07:00
|
|
|
#include "pmu-events/pmu-events.h"
|
2024-01-23 11:50:30 -07:00
|
|
|
#include "map_symbol.h"
|
|
|
|
#include "mem-events.h"
|
2012-03-15 12:09:17 -07:00
|
|
|
|
2020-05-06 09:05:08 -07:00
|
|
|
struct evsel_config_term;
|
perf tools: Enable on a list of CPUs for hybrid
The 'perf record' and 'perf stat' commands have supported the option
'-C/--cpus' to count or collect only on the list of CPUs provided. This
option needs to be supported for hybrid as well.
For hybrid support, it needs to check that the cpu list are available
on hybrid PMU. One example for AlderLake, cpu0-7 is 'cpu_core', cpu8-11
is 'cpu_atom'.
Before:
# perf stat -e cpu_core/cycles/ -C11 -- sleep 1
Performance counter stats for 'CPU(s) 11':
<not supported> cpu_core/cycles/
1.006179431 seconds time elapsed
The 'perf stat' command silently returned "<not supported>" without any
helpful information. It should error out pointing out that that cpu11
was not 'cpu_core'.
After:
# perf stat -e cpu_core/cycles/ -C11 -- sleep 1
WARNING: 11 isn't a 'cpu_core', please use a CPU list in the 'cpu_core' range (0-7)
failed to use cpu list 11
We also need to support the events without pmu prefix specified.
# perf stat -e cycles -C11 -- sleep 1
WARNING: 11 isn't a 'cpu_core', please use a CPU list in the 'cpu_core' range (0-7)
Performance counter stats for 'CPU(s) 11':
1,067,373 cpu_atom/cycles/
1.005544738 seconds time elapsed
The perf tool creates two cycles events automatically, cpu_core/cycles/ and
cpu_atom/cycles/. It checks that cpu11 is not 'cpu_core', then shows a warning
for cpu_core/cycles/ and only count the cpu_atom/cycles/.
If part of cpus are 'cpu_core' and part of cpus are 'cpu_atom', for example,
# perf stat -e cycles -C0,11 -- sleep 1
WARNING: use 0 in 'cpu_core' for 'cycles', skip other cpus in list.
WARNING: use 11 in 'cpu_atom' for 'cycles', skip other cpus in list.
Performance counter stats for 'CPU(s) 0,11':
1,914,704 cpu_core/cycles/
2,036,983 cpu_atom/cycles/
1.005815641 seconds time elapsed
It now automatically selects cpu0 for cpu_core/cycles/, selects cpu11 for
cpu_atom/cycles/, and output with some warnings.
Some more complex examples,
# perf stat -e cycles,instructions -C0,11 -- sleep 1
WARNING: use 0 in 'cpu_core' for 'cycles', skip other cpus in list.
WARNING: use 11 in 'cpu_atom' for 'cycles', skip other cpus in list.
WARNING: use 0 in 'cpu_core' for 'instructions', skip other cpus in list.
WARNING: use 11 in 'cpu_atom' for 'instructions', skip other cpus in list.
Performance counter stats for 'CPU(s) 0,11':
2,780,387 cpu_core/cycles/
1,583,432 cpu_atom/cycles/
3,957,277 cpu_core/instructions/
1,167,089 cpu_atom/instructions/
1.006005124 seconds time elapsed
# perf stat -e cycles,cpu_atom/instructions/ -C0,11 -- sleep 1
WARNING: use 0 in 'cpu_core' for 'cycles', skip other cpus in list.
WARNING: use 11 in 'cpu_atom' for 'cycles', skip other cpus in list.
WARNING: use 11 in 'cpu_atom' for 'cpu_atom/instructions/', skip other cpus in list.
Performance counter stats for 'CPU(s) 0,11':
3,290,301 cpu_core/cycles/
1,953,073 cpu_atom/cycles/
1,407,869 cpu_atom/instructions/
1.006260912 seconds time elapsed
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jin Yao <yao.jin@intel.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https //lore.kernel.org/r/20210723063433.7318-4-yao.jin@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-07-22 23:34:33 -07:00
|
|
|
struct perf_cpu_map;
|
perf list: Reorganize to use callbacks to allow honouring command line options
Rather than controlling the list output with passed flags, add
callbacks that are called when an event or metric are
encountered. State is passed to the callback so that command line
options can be respected, alternatively the callbacks can be changed.
Fix a few bugs:
- wordwrap to columns metric descriptions and expressions;
- remove unnecessary whitespace after PMU event names;
- the metric filter is a glob but matched using strstr which will
always fail, switch to using a proper globmatch,
- the detail flag gives details for extra kernel PMU events like
branch-instructions.
In metricgroup.c switch from struct mep being a rbtree of metricgroups
containing a list of metrics, to the tree directly containing all the
metrics. In general the alias for a name is passed to the print
routine rather than being contained in the name with OR.
Committer notes:
Check the asprint() return to address this on fedora 36:
util/print-events.c: In function ‘print_sdt_events’:
util/print-events.c:183:33: error: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ [-Werror=unused-result]
183 | asprintf(&evt_name, "%s@%s(%.12s)", sdt_name->s, path, bid);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
$ gcc --version | head -1
gcc (GCC) 12.2.1 20220819 (Red Hat 12.2.1-2)
$
Fix ps.pmu_glob setting when dealing with *:* events, it was being left
with a freed pointer that then at the end of cmd_list() would be double
freed.
Check if pmu_name is NULL in default_print_event() before calling
strglobmatch(pmu_name, ...) to avoid a segfault.
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Weilin Wang <weilin.wang@intel.com>
Cc: Xin Gao <gaoxin@cdjrlc.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: http://lore.kernel.org/lkml/20221114210723.2749751-10-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-11-14 14:07:22 -07:00
|
|
|
struct print_callbacks;
|
2019-01-29 04:24:52 -07:00
|
|
|
|
2012-03-15 12:09:17 -07:00
|
|
|
enum {
|
|
|
|
PERF_PMU_FORMAT_VALUE_CONFIG,
|
|
|
|
PERF_PMU_FORMAT_VALUE_CONFIG1,
|
|
|
|
PERF_PMU_FORMAT_VALUE_CONFIG2,
|
2023-02-17 15:32:11 -07:00
|
|
|
PERF_PMU_FORMAT_VALUE_CONFIG3,
|
2022-10-04 12:12:35 -07:00
|
|
|
PERF_PMU_FORMAT_VALUE_CONFIG_END,
|
2012-03-15 12:09:17 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define PERF_PMU_FORMAT_BITS 64
|
perf pmu: Add PMU alias support
A perf uncore PMU may have two PMU names, a real name and an alias. The
alias is exported at /sys/bus/event_source/devices/uncore_*/alias.
The perf tool should support the alias as well.
Add alias_name in the struct perf_pmu to store the alias. For the PMU
which doesn't have an alias. It's NULL.
Introduce two X86 specific functions to retrieve the real name and the
alias separately.
Only go through the sysfs to retrieve the mapping between the real name
and the alias once. The result is cached in a list, uncore_pmu_list.
Nothing changed for the other ARCHs.
With the patch, the perf tool can monitor the PMU with either the real
name or the alias.
Use the real name,
$ perf stat -e uncore_cha_2/event=1/ -x,
4044879584,,uncore_cha_2/event=1/,2528059205,100.00,,
Use the alias,
$ perf stat -e uncore_type_0_2/event=1/ -x,
3659675336,,uncore_type_0_2/event=1/,2287306455,100.00,,
Committer notes:
Rename 'struct perf_pmu_alias_name' to 'pmu_alias', the 'perf_' prefix
should be used for libperf, things inside just tools/perf/ are being
moved away from that prefix.
Also 'pmu_alias' is shorter and reflects the abstraction.
Also don't use 'pmu' as the name for variables for that type, we should
use that for the 'struct perf_pmu' variables, avoiding confusion. Use
'pmu_alias' for 'struct pmu_alias' variables.
Co-developed-by: Jin Yao <yao.jin@linux.intel.com>
Co-developed-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.garry@huawei.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Link: http://lore.kernel.org/lkml/20210902065955.1299-2-yao.jin@linux.intel.com
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-09-01 23:59:54 -07:00
|
|
|
#define MAX_PMU_NAME_LEN 128
|
2012-03-15 12:09:17 -07:00
|
|
|
|
2014-07-30 23:00:49 -07:00
|
|
|
struct perf_event_attr;
|
|
|
|
|
2020-03-19 13:25:01 -07:00
|
|
|
struct perf_pmu_caps {
|
|
|
|
char *name;
|
|
|
|
char *value;
|
|
|
|
struct list_head list;
|
|
|
|
};
|
|
|
|
|
2024-09-06 22:08:17 -07:00
|
|
|
enum {
|
|
|
|
PERF_PMU_TYPE_FAKE = 0xFFFFFFFF,
|
|
|
|
};
|
|
|
|
|
2022-11-14 14:07:15 -07:00
|
|
|
/**
|
2023-04-06 16:52:55 -07:00
|
|
|
* struct perf_pmu
|
2022-11-14 14:07:15 -07:00
|
|
|
*/
|
2012-03-15 12:09:17 -07:00
|
|
|
struct perf_pmu {
|
2022-11-14 14:07:15 -07:00
|
|
|
/** @name: The name of the PMU such as "cpu". */
|
2023-08-24 19:39:58 -07:00
|
|
|
const char *name;
|
2022-11-14 14:07:15 -07:00
|
|
|
/**
|
|
|
|
* @alias_name: Optional alternate name for the PMU determined in
|
|
|
|
* architecture specific code.
|
|
|
|
*/
|
perf pmu: Add PMU alias support
A perf uncore PMU may have two PMU names, a real name and an alias. The
alias is exported at /sys/bus/event_source/devices/uncore_*/alias.
The perf tool should support the alias as well.
Add alias_name in the struct perf_pmu to store the alias. For the PMU
which doesn't have an alias. It's NULL.
Introduce two X86 specific functions to retrieve the real name and the
alias separately.
Only go through the sysfs to retrieve the mapping between the real name
and the alias once. The result is cached in a list, uncore_pmu_list.
Nothing changed for the other ARCHs.
With the patch, the perf tool can monitor the PMU with either the real
name or the alias.
Use the real name,
$ perf stat -e uncore_cha_2/event=1/ -x,
4044879584,,uncore_cha_2/event=1/,2528059205,100.00,,
Use the alias,
$ perf stat -e uncore_type_0_2/event=1/ -x,
3659675336,,uncore_type_0_2/event=1/,2287306455,100.00,,
Committer notes:
Rename 'struct perf_pmu_alias_name' to 'pmu_alias', the 'perf_' prefix
should be used for libperf, things inside just tools/perf/ are being
moved away from that prefix.
Also 'pmu_alias' is shorter and reflects the abstraction.
Also don't use 'pmu' as the name for variables for that type, we should
use that for the 'struct perf_pmu' variables, avoiding confusion. Use
'pmu_alias' for 'struct pmu_alias' variables.
Co-developed-by: Jin Yao <yao.jin@linux.intel.com>
Co-developed-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.garry@huawei.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Link: http://lore.kernel.org/lkml/20210902065955.1299-2-yao.jin@linux.intel.com
Signed-off-by: Jin Yao <yao.jin@linux.intel.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-09-01 23:59:54 -07:00
|
|
|
char *alias_name;
|
2022-11-14 14:07:15 -07:00
|
|
|
/**
|
|
|
|
* @id: Optional PMU identifier read from
|
|
|
|
* <sysfs>/bus/event_source/devices/<name>/identifier.
|
|
|
|
*/
|
2023-08-24 19:40:00 -07:00
|
|
|
const char *id;
|
2022-11-14 14:07:15 -07:00
|
|
|
/**
|
|
|
|
* @type: Perf event attributed type value, read from
|
|
|
|
* <sysfs>/bus/event_source/devices/<name>/type.
|
|
|
|
*/
|
2012-03-15 12:09:17 -07:00
|
|
|
__u32 type;
|
2022-11-14 14:07:15 -07:00
|
|
|
/**
|
|
|
|
* @selectable: Can the PMU name be selected as if it were an event?
|
|
|
|
*/
|
2014-10-23 03:45:10 -07:00
|
|
|
bool selectable;
|
2023-05-27 00:21:41 -07:00
|
|
|
/**
|
|
|
|
* @is_core: Is the PMU the core CPU PMU? Determined by the name being
|
|
|
|
* "cpu" or by the presence of
|
|
|
|
* <sysfs>/bus/event_source/devices/<name>/cpus. There may be >1 core
|
|
|
|
* PMU on systems like Intel hybrid.
|
|
|
|
*/
|
|
|
|
bool is_core;
|
2022-11-14 14:07:15 -07:00
|
|
|
/**
|
|
|
|
* @is_uncore: Is the PMU not within the CPU core? Determined by the
|
|
|
|
* presence of <sysfs>/bus/event_source/devices/<name>/cpumask.
|
|
|
|
*/
|
perf pmu: Unbreak perf record for arm/arm64 with events with explicit PMU
Currently, perf record is broken on arm/arm64 systems when the PMU is
specified explicitly as part of the event, e.g.
$ ./perf record -e armv8_cortex_a53/cpu_cycles/u true
In such cases, perf record fails to open events unless
perf_event_paranoid is set to -1, even if the PMU in question supports
mode exclusion. Further, even when perf_event_paranoid is toggled, no
samples are recorded.
This is an unintended side effect of commit:
e3ba76deef23064f ("perf tools: Force uncore events to system wide monitoring)
... which assumes that if a PMU has an associated cpu_map, it is an
uncore PMU, and forces events for such PMUs to be system-wide.
This is not true for arm/arm64 systems, which can have heterogeneous
CPUs. To account for this, multiple CPU PMUs are exposed, each with a
"cpus" field under sysfs, which the perf tool parses into a cpu_map. ARM
PMUs do not have a "cpumask" file, and only have a "cpus" file. For the
gory details as to why, see commit:
7e3fcffe95544010 ("perf pmu: Support alternative sysfs cpumask")
Given all of this, we can instead identify uncore PMUs by explicitly
checking for a "cpumask" file, and restore arm/arm64 PMU support back to
a working state. This patch does so, adding a new perf_pmu::is_uncore
field, and splitting the existing cpumask parsing so that it can be
reused.
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Tested-by Will Deacon <will.deacon@arm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: 4.12+ <stable@vger.kernel.org>
Fixes: e3ba76deef23064f ("perf tools: Force uncore events to system wide monitoring)
Link: http://lkml.kernel.org/r/1507315102-5942-1-git-send-email-mark.rutland@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-10-06 11:38:22 -07:00
|
|
|
bool is_uncore;
|
2022-11-14 14:07:15 -07:00
|
|
|
/**
|
|
|
|
* @auxtrace: Are events auxiliary events? Determined in architecture
|
|
|
|
* specific code.
|
|
|
|
*/
|
2019-11-15 05:42:15 -07:00
|
|
|
bool auxtrace;
|
2023-05-31 19:36:43 -07:00
|
|
|
/**
|
|
|
|
* @formats_checked: Only check PMU's formats are valid for
|
|
|
|
* perf_event_attr once.
|
|
|
|
*/
|
|
|
|
bool formats_checked;
|
2023-05-31 19:36:44 -07:00
|
|
|
/** @config_masks_present: Are there config format values? */
|
|
|
|
bool config_masks_present;
|
|
|
|
/** @config_masks_computed: Set when masks are lazily computed. */
|
|
|
|
bool config_masks_computed;
|
2022-11-14 14:07:15 -07:00
|
|
|
/**
|
|
|
|
* @max_precise: Number of levels of :ppp precision supported by the
|
|
|
|
* PMU, read from
|
|
|
|
* <sysfs>/bus/event_source/devices/<name>/caps/max_precise.
|
|
|
|
*/
|
2019-03-05 08:25:32 -07:00
|
|
|
int max_precise;
|
2022-11-14 14:07:15 -07:00
|
|
|
/**
|
2023-10-12 10:56:45 -07:00
|
|
|
* @perf_event_attr_init_default: Optional function to default
|
|
|
|
* initialize PMU specific parts of the perf_event_attr.
|
2022-11-14 14:07:15 -07:00
|
|
|
*/
|
2023-10-12 10:56:45 -07:00
|
|
|
void (*perf_event_attr_init_default)(const struct perf_pmu *pmu,
|
|
|
|
struct perf_event_attr *attr);
|
2022-11-14 14:07:15 -07:00
|
|
|
/**
|
|
|
|
* @cpus: Empty or the contents of either of:
|
|
|
|
* <sysfs>/bus/event_source/devices/<name>/cpumask.
|
|
|
|
* <sysfs>/bus/event_source/devices/<cpu>/cpus.
|
|
|
|
*/
|
2019-07-21 04:23:49 -07:00
|
|
|
struct perf_cpu_map *cpus;
|
2022-11-14 14:07:15 -07:00
|
|
|
/**
|
|
|
|
* @format: Holds the contents of files read from
|
|
|
|
* <sysfs>/bus/event_source/devices/<name>/format/. The contents specify
|
|
|
|
* which event parameter changes what config, config1 or config2 bits.
|
|
|
|
*/
|
|
|
|
struct list_head format;
|
|
|
|
/**
|
|
|
|
* @aliases: List of struct perf_pmu_alias. Each alias corresponds to an
|
|
|
|
* event read from <sysfs>/bus/event_source/devices/<name>/events/ or
|
|
|
|
* from json events in pmu-events.c.
|
|
|
|
*/
|
|
|
|
struct list_head aliases;
|
2023-08-23 21:13:24 -07:00
|
|
|
/**
|
|
|
|
* @events_table: The events table for json events in pmu-events.c.
|
|
|
|
*/
|
|
|
|
const struct pmu_events_table *events_table;
|
2023-08-23 21:13:25 -07:00
|
|
|
/** @sysfs_aliases: Number of sysfs aliases loaded. */
|
|
|
|
uint32_t sysfs_aliases;
|
2024-05-10 17:36:01 -07:00
|
|
|
/** @cpu_json_aliases: Number of json event aliases loaded specific to the CPUID. */
|
|
|
|
uint32_t cpu_json_aliases;
|
|
|
|
/** @sys_json_aliases: Number of json event aliases loaded matching the PMU's identifier. */
|
|
|
|
uint32_t sys_json_aliases;
|
2023-08-23 21:13:28 -07:00
|
|
|
/** @sysfs_aliases_loaded: Are sysfs aliases loaded from disk? */
|
|
|
|
bool sysfs_aliases_loaded;
|
2023-08-23 21:13:25 -07:00
|
|
|
/**
|
|
|
|
* @cpu_aliases_added: Have all json events table entries for the PMU
|
|
|
|
* been added?
|
|
|
|
*/
|
|
|
|
bool cpu_aliases_added;
|
2022-11-14 14:07:15 -07:00
|
|
|
/** @caps_initialized: Has the list caps been initialized? */
|
2022-06-03 21:45:13 -07:00
|
|
|
bool caps_initialized;
|
2022-11-14 14:07:15 -07:00
|
|
|
/** @nr_caps: The length of the list caps. */
|
2022-06-03 21:45:13 -07:00
|
|
|
u32 nr_caps;
|
2022-11-14 14:07:15 -07:00
|
|
|
/**
|
|
|
|
* @caps: Holds the contents of files read from
|
|
|
|
* <sysfs>/bus/event_source/devices/<name>/caps/.
|
|
|
|
*
|
|
|
|
* The contents are pairs of the filename with the value of its
|
|
|
|
* contents, for example, max_precise (see above) may have a value of 3.
|
|
|
|
*/
|
|
|
|
struct list_head caps;
|
|
|
|
/** @list: Element on pmus list in pmu.c. */
|
|
|
|
struct list_head list;
|
perf evsel: Fix missing exclude_{host,guest} setting
The current logic for the perf missing feature has a bug that it can
wrongly clear some modifiers like G or H. Actually some PMUs don't
support any filtering or exclusion while others do. But we check it as
a global feature.
For example, the cycles event can have 'G' modifier to enable it only in
the guest mode on x86. When you don't run any VMs it'll return 0.
# perf stat -a -e cycles:G sleep 1
Performance counter stats for 'system wide':
0 cycles:G
1.000721670 seconds time elapsed
But when it's used with other pmu events that don't support G modifier,
it'll be reset and return non-zero values.
# perf stat -a -e cycles:G,msr/tsc/ sleep 1
Performance counter stats for 'system wide':
538,029,960 cycles:G
16,924,010,738 msr/tsc/
1.001815327 seconds time elapsed
This is because of the missing feature detection logic being global.
Add a hashmap to set pmu-specific exclude_host/guest features.
Committer notes:
Fix 'perf test python' by adding a stub for evsel__find_pmu() in
tools/perf/util/python.c, document that it is used so far only for the
above reasons so that if anybody needs this in the python binding
usecases, we can revisit this.
Reported-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Link: http://lore.kernel.org/lkml/20211105205847.120950-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-11-05 13:58:47 -07:00
|
|
|
|
2023-05-31 19:36:44 -07:00
|
|
|
/**
|
|
|
|
* @config_masks: Derived from the PMU's format data, bits that are
|
|
|
|
* valid within the config value.
|
|
|
|
*/
|
|
|
|
__u64 config_masks[PERF_PMU_FORMAT_VALUE_CONFIG_END];
|
|
|
|
|
2022-11-14 14:07:15 -07:00
|
|
|
/**
|
|
|
|
* @missing_features: Features to inhibit when events on this PMU are
|
|
|
|
* opened.
|
|
|
|
*/
|
perf evsel: Fix missing exclude_{host,guest} setting
The current logic for the perf missing feature has a bug that it can
wrongly clear some modifiers like G or H. Actually some PMUs don't
support any filtering or exclusion while others do. But we check it as
a global feature.
For example, the cycles event can have 'G' modifier to enable it only in
the guest mode on x86. When you don't run any VMs it'll return 0.
# perf stat -a -e cycles:G sleep 1
Performance counter stats for 'system wide':
0 cycles:G
1.000721670 seconds time elapsed
But when it's used with other pmu events that don't support G modifier,
it'll be reset and return non-zero values.
# perf stat -a -e cycles:G,msr/tsc/ sleep 1
Performance counter stats for 'system wide':
538,029,960 cycles:G
16,924,010,738 msr/tsc/
1.001815327 seconds time elapsed
This is because of the missing feature detection logic being global.
Add a hashmap to set pmu-specific exclude_host/guest features.
Committer notes:
Fix 'perf test python' by adding a stub for evsel__find_pmu() in
tools/perf/util/python.c, document that it is used so far only for the
above reasons so that if anybody needs this in the python binding
usecases, we can revisit this.
Reported-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Link: http://lore.kernel.org/lkml/20211105205847.120950-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-11-05 13:58:47 -07:00
|
|
|
struct {
|
2022-11-14 14:07:15 -07:00
|
|
|
/**
|
|
|
|
* @exclude_guest: Disables perf_event_attr exclude_guest and
|
|
|
|
* exclude_host.
|
|
|
|
*/
|
perf evsel: Fix missing exclude_{host,guest} setting
The current logic for the perf missing feature has a bug that it can
wrongly clear some modifiers like G or H. Actually some PMUs don't
support any filtering or exclusion while others do. But we check it as
a global feature.
For example, the cycles event can have 'G' modifier to enable it only in
the guest mode on x86. When you don't run any VMs it'll return 0.
# perf stat -a -e cycles:G sleep 1
Performance counter stats for 'system wide':
0 cycles:G
1.000721670 seconds time elapsed
But when it's used with other pmu events that don't support G modifier,
it'll be reset and return non-zero values.
# perf stat -a -e cycles:G,msr/tsc/ sleep 1
Performance counter stats for 'system wide':
538,029,960 cycles:G
16,924,010,738 msr/tsc/
1.001815327 seconds time elapsed
This is because of the missing feature detection logic being global.
Add a hashmap to set pmu-specific exclude_host/guest features.
Committer notes:
Fix 'perf test python' by adding a stub for evsel__find_pmu() in
tools/perf/util/python.c, document that it is used so far only for the
above reasons so that if anybody needs this in the python binding
usecases, we can revisit this.
Reported-by: Stephane Eranian <eranian@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Link: http://lore.kernel.org/lkml/20211105205847.120950-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2021-11-05 13:58:47 -07:00
|
|
|
bool exclude_guest;
|
|
|
|
} missing_features;
|
2024-01-23 11:50:30 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @mem_events: List of the supported mem events
|
|
|
|
*/
|
|
|
|
struct perf_mem_event *mem_events;
|
2012-03-15 12:09:17 -07:00
|
|
|
};
|
|
|
|
|
2014-09-24 07:04:06 -07:00
|
|
|
struct perf_pmu_info {
|
|
|
|
const char *unit;
|
|
|
|
double scale;
|
2014-11-21 02:31:12 -07:00
|
|
|
bool per_pkg;
|
2014-11-21 02:31:13 -07:00
|
|
|
bool snapshot;
|
2014-09-24 07:04:06 -07:00
|
|
|
};
|
|
|
|
|
2023-08-23 21:13:14 -07:00
|
|
|
struct pmu_event_info {
|
|
|
|
const struct perf_pmu *pmu;
|
|
|
|
const char *name;
|
|
|
|
const char* alias;
|
|
|
|
const char *scale_unit;
|
|
|
|
const char *desc;
|
|
|
|
const char *long_desc;
|
|
|
|
const char *encoding_desc;
|
|
|
|
const char *topic;
|
|
|
|
const char *pmu_name;
|
2024-09-06 22:08:19 -07:00
|
|
|
const char *event_type_desc;
|
2023-08-23 21:13:14 -07:00
|
|
|
const char *str;
|
2019-10-14 19:53:57 -07:00
|
|
|
bool deprecated;
|
2014-10-07 08:08:50 -07:00
|
|
|
};
|
|
|
|
|
2023-08-23 21:13:14 -07:00
|
|
|
typedef int (*pmu_event_callback)(void *state, struct pmu_event_info *info);
|
perf list: Give more details about raw event encodings
List all the PMUs, not just the first core one, and list real format
specifiers with value ranges.
Before:
$ perf list
...
rNNN [Raw hardware event descriptor]
cpu/t1=v1[,t2=v2,t3 ...]/modifier [Raw hardware event descriptor]
[(see 'man perf-list' on how to encode it)]
mem:<addr>[/len][:access] [Hardware breakpoint]
...
After:
$ perf list
...
rNNN [Raw event descriptor]
cpu/event=0..255,pc,edge,.../modifier [Raw event descriptor]
[(see 'man perf-list' or 'man perf-record' on how to encode it)]
breakpoint//modifier [Raw event descriptor]
cstate_core/event=0..0xffffffffffffffff/modifier [Raw event descriptor]
cstate_pkg/event=0..0xffffffffffffffff/modifier [Raw event descriptor]
i915/i915_eventid=0..0x1fffff/modifier [Raw event descriptor]
intel_bts//modifier [Raw event descriptor]
intel_pt/ptw,event,cyc_thresh=0..15,.../modifier [Raw event descriptor]
kprobe/retprobe/modifier [Raw event descriptor]
msr/event=0..0xffffffffffffffff/modifier [Raw event descriptor]
power/event=0..255/modifier [Raw event descriptor]
software//modifier [Raw event descriptor]
tracepoint//modifier [Raw event descriptor]
uncore_arb/event=0..255,edge,inv,.../modifier [Raw event descriptor]
uncore_cbox/event=0..255,edge,inv,.../modifier [Raw event descriptor]
uncore_clock/event=0..255/modifier [Raw event descriptor]
uncore_imc_free_running/event=0..255,umask=0..255/modifier[Raw event descriptor]
uprobe/ref_ctr_offset=0..0xffffffff,retprobe/modifier[Raw event descriptor]
mem:<addr>[/len][:access] [Hardware breakpoint]
...
With '--details' provide more details on the formats encoding:
cpu/event=0..255,pc,edge,.../modifier [Raw event descriptor]
[(see 'man perf-list' or 'man perf-record' on how to encode it)]
cpu/event=0..255,pc,edge,offcore_rsp=0..0xffffffffffffffff,ldlat=0..0xffff,inv,
umask=0..255,frontend=0..0xffffff,cmask=0..255,config=0..0xffffffffffffffff,
config1=0..0xffffffffffffffff,config2=0..0xffffffffffffffff,config3=0..0xffffffffffffffff,
name=string,period=number,freq=number,branch_type=(u|k|hv|any|...),time,
call-graph=(fp|dwarf|lbr),stack-size=number,max-stack=number,nr=number,inherit,no-inherit,
overwrite,no-overwrite,percore,aux-output,aux-sample-size=number/modifier
breakpoint//modifier [Raw event descriptor]
breakpoint//modifier
cstate_core/event=0..0xffffffffffffffff/modifier [Raw event descriptor]
cstate_core/event=0..0xffffffffffffffff/modifier
cstate_pkg/event=0..0xffffffffffffffff/modifier [Raw event descriptor]
cstate_pkg/event=0..0xffffffffffffffff/modifier
i915/i915_eventid=0..0x1fffff/modifier [Raw event descriptor]
i915/i915_eventid=0..0x1fffff/modifier
intel_bts//modifier [Raw event descriptor]
intel_bts//modifier
intel_pt/ptw,event,cyc_thresh=0..15,.../modifier [Raw event descriptor]
intel_pt/ptw,event,cyc_thresh=0..15,pt,notnt,branch,tsc,pwr_evt,fup_on_ptw,cyc,noretcomp,
mtc,psb_period=0..15,mtc_period=0..15/modifier
kprobe/retprobe/modifier [Raw event descriptor]
kprobe/retprobe/modifier
msr/event=0..0xffffffffffffffff/modifier [Raw event descriptor]
msr/event=0..0xffffffffffffffff/modifier
power/event=0..255/modifier [Raw event descriptor]
power/event=0..255/modifier
software//modifier [Raw event descriptor]
software//modifier
tracepoint//modifier [Raw event descriptor]
tracepoint//modifier
uncore_arb/event=0..255,edge,inv,.../modifier [Raw event descriptor]
uncore_arb/event=0..255,edge,inv,umask=0..255,cmask=0..31/modifier
uncore_cbox/event=0..255,edge,inv,.../modifier [Raw event descriptor]
uncore_cbox/event=0..255,edge,inv,umask=0..255,cmask=0..31/modifier
uncore_clock/event=0..255/modifier [Raw event descriptor]
uncore_clock/event=0..255/modifier
uncore_imc_free_running/event=0..255,umask=0..255/modifier[Raw event descriptor]
uncore_imc_free_running/event=0..255,umask=0..255/modifier
uprobe/ref_ctr_offset=0..0xffffffff,retprobe/modifier[Raw event descriptor]
uprobe/ref_ctr_offset=0..0xffffffff,retprobe/modifier
Committer notes:
Address this build error in various distros:
55 58.44 ubuntu:24.04 : FAIL gcc version 13.2.0 (Ubuntu 13.2.0-17ubuntu2)
util/pmu.c:1638:70: error: '_Static_assert' with no message is a C2x extension [-Werror,-Wc2x-extensions]
1638 | _Static_assert(ARRAY_SIZE(terms) == __PARSE_EVENTS__TERM_TYPE_NR - 6);
| ^
| , ""
1 error generated.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Kan Liang <kan.liang@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Link: https://lore.kernel.org/r/20240308001915.4060155-5-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-03-07 17:19:13 -07:00
|
|
|
typedef int (*pmu_format_callback)(void *state, const char *name, int config,
|
|
|
|
const unsigned long *bits);
|
2023-08-23 21:13:14 -07:00
|
|
|
|
2023-08-23 01:08:11 -07:00
|
|
|
void pmu_add_sys_aliases(struct perf_pmu *pmu);
|
2012-03-15 12:09:17 -07:00
|
|
|
int perf_pmu__config(struct perf_pmu *pmu, struct perf_event_attr *attr,
|
2023-09-01 16:39:49 -07:00
|
|
|
struct parse_events_terms *head_terms,
|
perf tools: Add term support for parse_events_error
Allowing event's term processing to report back error, like:
$ perf record -e 'cpu/even=0x1/' ls
event syntax error: 'cpu/even=0x1/'
\___ unknown term
valid terms: pc,any,inv,edge,cmask,event,in_tx,ldlat,umask,in_tx_cp,offcore_rsp,config,config1,config2,name,period,branch_type
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1429729824-13932-7-git-send-email-jolsa@kernel.org
[ Renamed 'error' variables to 'err', not to clash with util.h error() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-22 12:10:21 -07:00
|
|
|
struct parse_events_error *error);
|
2023-10-12 10:56:43 -07:00
|
|
|
int perf_pmu__config_terms(const struct perf_pmu *pmu,
|
2012-11-09 17:46:50 -07:00
|
|
|
struct perf_event_attr *attr,
|
2023-09-01 16:39:49 -07:00
|
|
|
struct parse_events_terms *terms,
|
perf tools: Add term support for parse_events_error
Allowing event's term processing to report back error, like:
$ perf record -e 'cpu/even=0x1/' ls
event syntax error: 'cpu/even=0x1/'
\___ unknown term
valid terms: pc,any,inv,edge,cmask,event,in_tx,ldlat,umask,in_tx_cp,offcore_rsp,config,config1,config2,name,period,branch_type
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1429729824-13932-7-git-send-email-jolsa@kernel.org
[ Renamed 'error' variables to 'err', not to clash with util.h error() ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2015-04-22 12:10:21 -07:00
|
|
|
bool zero, struct parse_events_error *error);
|
2023-08-23 01:08:10 -07:00
|
|
|
__u64 perf_pmu__format_bits(struct perf_pmu *pmu, const char *name);
|
2023-08-23 01:08:09 -07:00
|
|
|
int perf_pmu__format_type(struct perf_pmu *pmu, const char *name);
|
2023-09-01 16:39:49 -07:00
|
|
|
int perf_pmu__check_alias(struct perf_pmu *pmu, struct parse_events_terms *head_terms,
|
perf parse-events: Make legacy events lower priority than sysfs/JSON
The perf tool has previously made legacy events the priority so with
or without a PMU the legacy event would be opened:
$ perf stat -e cpu-cycles,cpu/cpu-cycles/ true
Using CPUID GenuineIntel-6-8D-1
intel_pt default config: tsc,mtc,mtc_period=3,psb_period=3,pt,branch
Attempting to add event pmu 'cpu' with 'cpu-cycles,' that may result in non-fatal errors
After aliases, add event pmu 'cpu' with 'cpu-cycles,' that may result in non-fatal errors
Control descriptor is not initialized
------------------------------------------------------------
perf_event_attr:
type 0 (PERF_TYPE_HARDWARE)
size 136
config 0 (PERF_COUNT_HW_CPU_CYCLES)
sample_type IDENTIFIER
read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
disabled 1
inherit 1
enable_on_exec 1
exclude_guest 1
------------------------------------------------------------
sys_perf_event_open: pid 833967 cpu -1 group_fd -1 flags 0x8 = 3
------------------------------------------------------------
perf_event_attr:
type 0 (PERF_TYPE_HARDWARE)
size 136
config 0 (PERF_COUNT_HW_CPU_CYCLES)
sample_type IDENTIFIER
read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
disabled 1
inherit 1
enable_on_exec 1
exclude_guest 1
------------------------------------------------------------
...
Fixes to make hybrid/BIG.little PMUs behave correctly, ie as core PMUs
capable of opening legacy events on each, removing hard coded "cpu_core"
and "cpu_atom" Intel PMU names, etc. caused a behavioral difference on
Apple/ARM due to latent issues in the PMU driver reported in:
https://lore.kernel.org/lkml/08f1f185-e259-4014-9ca4-6411d5c1bc65@marcan.st/
As part of that report Mark Rutland <mark.rutland@arm.com> requested
that legacy events not be higher in priority when a PMU is specified
reversing what has until this change been perf's default behavior. With
this change the above becomes:
$ perf stat -e cpu-cycles,cpu/cpu-cycles/ true
Using CPUID GenuineIntel-6-8D-1
Attempt to add: cpu/cpu-cycles=0/
..after resolving event: cpu/event=0x3c/
Control descriptor is not initialized
------------------------------------------------------------
perf_event_attr:
type 0 (PERF_TYPE_HARDWARE)
size 136
config 0 (PERF_COUNT_HW_CPU_CYCLES)
sample_type IDENTIFIER
read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
disabled 1
inherit 1
enable_on_exec 1
exclude_guest 1
------------------------------------------------------------
sys_perf_event_open: pid 827628 cpu -1 group_fd -1 flags 0x8 = 3
------------------------------------------------------------
perf_event_attr:
type 4 (PERF_TYPE_RAW)
size 136
config 0x3c
sample_type IDENTIFIER
read_format TOTAL_TIME_ENABLED|TOTAL_TIME_RUNNING
disabled 1
inherit 1
enable_on_exec 1
exclude_guest 1
------------------------------------------------------------
...
So the second event has become a raw event as
/sys/devices/cpu/events/cpu-cycles exists.
A fix was necessary to config_term_pmu in parse-events.c as check_alias
expansion needs to happen after config_term_pmu, and config_term_pmu may
need calling a second time because of this.
config_term_pmu is updated to not use the legacy event when the PMU has
such a named event (either from JSON or sysfs).
The bulk of this change is updating all of the parse-events test
expectations so that if a sysfs/JSON event exists for a PMU the test
doesn't fail - a further sign, if it were needed, that the legacy event
priority was a known and tested behavior of the perf tool.
Reported-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Hector Martin <marcan@marcan.st>
Tested-by: Marc Zyngier <maz@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20231123042922.834425-1-irogers@google.com
[ Initialize the 'alias_rewrote_terms' variable to false to address a clang warning ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2023-11-22 21:29:22 -07:00
|
|
|
struct perf_pmu_info *info, bool *rewrote_terms,
|
|
|
|
struct parse_events_error *err);
|
2023-08-23 21:13:14 -07:00
|
|
|
int perf_pmu__find_event(struct perf_pmu *pmu, const char *event, void *state, pmu_event_callback cb);
|
2012-03-15 12:09:17 -07:00
|
|
|
|
2023-08-23 21:13:13 -07:00
|
|
|
void perf_pmu_format__set_value(void *format, int config, unsigned long *bits);
|
2023-07-06 11:37:05 -07:00
|
|
|
bool perf_pmu__has_format(const struct perf_pmu *pmu, const char *name);
|
perf list: Give more details about raw event encodings
List all the PMUs, not just the first core one, and list real format
specifiers with value ranges.
Before:
$ perf list
...
rNNN [Raw hardware event descriptor]
cpu/t1=v1[,t2=v2,t3 ...]/modifier [Raw hardware event descriptor]
[(see 'man perf-list' on how to encode it)]
mem:<addr>[/len][:access] [Hardware breakpoint]
...
After:
$ perf list
...
rNNN [Raw event descriptor]
cpu/event=0..255,pc,edge,.../modifier [Raw event descriptor]
[(see 'man perf-list' or 'man perf-record' on how to encode it)]
breakpoint//modifier [Raw event descriptor]
cstate_core/event=0..0xffffffffffffffff/modifier [Raw event descriptor]
cstate_pkg/event=0..0xffffffffffffffff/modifier [Raw event descriptor]
i915/i915_eventid=0..0x1fffff/modifier [Raw event descriptor]
intel_bts//modifier [Raw event descriptor]
intel_pt/ptw,event,cyc_thresh=0..15,.../modifier [Raw event descriptor]
kprobe/retprobe/modifier [Raw event descriptor]
msr/event=0..0xffffffffffffffff/modifier [Raw event descriptor]
power/event=0..255/modifier [Raw event descriptor]
software//modifier [Raw event descriptor]
tracepoint//modifier [Raw event descriptor]
uncore_arb/event=0..255,edge,inv,.../modifier [Raw event descriptor]
uncore_cbox/event=0..255,edge,inv,.../modifier [Raw event descriptor]
uncore_clock/event=0..255/modifier [Raw event descriptor]
uncore_imc_free_running/event=0..255,umask=0..255/modifier[Raw event descriptor]
uprobe/ref_ctr_offset=0..0xffffffff,retprobe/modifier[Raw event descriptor]
mem:<addr>[/len][:access] [Hardware breakpoint]
...
With '--details' provide more details on the formats encoding:
cpu/event=0..255,pc,edge,.../modifier [Raw event descriptor]
[(see 'man perf-list' or 'man perf-record' on how to encode it)]
cpu/event=0..255,pc,edge,offcore_rsp=0..0xffffffffffffffff,ldlat=0..0xffff,inv,
umask=0..255,frontend=0..0xffffff,cmask=0..255,config=0..0xffffffffffffffff,
config1=0..0xffffffffffffffff,config2=0..0xffffffffffffffff,config3=0..0xffffffffffffffff,
name=string,period=number,freq=number,branch_type=(u|k|hv|any|...),time,
call-graph=(fp|dwarf|lbr),stack-size=number,max-stack=number,nr=number,inherit,no-inherit,
overwrite,no-overwrite,percore,aux-output,aux-sample-size=number/modifier
breakpoint//modifier [Raw event descriptor]
breakpoint//modifier
cstate_core/event=0..0xffffffffffffffff/modifier [Raw event descriptor]
cstate_core/event=0..0xffffffffffffffff/modifier
cstate_pkg/event=0..0xffffffffffffffff/modifier [Raw event descriptor]
cstate_pkg/event=0..0xffffffffffffffff/modifier
i915/i915_eventid=0..0x1fffff/modifier [Raw event descriptor]
i915/i915_eventid=0..0x1fffff/modifier
intel_bts//modifier [Raw event descriptor]
intel_bts//modifier
intel_pt/ptw,event,cyc_thresh=0..15,.../modifier [Raw event descriptor]
intel_pt/ptw,event,cyc_thresh=0..15,pt,notnt,branch,tsc,pwr_evt,fup_on_ptw,cyc,noretcomp,
mtc,psb_period=0..15,mtc_period=0..15/modifier
kprobe/retprobe/modifier [Raw event descriptor]
kprobe/retprobe/modifier
msr/event=0..0xffffffffffffffff/modifier [Raw event descriptor]
msr/event=0..0xffffffffffffffff/modifier
power/event=0..255/modifier [Raw event descriptor]
power/event=0..255/modifier
software//modifier [Raw event descriptor]
software//modifier
tracepoint//modifier [Raw event descriptor]
tracepoint//modifier
uncore_arb/event=0..255,edge,inv,.../modifier [Raw event descriptor]
uncore_arb/event=0..255,edge,inv,umask=0..255,cmask=0..31/modifier
uncore_cbox/event=0..255,edge,inv,.../modifier [Raw event descriptor]
uncore_cbox/event=0..255,edge,inv,umask=0..255,cmask=0..31/modifier
uncore_clock/event=0..255/modifier [Raw event descriptor]
uncore_clock/event=0..255/modifier
uncore_imc_free_running/event=0..255,umask=0..255/modifier[Raw event descriptor]
uncore_imc_free_running/event=0..255,umask=0..255/modifier
uprobe/ref_ctr_offset=0..0xffffffff,retprobe/modifier[Raw event descriptor]
uprobe/ref_ctr_offset=0..0xffffffff,retprobe/modifier
Committer notes:
Address this build error in various distros:
55 58.44 ubuntu:24.04 : FAIL gcc version 13.2.0 (Ubuntu 13.2.0-17ubuntu2)
util/pmu.c:1638:70: error: '_Static_assert' with no message is a C2x extension [-Werror,-Wc2x-extensions]
1638 | _Static_assert(ARRAY_SIZE(terms) == __PARSE_EVENTS__TERM_TYPE_NR - 6);
| ^
| , ""
1 error generated.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Kan Liang <kan.liang@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Yang Jihong <yangjihong1@huawei.com>
Link: https://lore.kernel.org/r/20240308001915.4060155-5-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-03-07 17:19:13 -07:00
|
|
|
int perf_pmu__for_each_format(struct perf_pmu *pmu, void *state, pmu_format_callback cb);
|
2012-03-15 12:09:17 -07:00
|
|
|
|
2020-03-17 04:02:17 -07:00
|
|
|
bool is_pmu_core(const char *name);
|
2023-05-02 15:38:30 -07:00
|
|
|
bool perf_pmu__supports_legacy_cache(const struct perf_pmu *pmu);
|
2023-05-02 15:38:43 -07:00
|
|
|
bool perf_pmu__auto_merge_stats(const struct perf_pmu *pmu);
|
2023-08-23 21:13:25 -07:00
|
|
|
bool perf_pmu__have_event(struct perf_pmu *pmu, const char *name);
|
|
|
|
size_t perf_pmu__num_events(struct perf_pmu *pmu);
|
2023-08-25 06:52:37 -07:00
|
|
|
int perf_pmu__for_each_event(struct perf_pmu *pmu, bool skip_duplicate_pmus,
|
|
|
|
void *state, pmu_event_callback cb);
|
2023-08-23 21:13:19 -07:00
|
|
|
bool pmu__name_match(const struct perf_pmu *pmu, const char *pmu_name);
|
2023-08-23 21:13:14 -07:00
|
|
|
|
2023-06-01 01:29:53 -07:00
|
|
|
/**
|
|
|
|
* perf_pmu_is_software - is the PMU a software PMU as in it uses the
|
|
|
|
* perf_sw_context in the kernel?
|
|
|
|
*/
|
|
|
|
bool perf_pmu__is_software(const struct perf_pmu *pmu);
|
2013-04-20 11:02:29 -07:00
|
|
|
|
2023-10-12 10:56:42 -07:00
|
|
|
FILE *perf_pmu__open_file(const struct perf_pmu *pmu, const char *name);
|
|
|
|
FILE *perf_pmu__open_file_at(const struct perf_pmu *pmu, int dirfd, const char *name);
|
2023-03-31 13:29:48 -07:00
|
|
|
|
2023-10-12 10:56:42 -07:00
|
|
|
int perf_pmu__scan_file(const struct perf_pmu *pmu, const char *name, const char *fmt, ...)
|
|
|
|
__scanf(3, 4);
|
|
|
|
int perf_pmu__scan_file_at(const struct perf_pmu *pmu, int dirfd, const char *name,
|
2023-03-31 13:29:48 -07:00
|
|
|
const char *fmt, ...) __scanf(4, 5);
|
2014-07-30 23:00:50 -07:00
|
|
|
|
2023-10-12 10:56:42 -07:00
|
|
|
bool perf_pmu__file_exists(const struct perf_pmu *pmu, const char *name);
|
2023-01-20 07:36:57 -07:00
|
|
|
|
2012-03-15 12:09:17 -07:00
|
|
|
int perf_pmu__test(void);
|
2014-07-30 23:00:49 -07:00
|
|
|
|
2023-10-12 10:56:39 -07:00
|
|
|
void perf_pmu__arch_init(struct perf_pmu *pmu);
|
2023-08-23 01:08:11 -07:00
|
|
|
void pmu_add_cpu_aliases_table(struct perf_pmu *pmu,
|
2022-08-12 16:09:46 -07:00
|
|
|
const struct pmu_events_table *table);
|
2014-07-30 23:00:49 -07:00
|
|
|
|
2022-08-12 16:09:42 -07:00
|
|
|
char *perf_pmu__getcpuid(struct perf_pmu *pmu);
|
2023-01-26 16:36:39 -07:00
|
|
|
const struct pmu_metrics_table *pmu_metrics_table__find(void);
|
2023-09-26 22:59:45 -07:00
|
|
|
bool pmu_uncore_identifier_match(const char *compat, const char *id);
|
2017-08-31 12:40:30 -07:00
|
|
|
|
2019-08-27 22:59:29 -07:00
|
|
|
int perf_pmu__convert_scale(const char *scale, char **end, double *sval);
|
|
|
|
|
2020-03-19 13:25:01 -07:00
|
|
|
int perf_pmu__caps_parse(struct perf_pmu *pmu);
|
|
|
|
|
2021-03-09 22:11:38 -07:00
|
|
|
void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config,
|
2023-05-31 19:36:44 -07:00
|
|
|
const char *name, int config_num,
|
|
|
|
const char *config_name);
|
2022-10-04 12:12:35 -07:00
|
|
|
void perf_pmu__warn_invalid_formats(struct perf_pmu *pmu);
|
2021-03-09 22:11:38 -07:00
|
|
|
|
2024-04-15 23:15:20 -07:00
|
|
|
bool perf_pmu__match(const struct perf_pmu *pmu, const char *tok);
|
2021-04-27 00:01:19 -07:00
|
|
|
|
2023-01-17 00:29:25 -07:00
|
|
|
double perf_pmu__cpu_slots_per_cycle(void);
|
2023-01-20 07:36:54 -07:00
|
|
|
int perf_pmu__event_source_devices_scnprintf(char *pathname, size_t size);
|
|
|
|
int perf_pmu__pathname_scnprintf(char *buf, size_t size,
|
|
|
|
const char *pmu_name, const char *filename);
|
perf pmu: Use relative path for sysfs scan
The PMU information is in the kernel sysfs so it needs to scan the
directory to get the whole information like event aliases, formats and
so on. During the traversal, it opens a lot of files and directories
like below:
dir = opendir("/sys/bus/event_source/devices");
while (dentry = readdir(dir)) {
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s/%s",
"/sys/bus/event_source/devices", dentry->d_name);
fd = open(buf, O_RDONLY);
...
}
But this is not good since it needs to copy the string to build the
absolute pathname, and it makes redundant pathname walk (from the /sys)
unnecessarily. We can use openat(2) to open the file in the given
directory. While it's not a problem ususally, it can be a problem when
the kernel has contentions on the sysfs.
Add a couple of new helper to return the file descriptor of PMU
directory so that it can use it with relative paths.
* perf_pmu__event_source_devices_fd()
- returns a fd for the PMU root ("/sys/bus/event_source/devices")
* perf_pmu__pathname_fd()
- returns a fd for "<pmu>/<file>" under the PMU root
Now the above code can be converted something like below:
dirfd = perf_pmu__event_source_devices_fd();
dir = fdopendir(dirfd);
while (dentry = readdir(dir)) {
fd = openat(dirfd, dentry->d_name, O_RDONLY);
...
}
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230331202949.810326-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2023-03-31 13:29:45 -07:00
|
|
|
int perf_pmu__event_source_devices_fd(void);
|
|
|
|
int perf_pmu__pathname_fd(int dirfd, const char *pmu_name, const char *filename, int flags);
|
2023-01-20 07:36:54 -07:00
|
|
|
|
2024-05-02 14:35:04 -07:00
|
|
|
struct perf_pmu *perf_pmu__lookup(struct list_head *pmus, int dirfd, const char *lookup_name,
|
|
|
|
bool eager_load);
|
2023-06-27 11:28:34 -07:00
|
|
|
struct perf_pmu *perf_pmu__create_placeholder_core_pmu(struct list_head *core_pmus);
|
2023-05-27 00:22:03 -07:00
|
|
|
void perf_pmu__delete(struct perf_pmu *pmu);
|
2023-09-13 08:33:48 -07:00
|
|
|
struct perf_pmu *perf_pmus__find_core_pmu(void);
|
2024-03-07 17:19:15 -07:00
|
|
|
const char *perf_pmu__name_from_config(struct perf_pmu *pmu, u64 config);
|
2023-03-31 13:29:43 -07:00
|
|
|
|
2012-03-15 12:09:17 -07:00
|
|
|
#endif /* __PMU_H */
|