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 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2012-05-21 15:12:49 +08:00
|
|
|
#include "parse-events.h"
|
|
|
|
#include "evsel.h"
|
|
|
|
#include "evlist.h"
|
2013-12-10 00:14:24 +08:00
|
|
|
#include <api/fs/fs.h>
|
2012-11-10 08:46:51 +08:00
|
|
|
#include "tests.h"
|
2014-07-15 05:46:48 +08:00
|
|
|
#include "debug.h"
|
2019-08-31 01:45:20 +08:00
|
|
|
#include "pmu.h"
|
2023-05-03 06:38:17 +08:00
|
|
|
#include "pmus.h"
|
2017-04-18 23:26:44 +08:00
|
|
|
#include <dirent.h>
|
2017-04-18 21:46:11 +08:00
|
|
|
#include <errno.h>
|
2021-09-02 14:59:55 +08:00
|
|
|
#include "fncache.h"
|
2017-04-20 07:57:47 +08:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
2017-04-17 22:39:06 +08:00
|
|
|
#include <linux/kernel.h>
|
2012-11-20 06:21:03 +08:00
|
|
|
#include <linux/hw_breakpoint.h>
|
2017-04-18 22:44:58 +08:00
|
|
|
#include <api/fs/tracing_path.h>
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2012-08-01 20:48:58 +08:00
|
|
|
#define PERF_TP_SAMPLE_TYPE (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME | \
|
|
|
|
PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD)
|
|
|
|
|
2023-07-05 16:26:52 +08:00
|
|
|
static int num_core_entries(void)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* If the kernel supports extended type, expect events to be
|
|
|
|
* opened once for each core PMU type. Otherwise fall back to the legacy
|
|
|
|
* behavior of opening only one event even though there are multiple
|
|
|
|
* PMUs
|
|
|
|
*/
|
|
|
|
if (perf_pmus__supports_extended_type())
|
|
|
|
return perf_pmus__num_core_pmus();
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2023-05-03 06:38:19 +08:00
|
|
|
static bool test_config(const struct evsel *evsel, __u64 expected_config)
|
|
|
|
{
|
|
|
|
__u32 type = evsel->core.attr.type;
|
|
|
|
__u64 config = evsel->core.attr.config;
|
|
|
|
|
|
|
|
if (type == PERF_TYPE_HARDWARE || type == PERF_TYPE_HW_CACHE) {
|
|
|
|
/*
|
|
|
|
* HARDWARE and HW_CACHE events encode the PMU's extended type
|
|
|
|
* in the top 32-bits. Mask in order to ignore.
|
|
|
|
*/
|
|
|
|
config &= PERF_HW_EVENT_MASK;
|
|
|
|
}
|
|
|
|
return config == expected_config;
|
|
|
|
}
|
|
|
|
|
2023-05-03 06:38:39 +08:00
|
|
|
static bool test_perf_config(const struct perf_evsel *evsel, __u64 expected_config)
|
|
|
|
{
|
|
|
|
return (evsel->attr.config & PERF_HW_EVENT_MASK) == expected_config;
|
|
|
|
}
|
|
|
|
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#ifdef HAVE_LIBTRACEEVENT
|
|
|
|
|
2019-06-04 13:35:04 +08:00
|
|
|
#if defined(__s390x__)
|
|
|
|
/* Return true if kvm module is available and loaded. Test this
|
2021-03-24 00:09:15 +08:00
|
|
|
* and return success when trace point kvm_s390_create_vm
|
2019-06-04 13:35:04 +08:00
|
|
|
* exists. Otherwise this test always fails.
|
|
|
|
*/
|
|
|
|
static bool kvm_s390_create_vm_valid(void)
|
|
|
|
{
|
|
|
|
char *eventfile;
|
|
|
|
bool rc = false;
|
|
|
|
|
|
|
|
eventfile = get_events_file("kvm-s390");
|
|
|
|
|
|
|
|
if (eventfile) {
|
|
|
|
DIR *mydir = opendir(eventfile);
|
|
|
|
|
|
|
|
if (mydir) {
|
|
|
|
rc = true;
|
|
|
|
closedir(mydir);
|
|
|
|
}
|
|
|
|
put_events_file(eventfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_tracepoint(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
2023-03-12 10:15:42 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 0 == evlist__nr_groups(evlist));
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_type",
|
2019-07-21 19:24:29 +08:00
|
|
|
PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period);
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_tracepoint_multi(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-07-21 19:23:51 +08:00
|
|
|
struct evsel *evsel;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", evlist->core.nr_entries > 1);
|
2023-03-12 10:15:42 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 0 == evlist__nr_groups(evlist));
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2016-06-23 22:26:15 +08:00
|
|
|
evlist__for_each_entry(evlist, evsel) {
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type",
|
2019-07-21 19:24:29 +08:00
|
|
|
PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_type",
|
2019-07-21 19:24:29 +08:00
|
|
|
PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_period",
|
2019-07-21 19:24:29 +08:00
|
|
|
1 == evsel->core.attr.sample_period);
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#endif /* HAVE_LIBTRACEEVENT */
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_raw(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2023-05-03 06:38:39 +08:00
|
|
|
struct perf_evsel *evsel;
|
|
|
|
bool raw_type_match = false;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2023-05-03 06:38:39 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 0 != evlist->core.nr_entries);
|
|
|
|
|
|
|
|
perf_evlist__for_each_evsel(&evlist->core, evsel) {
|
2023-07-05 16:26:51 +08:00
|
|
|
struct perf_pmu *pmu __maybe_unused = NULL;
|
2023-05-03 06:38:39 +08:00
|
|
|
bool type_matched = false;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_perf_config(evsel, 0x1a));
|
2023-07-05 16:26:51 +08:00
|
|
|
TEST_ASSERT_VAL("event not parsed as raw type",
|
|
|
|
evsel->attr.type == PERF_TYPE_RAW);
|
|
|
|
#if defined(__aarch64__)
|
|
|
|
/*
|
|
|
|
* Arm doesn't have a real raw type PMU in sysfs, so raw events
|
|
|
|
* would never match any PMU. However, RAW events on Arm will
|
|
|
|
* always successfully open on the first available core PMU
|
|
|
|
* so no need to test for a matching type here.
|
|
|
|
*/
|
|
|
|
type_matched = raw_type_match = true;
|
|
|
|
#else
|
2023-05-27 15:22:03 +08:00
|
|
|
while ((pmu = perf_pmus__scan(pmu)) != NULL) {
|
2023-05-03 06:38:39 +08:00
|
|
|
if (pmu->type == evsel->attr.type) {
|
|
|
|
TEST_ASSERT_VAL("PMU type expected once", !type_matched);
|
|
|
|
type_matched = true;
|
|
|
|
if (pmu->type == PERF_TYPE_RAW)
|
|
|
|
raw_type_match = true;
|
|
|
|
}
|
|
|
|
}
|
2023-07-05 16:26:51 +08:00
|
|
|
#endif
|
2023-05-03 06:38:39 +08:00
|
|
|
TEST_ASSERT_VAL("No PMU found for type", type_matched);
|
|
|
|
}
|
|
|
|
TEST_ASSERT_VAL("Raw PMU not matched", raw_type_match);
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_numeric(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 1));
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_symbolic_name(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2023-05-03 06:38:39 +08:00
|
|
|
struct perf_evsel *evsel;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2023-05-03 06:38:39 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 0 != evlist->core.nr_entries);
|
|
|
|
|
|
|
|
perf_evlist__for_each_evsel(&evlist->core, evsel) {
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
test_perf_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_symbolic_name_config(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2023-05-03 06:38:39 +08:00
|
|
|
struct perf_evsel *evsel;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2023-05-03 06:38:39 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 0 != evlist->core.nr_entries);
|
|
|
|
|
|
|
|
perf_evlist__for_each_evsel(&evlist->core, evsel) {
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_perf_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
/*
|
|
|
|
* The period value gets configured within evlist__config,
|
|
|
|
* while this test executes only parse events method.
|
|
|
|
*/
|
|
|
|
TEST_ASSERT_VAL("wrong period", 0 == evsel->attr.sample_period);
|
|
|
|
TEST_ASSERT_VAL("wrong config1", 0 == evsel->attr.config1);
|
|
|
|
TEST_ASSERT_VAL("wrong config2", 1 == evsel->attr.config2);
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_symbolic_alias(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_SW_PAGE_FAULTS));
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_genhw(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2023-05-03 06:38:39 +08:00
|
|
|
struct perf_evsel *evsel;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2023-05-03 06:38:39 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 0 != evlist->core.nr_entries);
|
|
|
|
|
|
|
|
perf_evlist__for_each_entry(&evlist->core, evsel) {
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_perf_config(evsel, 1 << 16));
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_breakpoint(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 0));
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
|
2019-07-21 19:24:29 +08:00
|
|
|
evsel->core.attr.bp_type);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 ==
|
2019-07-21 19:24:29 +08:00
|
|
|
evsel->core.attr.bp_len);
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_breakpoint_x(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 0));
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong bp_type",
|
2019-07-21 19:24:29 +08:00
|
|
|
HW_BREAKPOINT_X == evsel->core.attr.bp_type);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel->core.attr.bp_len);
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_breakpoint_r(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type",
|
2019-07-21 19:24:29 +08:00
|
|
|
PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 0));
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong bp_type",
|
2019-07-21 19:24:29 +08:00
|
|
|
HW_BREAKPOINT_R == evsel->core.attr.bp_type);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong bp_len",
|
2019-07-21 19:24:29 +08:00
|
|
|
HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len);
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_breakpoint_w(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type",
|
2019-07-21 19:24:29 +08:00
|
|
|
PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 0));
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong bp_type",
|
2019-07-21 19:24:29 +08:00
|
|
|
HW_BREAKPOINT_W == evsel->core.attr.bp_type);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong bp_len",
|
2019-07-21 19:24:29 +08:00
|
|
|
HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len);
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_breakpoint_rw(struct evlist *evlist)
|
2012-06-29 15:22:54 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-06-29 15:22:54 +08:00
|
|
|
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
2012-06-29 15:22:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type",
|
2019-07-21 19:24:29 +08:00
|
|
|
PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 0));
|
2012-06-29 15:22:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong bp_type",
|
2019-07-21 19:24:29 +08:00
|
|
|
(HW_BREAKPOINT_R|HW_BREAKPOINT_W) == evsel->core.attr.bp_type);
|
2012-06-29 15:22:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong bp_len",
|
2019-07-21 19:24:29 +08:00
|
|
|
HW_BREAKPOINT_LEN_4 == evsel->core.attr.bp_len);
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-06-29 15:22:54 +08:00
|
|
|
}
|
|
|
|
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#ifdef HAVE_LIBTRACEEVENT
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_tracepoint_modifier(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
return test__checkevent_tracepoint(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2019-07-21 19:23:52 +08:00
|
|
|
test__checkevent_tracepoint_multi_modifier(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2023-05-03 06:38:39 +08:00
|
|
|
struct perf_evsel *evsel;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", evlist->core.nr_entries > 1);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2023-05-03 06:38:39 +08:00
|
|
|
perf_evlist__for_each_entry(&evlist->core, evsel) {
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return test__checkevent_tracepoint_multi(evlist);
|
|
|
|
}
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#endif /* HAVE_LIBTRACEEVENT */
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_raw_modifier(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2023-05-03 06:38:39 +08:00
|
|
|
struct perf_evsel *evsel;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2023-05-03 06:38:39 +08:00
|
|
|
perf_evlist__for_each_entry(&evlist->core, evsel) {
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
|
|
|
|
}
|
2012-05-21 15:12:49 +08:00
|
|
|
return test__checkevent_raw(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_numeric_modifier(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2023-05-03 06:38:39 +08:00
|
|
|
struct perf_evsel *evsel;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2023-05-03 06:38:39 +08:00
|
|
|
perf_evlist__for_each_entry(&evlist->core, evsel) {
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
|
|
|
|
}
|
2012-05-21 15:12:49 +08:00
|
|
|
return test__checkevent_numeric(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_symbolic_name_modifier(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2023-06-01 16:29:54 +08:00
|
|
|
struct perf_evsel *evsel;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == num_core_entries());
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
perf_evlist__for_each_entry(&evlist->core, evsel) {
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
}
|
2012-05-21 15:12:49 +08:00
|
|
|
return test__checkevent_symbolic_name(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_exclude_host_modifier(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2023-05-03 06:38:39 +08:00
|
|
|
struct perf_evsel *evsel;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2023-05-03 06:38:39 +08:00
|
|
|
perf_evlist__for_each_entry(&evlist->core, evsel) {
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
|
|
|
|
}
|
2012-05-21 15:12:49 +08:00
|
|
|
return test__checkevent_symbolic_name(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_exclude_guest_modifier(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2023-05-03 06:38:39 +08:00
|
|
|
struct perf_evsel *evsel;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2023-05-03 06:38:39 +08:00
|
|
|
perf_evlist__for_each_entry(&evlist->core, evsel) {
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
}
|
2012-05-21 15:12:49 +08:00
|
|
|
return test__checkevent_symbolic_name(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_symbolic_alias_modifier(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
return test__checkevent_symbolic_alias(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_genhw_modifier(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2023-05-03 06:38:39 +08:00
|
|
|
struct perf_evsel *evsel;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2023-05-03 06:38:39 +08:00
|
|
|
perf_evlist__for_each_entry(&evlist->core, evsel) {
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip);
|
|
|
|
}
|
2012-05-21 15:12:49 +08:00
|
|
|
return test__checkevent_genhw(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_exclude_idle_modifier(struct evlist *evlist)
|
2015-04-08 05:25:14 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2015-04-08 05:25:14 +08:00
|
|
|
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude idle", evsel->core.attr.exclude_idle);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
2015-04-08 05:25:14 +08:00
|
|
|
|
|
|
|
return test__checkevent_symbolic_name(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_exclude_idle_modifier_1(struct evlist *evlist)
|
2015-04-08 05:25:14 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2015-04-08 05:25:14 +08:00
|
|
|
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude idle", evsel->core.attr.exclude_idle);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
2015-04-08 05:25:14 +08:00
|
|
|
|
|
|
|
return test__checkevent_symbolic_name(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_breakpoint_modifier(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
2012-06-29 05:18:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name",
|
2020-04-30 03:07:09 +08:00
|
|
|
!strcmp(evsel__name(evsel), "mem:0:u"));
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
return test__checkevent_breakpoint(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_breakpoint_x_modifier(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
2012-06-29 05:18:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name",
|
2020-04-30 03:07:09 +08:00
|
|
|
!strcmp(evsel__name(evsel), "mem:0:x:k"));
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
return test__checkevent_breakpoint_x(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_breakpoint_r_modifier(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
|
2012-06-29 05:18:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name",
|
2020-04-30 03:07:09 +08:00
|
|
|
!strcmp(evsel__name(evsel), "mem:0:r:hp"));
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
return test__checkevent_breakpoint_r(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_breakpoint_w_modifier(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
|
2012-06-29 05:18:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name",
|
2020-04-30 03:07:09 +08:00
|
|
|
!strcmp(evsel__name(evsel), "mem:0:w:up"));
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
return test__checkevent_breakpoint_w(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_breakpoint_rw_modifier(struct evlist *evlist)
|
2012-06-29 15:22:54 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-06-29 15:22:54 +08:00
|
|
|
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
|
2012-06-29 05:18:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name",
|
2020-04-30 03:07:09 +08:00
|
|
|
!strcmp(evsel__name(evsel), "mem:0:rw:kp"));
|
2012-06-29 15:22:54 +08:00
|
|
|
|
|
|
|
return test__checkevent_breakpoint_rw(evlist);
|
|
|
|
}
|
|
|
|
|
perf parse: Allow config terms with breakpoints
Add config terms to the parsing of breakpoint events. Extend "Test event
parsing" to also cover using a confg term.
This makes breakpoint events consistent with other events which already
support config terms.
Example:
$ cat dr_test.c
#include <unistd.h>
#include <stdio.h>
void func0(void)
{
}
int main()
{
printf("func0 %p\n", &func0);
while (1) {
func0();
usleep(100000);
}
return 0;
}
$ gcc -g -O0 -o dr_test dr_test.c
$ ./dr_test &
[2] 19646
func0 0x55feb98dd169
$ perf record -e mem:0x55feb98dd169:x/name=breakpoint/ -p 19646 -- sleep 0.5
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.017 MB perf.data (5 samples) ]
$ perf script
dr_test 19646 5632.956628: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
dr_test 19646 5633.056866: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
dr_test 19646 5633.157084: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
dr_test 19646 5633.257309: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
dr_test 19646 5633.357532: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
$ sudo perf test "Test event parsing"
6: Parse event definition strings :
6.1: Test event parsing : Ok
$ sudo perf test -v "Test event parsing" |& grep mem
running test 8 'mem:0'
running test 9 'mem:0:x'
running test 10 'mem:0:r'
running test 11 'mem:0:w'
running test 19 'mem:0:u'
running test 20 'mem:0:x:k'
running test 21 'mem:0:r:hp'
running test 22 'mem:0:w:up'
running test 26 'mem:0:rw'
running test 27 'mem:0:rw:kp'
running test 42 'mem:0/1'
running test 43 'mem:0/2:w'
running test 44 'mem:0/4:rw:u'
running test 58 'mem:0/name=breakpoint/'
running test 59 'mem:0:x/name=breakpoint/'
running test 60 'mem:0:r/name=breakpoint/'
running test 61 'mem:0:w/name=breakpoint/'
running test 62 'mem:0/name=breakpoint/u'
running test 63 'mem:0:x/name=breakpoint/k'
running test 64 'mem:0:r/name=breakpoint/hp'
running test 65 'mem:0:w/name=breakpoint/up'
running test 66 'mem:0:rw/name=breakpoint/'
running test 67 'mem:0:rw/name=breakpoint/kp'
running test 68 'mem:0/1/name=breakpoint/'
running test 69 'mem:0/2:w/name=breakpoint/'
running test 70 'mem:0/4:rw/name=breakpoint/u'
running test 71 'mem:0/1/name=breakpoint1/,mem:0/4:rw/name=breakpoint2/'
Committer notes:
Folded follow up patch (see 2nd link below) to address warnings about
unused tokens:
perf tools: Suppress bison unused value warnings
Patch "perf tools: Allow config terms with breakpoints" introduced parse
tokens for colons and slashes within breakpoint parsing to prevent mix
up with colons and slashes related to config terms.
The token values are not needed but introduce bison "unused value"
warnings.
Suppress those warnings.
Committer testing:
# cat ~acme/c/mem_breakpoint.c
#include <stdio.h>
#include <unistd.h>
void func1(void) { }
void func2(void) { }
void func3(void) { }
void func4(void) { }
void func5(void) { }
int main()
{
printf("func1 %p\n", &func1);
printf("func2 %p\n", &func2);
printf("func3 %p\n", &func3);
printf("func4 %p\n", &func4);
printf("func5 %p\n", &func5);
while (1) {
func1(); func2(); func3(); func4(); func5();
usleep(100000);
}
return 0;
}
# ~acme/c/mem_breakpoint &
[1] 3186153
func1 0x401136
func2 0x40113d
func3 0x401144
func4 0x40114b
func5 0x401152
#
Trying to watch the first 4 functions for eXecutable access:
# perf record -e mem:0x401136:x/name=breakpoint1/,mem:0x40113d:x/name=breakpoint2/,mem:0x401144:x/name=breakpoint3/,mem:0x40114b:x/name=breakpoint4/ -p 3186153 -- sleep 0.5
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.026 MB perf.data (20 samples) ]
[root@five ~]# perf script
mem_breakpoint 3186153 131612.864793: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.864795: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.864796: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.864797: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.964868: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.964870: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.964871: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.964872: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.064945: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.064948: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.064948: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.064949: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.165024: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.165026: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.165027: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.165028: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.265103: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.265105: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.265106: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.265107: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
#
Then all the 5 functions:
# perf record -e mem:0x401136:x/name=breakpoint1/,mem:0x40113d:x/name=breakpoint2/,mem:0x401144:x/name=breakpoint3/,mem:0x40114b:x/name=breakpoint4/,mem:0x401152:x/name=breakpoint5/ -p 3186153 -- sleep 0.5
Error:
The sys_perf_event_open() syscall returned with 28 (No space left on device) for event (breakpoint5).
/bin/dmesg | grep -i perf may provide additional information.
# grep -m1 'model name' /proc/cpuinfo
model name : AMD Ryzen 9 5950X 16-Core Processor
#
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20230525082902.25332-2-adrian.hunter@intel.com
Link: https://lore.kernel.org/r/f7228dc9-fe18-a8e3-7d3f-52922e0e1113@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2023-05-25 16:29:02 +08:00
|
|
|
static int test__checkevent_breakpoint_modifier_name(struct evlist *evlist)
|
|
|
|
{
|
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong name",
|
|
|
|
!strcmp(evsel__name(evsel), "breakpoint"));
|
|
|
|
|
|
|
|
return test__checkevent_breakpoint(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_breakpoint_x_modifier_name(struct evlist *evlist)
|
|
|
|
{
|
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong name",
|
|
|
|
!strcmp(evsel__name(evsel), "breakpoint"));
|
|
|
|
|
|
|
|
return test__checkevent_breakpoint_x(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_breakpoint_r_modifier_name(struct evlist *evlist)
|
|
|
|
{
|
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong name",
|
|
|
|
!strcmp(evsel__name(evsel), "breakpoint"));
|
|
|
|
|
|
|
|
return test__checkevent_breakpoint_r(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_breakpoint_w_modifier_name(struct evlist *evlist)
|
|
|
|
{
|
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong name",
|
|
|
|
!strcmp(evsel__name(evsel), "breakpoint"));
|
|
|
|
|
|
|
|
return test__checkevent_breakpoint_w(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_breakpoint_rw_modifier_name(struct evlist *evlist)
|
|
|
|
{
|
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong name",
|
|
|
|
!strcmp(evsel__name(evsel), "breakpoint"));
|
|
|
|
|
|
|
|
return test__checkevent_breakpoint_rw(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_breakpoint_2_events(struct evlist *evlist)
|
|
|
|
{
|
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong name", !strcmp(evsel__name(evsel), "breakpoint1"));
|
|
|
|
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong name", !strcmp(evsel__name(evsel), "breakpoint2"));
|
|
|
|
|
|
|
|
return TEST_OK;
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_pmu(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
|
|
|
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 10));
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config1", 1 == evsel->core.attr.config1);
|
|
|
|
TEST_ASSERT_VAL("wrong config2", 3 == evsel->core.attr.config2);
|
2023-02-18 06:32:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config3", 0 == evsel->core.attr.config3);
|
2015-07-29 17:42:11 +08:00
|
|
|
/*
|
2020-12-01 02:07:49 +08:00
|
|
|
* The period value gets configured within evlist__config,
|
2015-07-29 17:42:11 +08:00
|
|
|
* while this test executes only parse events method.
|
|
|
|
*/
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
|
|
|
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#ifdef HAVE_LIBTRACEEVENT
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_list(struct evlist *evlist)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2023-05-03 06:38:39 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 3 <= evlist->core.nr_entries);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
/* r1 */
|
2023-05-03 06:38:39 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT != evsel->core.attr.type);
|
|
|
|
while (evsel->core.attr.type != PERF_TYPE_TRACEPOINT) {
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 1));
|
|
|
|
TEST_ASSERT_VAL("wrong config1", 0 == evsel->core.attr.config1);
|
|
|
|
TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2);
|
|
|
|
TEST_ASSERT_VAL("wrong config3", 0 == evsel->core.attr.config3);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
}
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2015-04-16 21:52:53 +08:00
|
|
|
/* syscalls:sys_enter_openat:k */
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->core.attr.type);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_type",
|
2019-07-21 19:24:29 +08:00
|
|
|
PERF_TP_SAMPLE_TYPE == evsel->core.attr.sample_type);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
/* 1:1:hp */
|
2020-04-30 22:06:45 +08:00
|
|
|
evsel = evsel__next(evsel);
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", 1 == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 1));
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#endif
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_pmu_name(struct evlist *evlist)
|
2012-05-21 15:12:53 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-05-21 15:12:53 +08:00
|
|
|
|
2012-06-21 18:25:16 +08:00
|
|
|
/* cpu/config=1,name=krava/u */
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 1));
|
2020-04-30 03:07:09 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name", !strcmp(evsel__name(evsel), "krava"));
|
2012-05-21 15:12:53 +08:00
|
|
|
|
2012-06-21 18:25:16 +08:00
|
|
|
/* cpu/config=2/u" */
|
2020-04-30 22:06:45 +08:00
|
|
|
evsel = evsel__next(evsel);
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 2));
|
2012-06-21 18:25:16 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name",
|
2020-04-30 03:07:09 +08:00
|
|
|
!strcmp(evsel__name(evsel), "cpu/config=2/u"));
|
2012-05-21 15:12:53 +08:00
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-05-21 15:12:53 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_pmu_partial_time_callgraph(struct evlist *evlist)
|
2015-08-11 18:30:50 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2015-08-11 18:30:50 +08:00
|
|
|
|
|
|
|
/* cpu/config=1,call-graph=fp,time,period=100000/ */
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->core.nr_entries);
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 1));
|
2015-08-11 18:30:50 +08:00
|
|
|
/*
|
2020-12-01 02:07:49 +08:00
|
|
|
* The period, time and callgraph value gets configured within evlist__config,
|
2015-08-11 18:30:50 +08:00
|
|
|
* while this test executes only parse events method.
|
|
|
|
*/
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period);
|
2018-05-29 03:00:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong callgraph", !evsel__has_callchain(evsel));
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->core.attr.sample_type));
|
2015-08-11 18:30:50 +08:00
|
|
|
|
|
|
|
/* cpu/config=2,call-graph=no,time=0,period=2000/ */
|
2020-04-30 22:06:45 +08:00
|
|
|
evsel = evsel__next(evsel);
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 2));
|
2015-08-11 18:30:50 +08:00
|
|
|
/*
|
2020-12-01 02:07:49 +08:00
|
|
|
* The period, time and callgraph value gets configured within evlist__config,
|
2015-08-11 18:30:50 +08:00
|
|
|
* while this test executes only parse events method.
|
|
|
|
*/
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period);
|
2018-05-29 03:00:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong callgraph", !evsel__has_callchain(evsel));
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->core.attr.sample_type));
|
2015-08-11 18:30:50 +08:00
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2015-08-11 18:30:50 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_pmu_events(struct evlist *evlist)
|
2012-10-10 20:53:18 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2012-10-10 20:53:18 +08:00
|
|
|
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
2023-05-03 06:38:17 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type ||
|
|
|
|
strcmp(evsel->pmu_name, "cpu"));
|
2012-10-10 20:53:18 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_user",
|
2019-07-21 19:24:29 +08:00
|
|
|
!evsel->core.attr.exclude_user);
|
2012-10-10 20:53:18 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel",
|
2019-07-21 19:24:29 +08:00
|
|
|
evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
|
perf tools: Add support for exclusive groups/events
Peter suggested that using the exclusive mode in perf could avoid some
problems with bad scheduling of groups. Exclusive is implemented in the
kernel, but wasn't exposed by the perf tool, so hard to use without
custom low level API users.
Add support for marking groups or events with :e for exclusive in the
perf tool. The implementation is basically the same as the existing
pinned attribute.
Committer testing:
# perf test "parse event"
6: Parse event definition strings : Ok
# perf test -v "parse event" |& grep :u*e
running test 56 'instructions:uep'
running test 57 '{cycles,cache-misses,branch-misses}:e'
#
#
# grep "model name" -m1 /proc/cpuinfo
model name : AMD Ryzen 9 3900X 12-Core Processor
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
<not counted> cycles (0.00%)
<not counted> cache-misses (0.00%)
<not counted> branch-misses (0.00%)
1.001269893 seconds time elapsed
Some events weren't counted. Try disabling the NMI watchdog:
echo 0 > /proc/sys/kernel/nmi_watchdog
perf stat ...
echo 1 > /proc/sys/kernel/nmi_watchdog
# echo 0 > /proc/sys/kernel/nmi_watchdog
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
1,298,663,141 cycles
30,962,215 cache-misses
5,325,150 branch-misses
1.001474934 seconds time elapsed
#
# The output for asking for precise events on AMD needs to improve, it
# supposedly works only for system wide or per CPU
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:uep' sleep 1
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles).
/bin/dmesg | grep -i perf may provide additional information.
# perf stat -a -e '{cycles,cache-misses,branch-misses}:ue' sleep 1
Performance counter stats for 'system wide':
746,363,126 cycles
16,881,611 cache-misses
2,871,259 branch-misses
1.001636066 seconds time elapsed
#
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20201014144255.22699-1-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-10-14 22:42:55 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);
|
2012-10-10 20:53:18 +08:00
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-10-10 20:53:18 +08:00
|
|
|
}
|
|
|
|
|
perf test: Add test case for pmu event new style format
Add test case in automated tests suite. It checks not only the two types
of pmu event stytle formats "pmu_event_name" and "cpu/pmu_event_name/",
but also the different formats mixtures which are more likely to trigger
parse issue.
The patch set including this one has been tested by the perf automated
test:
./perf test parse -v"
On haswell, ivybridge and Romley platform.
The patch set also has been tested on haswell by the following script.
Note: please make sure that your test system support TSX and
L1-dcache-loads events. Otherwise, you may want to change the events to
other pmu events.
[lk@localhost ~]$ cat perf_style_test.sh
# hardware events + kernel pmu event with different style
perf stat -x, -e cycles,mem-stores,tx-start sleep 2
perf stat -x, -e cpu-cycles,cycles-ct,cycles-t sleep 2
perf stat -x, -e cycles,cpu/cycles-ct/,cpu/cycles-t/ sleep 2
perf stat -x, -e instructions,cpu/tx-start/ sleep 2
perf stat -x, -e '{cycles,tx-start}' sleep 2
perf stat -x, -e '{cycles,cpu/tx-start/}' sleep 2
# HW Cache event + kernel pmu event with different style
perf stat -x, -e L1-dcache-loads,cpu/mem-stores/,tx-start sleep 2
perf stat -x, -e L1-dcache-loads,mem-stores,cpu/tx-start/ sleep 2
perf stat -x, -e '{L1-dcache-loads,mem-stores}' sleep 2
perf stat -x, -e '{L1-dcache-loads,cpu/tx-start/}' sleep 2
# Raw event + kernel pmu event with different style:
perf stat -x, -e cpu/event=0xc0,umask=0x00/,mem-loads,cpu/mem-stores/ sleep 2
perf stat -x, -e cpu/event=0xc0,umask=0x00/,tx-start,cpu/el-start/ sleep 2
perf stat -x, -e '{cpu/event=0xc0,umask=0x00/,tx-start}' sleep 2
Signed-off-by: Kan Liang <kan.liang@intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1412694532-23391-5-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-10-07 23:08:52 +08:00
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_pmu_events_mix(struct evlist *evlist)
|
perf test: Add test case for pmu event new style format
Add test case in automated tests suite. It checks not only the two types
of pmu event stytle formats "pmu_event_name" and "cpu/pmu_event_name/",
but also the different formats mixtures which are more likely to trigger
parse issue.
The patch set including this one has been tested by the perf automated
test:
./perf test parse -v"
On haswell, ivybridge and Romley platform.
The patch set also has been tested on haswell by the following script.
Note: please make sure that your test system support TSX and
L1-dcache-loads events. Otherwise, you may want to change the events to
other pmu events.
[lk@localhost ~]$ cat perf_style_test.sh
# hardware events + kernel pmu event with different style
perf stat -x, -e cycles,mem-stores,tx-start sleep 2
perf stat -x, -e cpu-cycles,cycles-ct,cycles-t sleep 2
perf stat -x, -e cycles,cpu/cycles-ct/,cpu/cycles-t/ sleep 2
perf stat -x, -e instructions,cpu/tx-start/ sleep 2
perf stat -x, -e '{cycles,tx-start}' sleep 2
perf stat -x, -e '{cycles,cpu/tx-start/}' sleep 2
# HW Cache event + kernel pmu event with different style
perf stat -x, -e L1-dcache-loads,cpu/mem-stores/,tx-start sleep 2
perf stat -x, -e L1-dcache-loads,mem-stores,cpu/tx-start/ sleep 2
perf stat -x, -e '{L1-dcache-loads,mem-stores}' sleep 2
perf stat -x, -e '{L1-dcache-loads,cpu/tx-start/}' sleep 2
# Raw event + kernel pmu event with different style:
perf stat -x, -e cpu/event=0xc0,umask=0x00/,mem-loads,cpu/mem-stores/ sleep 2
perf stat -x, -e cpu/event=0xc0,umask=0x00/,tx-start,cpu/el-start/ sleep 2
perf stat -x, -e '{cpu/event=0xc0,umask=0x00/,tx-start}' sleep 2
Signed-off-by: Kan Liang <kan.liang@intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1412694532-23391-5-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-10-07 23:08:52 +08:00
|
|
|
{
|
2023-06-01 16:29:54 +08:00
|
|
|
struct evsel *evsel = NULL;
|
perf test: Add test case for pmu event new style format
Add test case in automated tests suite. It checks not only the two types
of pmu event stytle formats "pmu_event_name" and "cpu/pmu_event_name/",
but also the different formats mixtures which are more likely to trigger
parse issue.
The patch set including this one has been tested by the perf automated
test:
./perf test parse -v"
On haswell, ivybridge and Romley platform.
The patch set also has been tested on haswell by the following script.
Note: please make sure that your test system support TSX and
L1-dcache-loads events. Otherwise, you may want to change the events to
other pmu events.
[lk@localhost ~]$ cat perf_style_test.sh
# hardware events + kernel pmu event with different style
perf stat -x, -e cycles,mem-stores,tx-start sleep 2
perf stat -x, -e cpu-cycles,cycles-ct,cycles-t sleep 2
perf stat -x, -e cycles,cpu/cycles-ct/,cpu/cycles-t/ sleep 2
perf stat -x, -e instructions,cpu/tx-start/ sleep 2
perf stat -x, -e '{cycles,tx-start}' sleep 2
perf stat -x, -e '{cycles,cpu/tx-start/}' sleep 2
# HW Cache event + kernel pmu event with different style
perf stat -x, -e L1-dcache-loads,cpu/mem-stores/,tx-start sleep 2
perf stat -x, -e L1-dcache-loads,mem-stores,cpu/tx-start/ sleep 2
perf stat -x, -e '{L1-dcache-loads,mem-stores}' sleep 2
perf stat -x, -e '{L1-dcache-loads,cpu/tx-start/}' sleep 2
# Raw event + kernel pmu event with different style:
perf stat -x, -e cpu/event=0xc0,umask=0x00/,mem-loads,cpu/mem-stores/ sleep 2
perf stat -x, -e cpu/event=0xc0,umask=0x00/,tx-start,cpu/el-start/ sleep 2
perf stat -x, -e '{cpu/event=0xc0,umask=0x00/,tx-start}' sleep 2
Signed-off-by: Kan Liang <kan.liang@intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1412694532-23391-5-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-10-07 23:08:52 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
/*
|
|
|
|
* The wild card event will be opened at least once, but it may be
|
|
|
|
* opened on each core PMU.
|
|
|
|
*/
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", evlist->core.nr_entries >= 2);
|
|
|
|
for (int i = 0; i < evlist->core.nr_entries - 1; i++) {
|
|
|
|
evsel = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
|
|
|
|
/* pmu-event:u */
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user",
|
|
|
|
!evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel",
|
|
|
|
evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
|
|
|
|
TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);
|
|
|
|
}
|
perf test: Add test case for pmu event new style format
Add test case in automated tests suite. It checks not only the two types
of pmu event stytle formats "pmu_event_name" and "cpu/pmu_event_name/",
but also the different formats mixtures which are more likely to trigger
parse issue.
The patch set including this one has been tested by the perf automated
test:
./perf test parse -v"
On haswell, ivybridge and Romley platform.
The patch set also has been tested on haswell by the following script.
Note: please make sure that your test system support TSX and
L1-dcache-loads events. Otherwise, you may want to change the events to
other pmu events.
[lk@localhost ~]$ cat perf_style_test.sh
# hardware events + kernel pmu event with different style
perf stat -x, -e cycles,mem-stores,tx-start sleep 2
perf stat -x, -e cpu-cycles,cycles-ct,cycles-t sleep 2
perf stat -x, -e cycles,cpu/cycles-ct/,cpu/cycles-t/ sleep 2
perf stat -x, -e instructions,cpu/tx-start/ sleep 2
perf stat -x, -e '{cycles,tx-start}' sleep 2
perf stat -x, -e '{cycles,cpu/tx-start/}' sleep 2
# HW Cache event + kernel pmu event with different style
perf stat -x, -e L1-dcache-loads,cpu/mem-stores/,tx-start sleep 2
perf stat -x, -e L1-dcache-loads,mem-stores,cpu/tx-start/ sleep 2
perf stat -x, -e '{L1-dcache-loads,mem-stores}' sleep 2
perf stat -x, -e '{L1-dcache-loads,cpu/tx-start/}' sleep 2
# Raw event + kernel pmu event with different style:
perf stat -x, -e cpu/event=0xc0,umask=0x00/,mem-loads,cpu/mem-stores/ sleep 2
perf stat -x, -e cpu/event=0xc0,umask=0x00/,tx-start,cpu/el-start/ sleep 2
perf stat -x, -e '{cpu/event=0xc0,umask=0x00/,tx-start}' sleep 2
Signed-off-by: Kan Liang <kan.liang@intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1412694532-23391-5-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-10-07 23:08:52 +08:00
|
|
|
/* cpu/pmu-event/u*/
|
2020-04-30 22:06:45 +08:00
|
|
|
evsel = evsel__next(evsel);
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", evsel__find_pmu(evsel)->is_core);
|
perf test: Add test case for pmu event new style format
Add test case in automated tests suite. It checks not only the two types
of pmu event stytle formats "pmu_event_name" and "cpu/pmu_event_name/",
but also the different formats mixtures which are more likely to trigger
parse issue.
The patch set including this one has been tested by the perf automated
test:
./perf test parse -v"
On haswell, ivybridge and Romley platform.
The patch set also has been tested on haswell by the following script.
Note: please make sure that your test system support TSX and
L1-dcache-loads events. Otherwise, you may want to change the events to
other pmu events.
[lk@localhost ~]$ cat perf_style_test.sh
# hardware events + kernel pmu event with different style
perf stat -x, -e cycles,mem-stores,tx-start sleep 2
perf stat -x, -e cpu-cycles,cycles-ct,cycles-t sleep 2
perf stat -x, -e cycles,cpu/cycles-ct/,cpu/cycles-t/ sleep 2
perf stat -x, -e instructions,cpu/tx-start/ sleep 2
perf stat -x, -e '{cycles,tx-start}' sleep 2
perf stat -x, -e '{cycles,cpu/tx-start/}' sleep 2
# HW Cache event + kernel pmu event with different style
perf stat -x, -e L1-dcache-loads,cpu/mem-stores/,tx-start sleep 2
perf stat -x, -e L1-dcache-loads,mem-stores,cpu/tx-start/ sleep 2
perf stat -x, -e '{L1-dcache-loads,mem-stores}' sleep 2
perf stat -x, -e '{L1-dcache-loads,cpu/tx-start/}' sleep 2
# Raw event + kernel pmu event with different style:
perf stat -x, -e cpu/event=0xc0,umask=0x00/,mem-loads,cpu/mem-stores/ sleep 2
perf stat -x, -e cpu/event=0xc0,umask=0x00/,tx-start,cpu/el-start/ sleep 2
perf stat -x, -e '{cpu/event=0xc0,umask=0x00/,tx-start}' sleep 2
Signed-off-by: Kan Liang <kan.liang@intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1412694532-23391-5-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-10-07 23:08:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_user",
|
2019-07-21 19:24:29 +08:00
|
|
|
!evsel->core.attr.exclude_user);
|
perf test: Add test case for pmu event new style format
Add test case in automated tests suite. It checks not only the two types
of pmu event stytle formats "pmu_event_name" and "cpu/pmu_event_name/",
but also the different formats mixtures which are more likely to trigger
parse issue.
The patch set including this one has been tested by the perf automated
test:
./perf test parse -v"
On haswell, ivybridge and Romley platform.
The patch set also has been tested on haswell by the following script.
Note: please make sure that your test system support TSX and
L1-dcache-loads events. Otherwise, you may want to change the events to
other pmu events.
[lk@localhost ~]$ cat perf_style_test.sh
# hardware events + kernel pmu event with different style
perf stat -x, -e cycles,mem-stores,tx-start sleep 2
perf stat -x, -e cpu-cycles,cycles-ct,cycles-t sleep 2
perf stat -x, -e cycles,cpu/cycles-ct/,cpu/cycles-t/ sleep 2
perf stat -x, -e instructions,cpu/tx-start/ sleep 2
perf stat -x, -e '{cycles,tx-start}' sleep 2
perf stat -x, -e '{cycles,cpu/tx-start/}' sleep 2
# HW Cache event + kernel pmu event with different style
perf stat -x, -e L1-dcache-loads,cpu/mem-stores/,tx-start sleep 2
perf stat -x, -e L1-dcache-loads,mem-stores,cpu/tx-start/ sleep 2
perf stat -x, -e '{L1-dcache-loads,mem-stores}' sleep 2
perf stat -x, -e '{L1-dcache-loads,cpu/tx-start/}' sleep 2
# Raw event + kernel pmu event with different style:
perf stat -x, -e cpu/event=0xc0,umask=0x00/,mem-loads,cpu/mem-stores/ sleep 2
perf stat -x, -e cpu/event=0xc0,umask=0x00/,tx-start,cpu/el-start/ sleep 2
perf stat -x, -e '{cpu/event=0xc0,umask=0x00/,tx-start}' sleep 2
Signed-off-by: Kan Liang <kan.liang@intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1412694532-23391-5-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-10-07 23:08:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel",
|
2019-07-21 19:24:29 +08:00
|
|
|
evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
|
perf tools: Add support for exclusive groups/events
Peter suggested that using the exclusive mode in perf could avoid some
problems with bad scheduling of groups. Exclusive is implemented in the
kernel, but wasn't exposed by the perf tool, so hard to use without
custom low level API users.
Add support for marking groups or events with :e for exclusive in the
perf tool. The implementation is basically the same as the existing
pinned attribute.
Committer testing:
# perf test "parse event"
6: Parse event definition strings : Ok
# perf test -v "parse event" |& grep :u*e
running test 56 'instructions:uep'
running test 57 '{cycles,cache-misses,branch-misses}:e'
#
#
# grep "model name" -m1 /proc/cpuinfo
model name : AMD Ryzen 9 3900X 12-Core Processor
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
<not counted> cycles (0.00%)
<not counted> cache-misses (0.00%)
<not counted> branch-misses (0.00%)
1.001269893 seconds time elapsed
Some events weren't counted. Try disabling the NMI watchdog:
echo 0 > /proc/sys/kernel/nmi_watchdog
perf stat ...
echo 1 > /proc/sys/kernel/nmi_watchdog
# echo 0 > /proc/sys/kernel/nmi_watchdog
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
1,298,663,141 cycles
30,962,215 cache-misses
5,325,150 branch-misses
1.001474934 seconds time elapsed
#
# The output for asking for precise events on AMD needs to improve, it
# supposedly works only for system wide or per CPU
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:uep' sleep 1
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles).
/bin/dmesg | grep -i perf may provide additional information.
# perf stat -a -e '{cycles,cache-misses,branch-misses}:ue' sleep 1
Performance counter stats for 'system wide':
746,363,126 cycles
16,881,611 cache-misses
2,871,259 branch-misses
1.001636066 seconds time elapsed
#
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20201014144255.22699-1-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-10-14 22:42:55 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.pinned);
|
perf test: Add test case for pmu event new style format
Add test case in automated tests suite. It checks not only the two types
of pmu event stytle formats "pmu_event_name" and "cpu/pmu_event_name/",
but also the different formats mixtures which are more likely to trigger
parse issue.
The patch set including this one has been tested by the perf automated
test:
./perf test parse -v"
On haswell, ivybridge and Romley platform.
The patch set also has been tested on haswell by the following script.
Note: please make sure that your test system support TSX and
L1-dcache-loads events. Otherwise, you may want to change the events to
other pmu events.
[lk@localhost ~]$ cat perf_style_test.sh
# hardware events + kernel pmu event with different style
perf stat -x, -e cycles,mem-stores,tx-start sleep 2
perf stat -x, -e cpu-cycles,cycles-ct,cycles-t sleep 2
perf stat -x, -e cycles,cpu/cycles-ct/,cpu/cycles-t/ sleep 2
perf stat -x, -e instructions,cpu/tx-start/ sleep 2
perf stat -x, -e '{cycles,tx-start}' sleep 2
perf stat -x, -e '{cycles,cpu/tx-start/}' sleep 2
# HW Cache event + kernel pmu event with different style
perf stat -x, -e L1-dcache-loads,cpu/mem-stores/,tx-start sleep 2
perf stat -x, -e L1-dcache-loads,mem-stores,cpu/tx-start/ sleep 2
perf stat -x, -e '{L1-dcache-loads,mem-stores}' sleep 2
perf stat -x, -e '{L1-dcache-loads,cpu/tx-start/}' sleep 2
# Raw event + kernel pmu event with different style:
perf stat -x, -e cpu/event=0xc0,umask=0x00/,mem-loads,cpu/mem-stores/ sleep 2
perf stat -x, -e cpu/event=0xc0,umask=0x00/,tx-start,cpu/el-start/ sleep 2
perf stat -x, -e '{cpu/event=0xc0,umask=0x00/,tx-start}' sleep 2
Signed-off-by: Kan Liang <kan.liang@intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1412694532-23391-5-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-10-07 23:08:52 +08:00
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
perf test: Add test case for pmu event new style format
Add test case in automated tests suite. It checks not only the two types
of pmu event stytle formats "pmu_event_name" and "cpu/pmu_event_name/",
but also the different formats mixtures which are more likely to trigger
parse issue.
The patch set including this one has been tested by the perf automated
test:
./perf test parse -v"
On haswell, ivybridge and Romley platform.
The patch set also has been tested on haswell by the following script.
Note: please make sure that your test system support TSX and
L1-dcache-loads events. Otherwise, you may want to change the events to
other pmu events.
[lk@localhost ~]$ cat perf_style_test.sh
# hardware events + kernel pmu event with different style
perf stat -x, -e cycles,mem-stores,tx-start sleep 2
perf stat -x, -e cpu-cycles,cycles-ct,cycles-t sleep 2
perf stat -x, -e cycles,cpu/cycles-ct/,cpu/cycles-t/ sleep 2
perf stat -x, -e instructions,cpu/tx-start/ sleep 2
perf stat -x, -e '{cycles,tx-start}' sleep 2
perf stat -x, -e '{cycles,cpu/tx-start/}' sleep 2
# HW Cache event + kernel pmu event with different style
perf stat -x, -e L1-dcache-loads,cpu/mem-stores/,tx-start sleep 2
perf stat -x, -e L1-dcache-loads,mem-stores,cpu/tx-start/ sleep 2
perf stat -x, -e '{L1-dcache-loads,mem-stores}' sleep 2
perf stat -x, -e '{L1-dcache-loads,cpu/tx-start/}' sleep 2
# Raw event + kernel pmu event with different style:
perf stat -x, -e cpu/event=0xc0,umask=0x00/,mem-loads,cpu/mem-stores/ sleep 2
perf stat -x, -e cpu/event=0xc0,umask=0x00/,tx-start,cpu/el-start/ sleep 2
perf stat -x, -e '{cpu/event=0xc0,umask=0x00/,tx-start}' sleep 2
Signed-off-by: Kan Liang <kan.liang@intel.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/1412694532-23391-5-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2014-10-07 23:08:52 +08:00
|
|
|
}
|
|
|
|
|
2012-06-15 14:31:42 +08:00
|
|
|
static int test__checkterms_simple(struct list_head *terms)
|
|
|
|
{
|
2013-01-19 03:29:49 +08:00
|
|
|
struct parse_events_term *term;
|
2012-06-15 14:31:42 +08:00
|
|
|
|
|
|
|
/* config=10 */
|
2013-01-19 03:29:49 +08:00
|
|
|
term = list_entry(terms->next, struct parse_events_term, list);
|
2012-06-15 14:31:42 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type term",
|
|
|
|
term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG);
|
|
|
|
TEST_ASSERT_VAL("wrong type val",
|
|
|
|
term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
|
|
|
|
TEST_ASSERT_VAL("wrong val", term->val.num == 10);
|
2021-09-16 20:34:21 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config"));
|
2012-06-15 14:31:42 +08:00
|
|
|
|
|
|
|
/* config1 */
|
2013-01-19 03:29:49 +08:00
|
|
|
term = list_entry(term->list.next, struct parse_events_term, list);
|
2012-06-15 14:31:42 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type term",
|
|
|
|
term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG1);
|
|
|
|
TEST_ASSERT_VAL("wrong type val",
|
|
|
|
term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
|
|
|
|
TEST_ASSERT_VAL("wrong val", term->val.num == 1);
|
2021-09-16 20:34:21 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config1"));
|
2012-06-15 14:31:42 +08:00
|
|
|
|
|
|
|
/* config2=3 */
|
2013-01-19 03:29:49 +08:00
|
|
|
term = list_entry(term->list.next, struct parse_events_term, list);
|
2012-06-15 14:31:42 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type term",
|
|
|
|
term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG2);
|
|
|
|
TEST_ASSERT_VAL("wrong type val",
|
|
|
|
term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
|
|
|
|
TEST_ASSERT_VAL("wrong val", term->val.num == 3);
|
2021-09-16 20:34:21 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config2"));
|
2012-06-15 14:31:42 +08:00
|
|
|
|
2023-02-18 06:32:11 +08:00
|
|
|
/* config3=4 */
|
|
|
|
term = list_entry(term->list.next, struct parse_events_term, list);
|
|
|
|
TEST_ASSERT_VAL("wrong type term",
|
|
|
|
term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG3);
|
|
|
|
TEST_ASSERT_VAL("wrong type val",
|
|
|
|
term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
|
|
|
|
TEST_ASSERT_VAL("wrong val", term->val.num == 4);
|
|
|
|
TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config3"));
|
|
|
|
|
2012-06-15 14:31:42 +08:00
|
|
|
/* umask=1*/
|
2013-01-19 03:29:49 +08:00
|
|
|
term = list_entry(term->list.next, struct parse_events_term, list);
|
2012-06-15 14:31:42 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type term",
|
|
|
|
term->type_term == PARSE_EVENTS__TERM_TYPE_USER);
|
|
|
|
TEST_ASSERT_VAL("wrong type val",
|
|
|
|
term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
|
|
|
|
TEST_ASSERT_VAL("wrong val", term->val.num == 1);
|
|
|
|
TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "umask"));
|
|
|
|
|
2020-07-26 15:52:44 +08:00
|
|
|
/*
|
|
|
|
* read
|
|
|
|
*
|
|
|
|
* The perf_pmu__test_parse_init injects 'read' term into
|
|
|
|
* perf_pmu_events_list, so 'read' is evaluated as read term
|
|
|
|
* and not as raw event with 'ead' hex value.
|
|
|
|
*/
|
|
|
|
term = list_entry(term->list.next, struct parse_events_term, list);
|
|
|
|
TEST_ASSERT_VAL("wrong type term",
|
2023-05-03 06:38:25 +08:00
|
|
|
term->type_term == PARSE_EVENTS__TERM_TYPE_RAW);
|
2020-07-26 15:52:44 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type val",
|
2023-05-03 06:38:25 +08:00
|
|
|
term->type_val == PARSE_EVENTS__TERM_TYPE_STR);
|
|
|
|
TEST_ASSERT_VAL("wrong val", !strcmp(term->val.str, "read"));
|
|
|
|
TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "raw"));
|
2020-07-26 15:52:44 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* r0xead
|
|
|
|
*
|
|
|
|
* To be still able to pass 'ead' value with 'r' syntax,
|
|
|
|
* we added support to parse 'r0xHEX' event.
|
|
|
|
*/
|
|
|
|
term = list_entry(term->list.next, struct parse_events_term, list);
|
|
|
|
TEST_ASSERT_VAL("wrong type term",
|
2023-05-03 06:38:25 +08:00
|
|
|
term->type_term == PARSE_EVENTS__TERM_TYPE_RAW);
|
2020-07-26 15:52:44 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type val",
|
2023-05-03 06:38:25 +08:00
|
|
|
term->type_val == PARSE_EVENTS__TERM_TYPE_STR);
|
|
|
|
TEST_ASSERT_VAL("wrong val", !strcmp(term->val.str, "r0xead"));
|
|
|
|
TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "raw"));
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-06-15 14:31:42 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__group1(struct evlist *evlist)
|
2012-08-08 18:23:52 +08:00
|
|
|
{
|
2019-07-21 19:23:51 +08:00
|
|
|
struct evsel *evsel, *leader;
|
2012-08-08 18:23:52 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == (num_core_entries() * 2));
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist__nr_groups(evlist) == num_core_entries());
|
2023-06-01 16:29:54 +08:00
|
|
|
|
2023-07-05 16:26:52 +08:00
|
|
|
for (int i = 0; i < num_core_entries(); i++) {
|
2023-06-01 16:29:54 +08:00
|
|
|
/* instructions:k */
|
|
|
|
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cycles:upp */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
/* use of precise requires exclude_guest */
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-08-08 18:23:52 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__group2(struct evlist *evlist)
|
2012-08-08 18:23:52 +08:00
|
|
|
{
|
2023-06-01 16:29:54 +08:00
|
|
|
struct evsel *evsel, *leader = NULL;
|
2012-08-08 18:23:52 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == (2 * num_core_entries() + 1));
|
2023-06-01 16:29:54 +08:00
|
|
|
/*
|
|
|
|
* TODO: Currently the software event won't be grouped with the hardware
|
|
|
|
* event except for 1 PMU.
|
|
|
|
*/
|
2023-03-12 10:15:42 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 1 == evlist__nr_groups(evlist));
|
2012-08-08 18:23:52 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
evlist__for_each_entry(evlist, evsel) {
|
|
|
|
if (evsel->core.attr.type == PERF_TYPE_SOFTWARE) {
|
|
|
|
/* faults + :ku modifier */
|
|
|
|
leader = evsel;
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
test_config(evsel, PERF_COUNT_SW_PAGE_FAULTS));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (evsel->core.attr.type == PERF_TYPE_HARDWARE &&
|
|
|
|
test_config(evsel, PERF_COUNT_HW_CACHE_REFERENCES)) {
|
|
|
|
/* cache-references + :u modifier */
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
if (evsel__has_leader(evsel, leader))
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* cycles:k */
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-08-08 18:23:52 +08:00
|
|
|
}
|
|
|
|
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#ifdef HAVE_LIBTRACEEVENT
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__group3(struct evlist *evlist __maybe_unused)
|
2012-08-08 18:23:52 +08:00
|
|
|
{
|
2023-06-01 16:29:54 +08:00
|
|
|
struct evsel *evsel, *group1_leader = NULL, *group2_leader = NULL;
|
2012-08-08 18:23:52 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
|
|
|
evlist->core.nr_entries == (3 * perf_pmus__num_core_pmus() + 2));
|
|
|
|
/*
|
|
|
|
* Currently the software event won't be grouped with the hardware event
|
|
|
|
* except for 1 PMU. This means there are always just 2 groups
|
|
|
|
* regardless of the number of core PMUs.
|
|
|
|
*/
|
2023-03-12 10:15:42 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 2 == evlist__nr_groups(evlist));
|
2012-08-08 18:23:52 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
evlist__for_each_entry(evlist, evsel) {
|
|
|
|
if (evsel->core.attr.type == PERF_TYPE_TRACEPOINT) {
|
|
|
|
/* group1 syscalls:sys_enter_openat:H */
|
|
|
|
group1_leader = evsel;
|
|
|
|
TEST_ASSERT_VAL("wrong sample_type",
|
|
|
|
evsel->core.attr.sample_type == PERF_TP_SAMPLE_TYPE);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->core.attr.sample_period);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !strcmp(evsel->group_name, "group1"));
|
|
|
|
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (evsel->core.attr.type == PERF_TYPE_HARDWARE &&
|
|
|
|
test_config(evsel, PERF_COUNT_HW_CPU_CYCLES)) {
|
|
|
|
if (evsel->core.attr.exclude_user) {
|
|
|
|
/* group1 cycles:kppp */
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user",
|
|
|
|
evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel",
|
|
|
|
!evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
/* use of precise requires exclude_guest */
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest",
|
|
|
|
evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host",
|
|
|
|
!evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip",
|
|
|
|
evsel->core.attr.precise_ip == 3);
|
|
|
|
if (evsel__has_leader(evsel, group1_leader)) {
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx",
|
|
|
|
evsel__group_idx(evsel) == 1);
|
|
|
|
}
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
|
|
|
} else {
|
|
|
|
/* group2 cycles + G modifier */
|
|
|
|
group2_leader = evsel;
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel",
|
|
|
|
!evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv",
|
|
|
|
!evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest",
|
|
|
|
!evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host",
|
|
|
|
evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
|
|
|
if (evsel->core.nr_members == 2) {
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx",
|
|
|
|
evsel__group_idx(evsel) == 0);
|
|
|
|
}
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (evsel->core.attr.type == 1) {
|
|
|
|
/* group2 1:3 + G modifier */
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 3));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
if (evsel__has_leader(evsel, group2_leader))
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* instructions:u */
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-08-08 18:23:52 +08:00
|
|
|
}
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#endif
|
2012-08-08 18:23:52 +08:00
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__group4(struct evlist *evlist __maybe_unused)
|
2012-08-08 18:23:52 +08:00
|
|
|
{
|
2019-07-21 19:23:51 +08:00
|
|
|
struct evsel *evsel, *leader;
|
2012-08-08 18:23:52 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == (num_core_entries() * 2));
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups",
|
2023-07-05 16:26:52 +08:00
|
|
|
num_core_entries() == evlist__nr_groups(evlist));
|
2012-08-08 18:23:52 +08:00
|
|
|
|
2023-07-05 16:26:52 +08:00
|
|
|
for (int i = 0; i < num_core_entries(); i++) {
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cycles:u + p */
|
|
|
|
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
/* use of precise requires exclude_guest */
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 1);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
|
|
|
|
|
|
|
/* instructions:kp + p */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
/* use of precise requires exclude_guest */
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-08-08 18:23:52 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__group5(struct evlist *evlist __maybe_unused)
|
2012-08-08 18:23:52 +08:00
|
|
|
{
|
2023-06-01 16:29:54 +08:00
|
|
|
struct evsel *evsel = NULL, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == (5 * num_core_entries()));
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist__nr_groups(evlist) == (2 * num_core_entries()));
|
2023-06-01 16:29:54 +08:00
|
|
|
|
2023-07-05 16:26:52 +08:00
|
|
|
for (int i = 0; i < num_core_entries(); i++) {
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cycles + G */
|
|
|
|
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
/* instructions + G */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
|
|
|
}
|
2023-07-05 16:26:52 +08:00
|
|
|
for (int i = 0; i < num_core_entries(); i++) {
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cycles:G */
|
|
|
|
evsel = leader = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
/* instructions:G */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
|
|
|
|
}
|
2023-07-05 16:26:52 +08:00
|
|
|
for (int i = 0; i < num_core_entries(); i++) {
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cycles */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2012-08-08 18:23:52 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__group_gh1(struct evlist *evlist)
|
2013-02-04 17:56:43 +08:00
|
|
|
{
|
2023-06-01 16:29:54 +08:00
|
|
|
struct evsel *evsel = NULL, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == (2 * num_core_entries()));
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist__nr_groups(evlist) == num_core_entries());
|
2023-06-01 16:29:54 +08:00
|
|
|
|
2023-07-05 16:26:52 +08:00
|
|
|
for (int i = 0; i < num_core_entries(); i++) {
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cycles + :H group modifier */
|
|
|
|
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
|
2013-02-04 17:56:43 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cache-misses:G + :H group modifier */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2013-02-04 17:56:43 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__group_gh2(struct evlist *evlist)
|
2013-02-04 17:56:43 +08:00
|
|
|
{
|
2023-06-01 16:29:54 +08:00
|
|
|
struct evsel *evsel = NULL, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == (2 * num_core_entries()));
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist__nr_groups(evlist) == num_core_entries());
|
2023-06-01 16:29:54 +08:00
|
|
|
|
2023-07-05 16:26:52 +08:00
|
|
|
for (int i = 0; i < num_core_entries(); i++) {
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cycles + :G group modifier */
|
|
|
|
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
|
2013-02-04 17:56:43 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cache-misses:H + :G group modifier */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2013-02-04 17:56:43 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__group_gh3(struct evlist *evlist)
|
2013-02-04 17:56:43 +08:00
|
|
|
{
|
2023-06-01 16:29:54 +08:00
|
|
|
struct evsel *evsel = NULL, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == (2 * num_core_entries()));
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist__nr_groups(evlist) == num_core_entries());
|
2023-06-01 16:29:54 +08:00
|
|
|
|
2023-07-05 16:26:52 +08:00
|
|
|
for (int i = 0; i < num_core_entries(); i++) {
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cycles:G + :u group modifier */
|
|
|
|
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
|
2013-02-04 17:56:43 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cache-misses:H + :u group modifier */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2013-02-04 17:56:43 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__group_gh4(struct evlist *evlist)
|
2013-02-04 17:56:43 +08:00
|
|
|
{
|
2023-06-01 16:29:54 +08:00
|
|
|
struct evsel *evsel = NULL, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == (2 * num_core_entries()));
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist__nr_groups(evlist) == num_core_entries());
|
2023-06-01 16:29:54 +08:00
|
|
|
|
2023-07-05 16:26:52 +08:00
|
|
|
for (int i = 0; i < num_core_entries(); i++) {
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cycles:G + :uG group modifier */
|
|
|
|
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
|
2013-02-04 17:56:43 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cache-misses:H + :uG group modifier */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2013-02-04 17:56:43 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__leader_sample1(struct evlist *evlist)
|
2013-02-02 03:37:11 +08:00
|
|
|
{
|
2023-06-01 16:29:54 +08:00
|
|
|
struct evsel *evsel = NULL, *leader;
|
2013-02-02 03:37:11 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == (3 * num_core_entries()));
|
2013-02-02 03:37:11 +08:00
|
|
|
|
2023-07-05 16:26:52 +08:00
|
|
|
for (int i = 0; i < num_core_entries(); i++) {
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cycles - sampling group leader */
|
|
|
|
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
|
2013-02-02 03:37:11 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cache-misses - not sampling */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
|
2013-02-02 03:37:11 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
/* branch-misses - not sampling */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_BRANCH_MISSES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2013-02-02 03:37:11 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__leader_sample2(struct evlist *evlist __maybe_unused)
|
2013-02-02 03:37:11 +08:00
|
|
|
{
|
2023-06-01 16:29:54 +08:00
|
|
|
struct evsel *evsel = NULL, *leader;
|
2013-02-02 03:37:11 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == (2 * num_core_entries()));
|
2013-02-02 03:37:11 +08:00
|
|
|
|
2023-07-05 16:26:52 +08:00
|
|
|
for (int i = 0; i < num_core_entries(); i++) {
|
2023-06-01 16:29:54 +08:00
|
|
|
/* instructions - sampling group leader */
|
|
|
|
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
|
2013-02-02 03:37:11 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
/* branch-misses - not sampling */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_BRANCH_MISSES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2013-02-02 03:37:11 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_pinned_modifier(struct evlist *evlist)
|
2013-08-06 21:28:06 +08:00
|
|
|
{
|
2023-06-01 16:29:54 +08:00
|
|
|
struct evsel *evsel = NULL;
|
2013-08-06 21:28:06 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == num_core_entries());
|
2013-08-06 21:28:06 +08:00
|
|
|
|
2023-07-05 16:26:52 +08:00
|
|
|
for (int i = 0; i < num_core_entries(); i++) {
|
2023-06-01 16:29:54 +08:00
|
|
|
evsel = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong pinned", evsel->core.attr.pinned);
|
|
|
|
}
|
2013-08-06 21:28:06 +08:00
|
|
|
return test__checkevent_symbolic_name(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__pinned_group(struct evlist *evlist)
|
2013-08-06 21:28:06 +08:00
|
|
|
{
|
2023-06-01 16:29:54 +08:00
|
|
|
struct evsel *evsel = NULL, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == (3 * num_core_entries()));
|
2023-06-01 16:29:54 +08:00
|
|
|
|
2023-07-05 16:26:52 +08:00
|
|
|
for (int i = 0; i < num_core_entries(); i++) {
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cycles - group leader */
|
|
|
|
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
/* TODO: The group modifier is not copied to the split group leader. */
|
|
|
|
if (perf_pmus__num_core_pmus() == 1)
|
|
|
|
TEST_ASSERT_VAL("wrong pinned", evsel->core.attr.pinned);
|
|
|
|
|
|
|
|
/* cache-misses - can not be pinned, but will go on with the leader */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES));
|
|
|
|
TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
|
2013-08-06 21:28:06 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
/* branch-misses - ditto */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_BRANCH_MISSES));
|
|
|
|
TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2013-08-06 21:28:06 +08:00
|
|
|
}
|
|
|
|
|
perf tools: Add support for exclusive groups/events
Peter suggested that using the exclusive mode in perf could avoid some
problems with bad scheduling of groups. Exclusive is implemented in the
kernel, but wasn't exposed by the perf tool, so hard to use without
custom low level API users.
Add support for marking groups or events with :e for exclusive in the
perf tool. The implementation is basically the same as the existing
pinned attribute.
Committer testing:
# perf test "parse event"
6: Parse event definition strings : Ok
# perf test -v "parse event" |& grep :u*e
running test 56 'instructions:uep'
running test 57 '{cycles,cache-misses,branch-misses}:e'
#
#
# grep "model name" -m1 /proc/cpuinfo
model name : AMD Ryzen 9 3900X 12-Core Processor
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
<not counted> cycles (0.00%)
<not counted> cache-misses (0.00%)
<not counted> branch-misses (0.00%)
1.001269893 seconds time elapsed
Some events weren't counted. Try disabling the NMI watchdog:
echo 0 > /proc/sys/kernel/nmi_watchdog
perf stat ...
echo 1 > /proc/sys/kernel/nmi_watchdog
# echo 0 > /proc/sys/kernel/nmi_watchdog
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
1,298,663,141 cycles
30,962,215 cache-misses
5,325,150 branch-misses
1.001474934 seconds time elapsed
#
# The output for asking for precise events on AMD needs to improve, it
# supposedly works only for system wide or per CPU
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:uep' sleep 1
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles).
/bin/dmesg | grep -i perf may provide additional information.
# perf stat -a -e '{cycles,cache-misses,branch-misses}:ue' sleep 1
Performance counter stats for 'system wide':
746,363,126 cycles
16,881,611 cache-misses
2,871,259 branch-misses
1.001636066 seconds time elapsed
#
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20201014144255.22699-1-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-10-14 22:42:55 +08:00
|
|
|
static int test__checkevent_exclusive_modifier(struct evlist *evlist)
|
|
|
|
{
|
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong exclusive", evsel->core.attr.exclusive);
|
|
|
|
|
|
|
|
return test__checkevent_symbolic_name(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__exclusive_group(struct evlist *evlist)
|
|
|
|
{
|
2023-06-01 16:29:54 +08:00
|
|
|
struct evsel *evsel = NULL, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == 3 * num_core_entries());
|
2023-06-01 16:29:54 +08:00
|
|
|
|
2023-07-05 16:26:52 +08:00
|
|
|
for (int i = 0; i < num_core_entries(); i++) {
|
2023-06-01 16:29:54 +08:00
|
|
|
/* cycles - group leader */
|
|
|
|
evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
|
|
|
|
/* TODO: The group modifier is not copied to the split group leader. */
|
|
|
|
if (perf_pmus__num_core_pmus() == 1)
|
|
|
|
TEST_ASSERT_VAL("wrong exclusive", evsel->core.attr.exclusive);
|
|
|
|
|
|
|
|
/* cache-misses - can not be pinned, but will go on with the leader */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);
|
perf tools: Add support for exclusive groups/events
Peter suggested that using the exclusive mode in perf could avoid some
problems with bad scheduling of groups. Exclusive is implemented in the
kernel, but wasn't exposed by the perf tool, so hard to use without
custom low level API users.
Add support for marking groups or events with :e for exclusive in the
perf tool. The implementation is basically the same as the existing
pinned attribute.
Committer testing:
# perf test "parse event"
6: Parse event definition strings : Ok
# perf test -v "parse event" |& grep :u*e
running test 56 'instructions:uep'
running test 57 '{cycles,cache-misses,branch-misses}:e'
#
#
# grep "model name" -m1 /proc/cpuinfo
model name : AMD Ryzen 9 3900X 12-Core Processor
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
<not counted> cycles (0.00%)
<not counted> cache-misses (0.00%)
<not counted> branch-misses (0.00%)
1.001269893 seconds time elapsed
Some events weren't counted. Try disabling the NMI watchdog:
echo 0 > /proc/sys/kernel/nmi_watchdog
perf stat ...
echo 1 > /proc/sys/kernel/nmi_watchdog
# echo 0 > /proc/sys/kernel/nmi_watchdog
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
1,298,663,141 cycles
30,962,215 cache-misses
5,325,150 branch-misses
1.001474934 seconds time elapsed
#
# The output for asking for precise events on AMD needs to improve, it
# supposedly works only for system wide or per CPU
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:uep' sleep 1
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles).
/bin/dmesg | grep -i perf may provide additional information.
# perf stat -a -e '{cycles,cache-misses,branch-misses}:ue' sleep 1
Performance counter stats for 'system wide':
746,363,126 cycles
16,881,611 cache-misses
2,871,259 branch-misses
1.001636066 seconds time elapsed
#
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20201014144255.22699-1-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-10-14 22:42:55 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
/* branch-misses - ditto */
|
|
|
|
evsel = evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_BRANCH_MISSES));
|
|
|
|
TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
perf tools: Add support for exclusive groups/events
Peter suggested that using the exclusive mode in perf could avoid some
problems with bad scheduling of groups. Exclusive is implemented in the
kernel, but wasn't exposed by the perf tool, so hard to use without
custom low level API users.
Add support for marking groups or events with :e for exclusive in the
perf tool. The implementation is basically the same as the existing
pinned attribute.
Committer testing:
# perf test "parse event"
6: Parse event definition strings : Ok
# perf test -v "parse event" |& grep :u*e
running test 56 'instructions:uep'
running test 57 '{cycles,cache-misses,branch-misses}:e'
#
#
# grep "model name" -m1 /proc/cpuinfo
model name : AMD Ryzen 9 3900X 12-Core Processor
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
<not counted> cycles (0.00%)
<not counted> cache-misses (0.00%)
<not counted> branch-misses (0.00%)
1.001269893 seconds time elapsed
Some events weren't counted. Try disabling the NMI watchdog:
echo 0 > /proc/sys/kernel/nmi_watchdog
perf stat ...
echo 1 > /proc/sys/kernel/nmi_watchdog
# echo 0 > /proc/sys/kernel/nmi_watchdog
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
1,298,663,141 cycles
30,962,215 cache-misses
5,325,150 branch-misses
1.001474934 seconds time elapsed
#
# The output for asking for precise events on AMD needs to improve, it
# supposedly works only for system wide or per CPU
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:uep' sleep 1
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles).
/bin/dmesg | grep -i perf may provide additional information.
# perf stat -a -e '{cycles,cache-misses,branch-misses}:ue' sleep 1
Performance counter stats for 'system wide':
746,363,126 cycles
16,881,611 cache-misses
2,871,259 branch-misses
1.001636066 seconds time elapsed
#
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20201014144255.22699-1-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-10-14 22:42:55 +08:00
|
|
|
}
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_breakpoint_len(struct evlist *evlist)
|
2014-05-29 23:26:52 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2014-05-29 23:26:52 +08:00
|
|
|
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 0));
|
2014-05-29 23:26:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
|
2019-07-21 19:24:29 +08:00
|
|
|
evsel->core.attr.bp_type);
|
2014-05-29 23:26:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_1 ==
|
2019-07-21 19:24:29 +08:00
|
|
|
evsel->core.attr.bp_len);
|
2014-05-29 23:26:52 +08:00
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2014-05-29 23:26:52 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_breakpoint_len_w(struct evlist *evlist)
|
2014-05-29 23:26:52 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2014-05-29 23:26:52 +08:00
|
|
|
|
2019-07-21 19:24:28 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 0));
|
2014-05-29 23:26:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_W ==
|
2019-07-21 19:24:29 +08:00
|
|
|
evsel->core.attr.bp_type);
|
2014-05-29 23:26:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_2 ==
|
2019-07-21 19:24:29 +08:00
|
|
|
evsel->core.attr.bp_len);
|
2014-05-29 23:26:52 +08:00
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2014-05-29 23:26:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2019-07-21 19:23:52 +08:00
|
|
|
test__checkevent_breakpoint_len_rw_modifier(struct evlist *evlist)
|
2014-05-29 23:26:52 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2014-05-29 23:26:52 +08:00
|
|
|
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip);
|
2014-05-29 23:26:52 +08:00
|
|
|
|
|
|
|
return test__checkevent_breakpoint_rw(evlist);
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_precise_max_modifier(struct evlist *evlist)
|
2015-10-06 02:06:06 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2015-10-06 02:06:06 +08:00
|
|
|
|
2023-06-01 16:29:54 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries",
|
2023-07-05 16:26:52 +08:00
|
|
|
evlist->core.nr_entries == 1 + num_core_entries());
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_SW_TASK_CLOCK));
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2015-10-06 02:06:06 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_config_symbol(struct evlist *evlist)
|
perf tools: Enable config raw and numeric events
This patch allows setting config terms for raw and numeric events.
For example:
# perf stat -e cycles/name=cyc/ ls
...
1821108 cyc
...
# perf stat -e r6530160/name=event/ ls
...
1103195 event
...
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
...
# perf report --stdio
...
# Samples: 124 of event 'cycles'
46.61% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
41.26% 0.00% swapper [kernel.vmlinux] [k] start_secondary
...
# Samples: 91 of event 'evtx'
...
93.76% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--66.63%--call_cpuidle
| cpuidle_enter
| |
...
3 test cases are introduced to test config terms for symbol, raw and
numeric events.
Committer note:
Further testing shows that we can retrieve the event name using 'perf
evlist -v' and looking at the 'config' perf_event_attr field, i.e.:
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.724 MB perf.data (2076 samples) ]
# perf evlist
cycles
evtx
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
evtx: type: 4, size: 112, config: 0x6530160, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-19 19:44:00 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
perf tools: Enable config raw and numeric events
This patch allows setting config terms for raw and numeric events.
For example:
# perf stat -e cycles/name=cyc/ ls
...
1821108 cyc
...
# perf stat -e r6530160/name=event/ ls
...
1103195 event
...
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
...
# perf report --stdio
...
# Samples: 124 of event 'cycles'
46.61% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
41.26% 0.00% swapper [kernel.vmlinux] [k] start_secondary
...
# Samples: 91 of event 'evtx'
...
93.76% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--66.63%--call_cpuidle
| cpuidle_enter
| |
...
3 test cases are introduced to test config terms for symbol, raw and
numeric events.
Committer note:
Further testing shows that we can retrieve the event name using 'perf
evlist -v' and looking at the 'config' perf_event_attr field, i.e.:
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.724 MB perf.data (2076 samples) ]
# perf evlist
cycles
evtx
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
evtx: type: 4, size: 112, config: 0x6530160, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-19 19:44:00 +08:00
|
|
|
|
2023-04-21 02:54:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "insn"));
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
perf tools: Enable config raw and numeric events
This patch allows setting config terms for raw and numeric events.
For example:
# perf stat -e cycles/name=cyc/ ls
...
1821108 cyc
...
# perf stat -e r6530160/name=event/ ls
...
1103195 event
...
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
...
# perf report --stdio
...
# Samples: 124 of event 'cycles'
46.61% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
41.26% 0.00% swapper [kernel.vmlinux] [k] start_secondary
...
# Samples: 91 of event 'evtx'
...
93.76% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--66.63%--call_cpuidle
| cpuidle_enter
| |
...
3 test cases are introduced to test config terms for symbol, raw and
numeric events.
Committer note:
Further testing shows that we can retrieve the event name using 'perf
evlist -v' and looking at the 'config' perf_event_attr field, i.e.:
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.724 MB perf.data (2076 samples) ]
# perf evlist
cycles
evtx
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
evtx: type: 4, size: 112, config: 0x6530160, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-19 19:44:00 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_config_raw(struct evlist *evlist)
|
perf tools: Enable config raw and numeric events
This patch allows setting config terms for raw and numeric events.
For example:
# perf stat -e cycles/name=cyc/ ls
...
1821108 cyc
...
# perf stat -e r6530160/name=event/ ls
...
1103195 event
...
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
...
# perf report --stdio
...
# Samples: 124 of event 'cycles'
46.61% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
41.26% 0.00% swapper [kernel.vmlinux] [k] start_secondary
...
# Samples: 91 of event 'evtx'
...
93.76% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--66.63%--call_cpuidle
| cpuidle_enter
| |
...
3 test cases are introduced to test config terms for symbol, raw and
numeric events.
Committer note:
Further testing shows that we can retrieve the event name using 'perf
evlist -v' and looking at the 'config' perf_event_attr field, i.e.:
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.724 MB perf.data (2076 samples) ]
# perf evlist
cycles
evtx
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
evtx: type: 4, size: 112, config: 0x6530160, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-19 19:44:00 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
perf tools: Enable config raw and numeric events
This patch allows setting config terms for raw and numeric events.
For example:
# perf stat -e cycles/name=cyc/ ls
...
1821108 cyc
...
# perf stat -e r6530160/name=event/ ls
...
1103195 event
...
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
...
# perf report --stdio
...
# Samples: 124 of event 'cycles'
46.61% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
41.26% 0.00% swapper [kernel.vmlinux] [k] start_secondary
...
# Samples: 91 of event 'evtx'
...
93.76% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--66.63%--call_cpuidle
| cpuidle_enter
| |
...
3 test cases are introduced to test config terms for symbol, raw and
numeric events.
Committer note:
Further testing shows that we can retrieve the event name using 'perf
evlist -v' and looking at the 'config' perf_event_attr field, i.e.:
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.724 MB perf.data (2076 samples) ]
# perf evlist
cycles
evtx
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
evtx: type: 4, size: 112, config: 0x6530160, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-19 19:44:00 +08:00
|
|
|
|
2023-04-21 02:54:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "rawpmu"));
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
perf tools: Enable config raw and numeric events
This patch allows setting config terms for raw and numeric events.
For example:
# perf stat -e cycles/name=cyc/ ls
...
1821108 cyc
...
# perf stat -e r6530160/name=event/ ls
...
1103195 event
...
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
...
# perf report --stdio
...
# Samples: 124 of event 'cycles'
46.61% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
41.26% 0.00% swapper [kernel.vmlinux] [k] start_secondary
...
# Samples: 91 of event 'evtx'
...
93.76% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--66.63%--call_cpuidle
| cpuidle_enter
| |
...
3 test cases are introduced to test config terms for symbol, raw and
numeric events.
Committer note:
Further testing shows that we can retrieve the event name using 'perf
evlist -v' and looking at the 'config' perf_event_attr field, i.e.:
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.724 MB perf.data (2076 samples) ]
# perf evlist
cycles
evtx
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
evtx: type: 4, size: 112, config: 0x6530160, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-19 19:44:00 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_config_num(struct evlist *evlist)
|
perf tools: Enable config raw and numeric events
This patch allows setting config terms for raw and numeric events.
For example:
# perf stat -e cycles/name=cyc/ ls
...
1821108 cyc
...
# perf stat -e r6530160/name=event/ ls
...
1103195 event
...
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
...
# perf report --stdio
...
# Samples: 124 of event 'cycles'
46.61% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
41.26% 0.00% swapper [kernel.vmlinux] [k] start_secondary
...
# Samples: 91 of event 'evtx'
...
93.76% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--66.63%--call_cpuidle
| cpuidle_enter
| |
...
3 test cases are introduced to test config terms for symbol, raw and
numeric events.
Committer note:
Further testing shows that we can retrieve the event name using 'perf
evlist -v' and looking at the 'config' perf_event_attr field, i.e.:
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.724 MB perf.data (2076 samples) ]
# perf evlist
cycles
evtx
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
evtx: type: 4, size: 112, config: 0x6530160, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-19 19:44:00 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
perf tools: Enable config raw and numeric events
This patch allows setting config terms for raw and numeric events.
For example:
# perf stat -e cycles/name=cyc/ ls
...
1821108 cyc
...
# perf stat -e r6530160/name=event/ ls
...
1103195 event
...
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
...
# perf report --stdio
...
# Samples: 124 of event 'cycles'
46.61% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
41.26% 0.00% swapper [kernel.vmlinux] [k] start_secondary
...
# Samples: 91 of event 'evtx'
...
93.76% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--66.63%--call_cpuidle
| cpuidle_enter
| |
...
3 test cases are introduced to test config terms for symbol, raw and
numeric events.
Committer note:
Further testing shows that we can retrieve the event name using 'perf
evlist -v' and looking at the 'config' perf_event_attr field, i.e.:
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.724 MB perf.data (2076 samples) ]
# perf evlist
cycles
evtx
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
evtx: type: 4, size: 112, config: 0x6530160, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-19 19:44:00 +08:00
|
|
|
|
2023-04-21 02:54:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "numpmu"));
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
perf tools: Enable config raw and numeric events
This patch allows setting config terms for raw and numeric events.
For example:
# perf stat -e cycles/name=cyc/ ls
...
1821108 cyc
...
# perf stat -e r6530160/name=event/ ls
...
1103195 event
...
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
...
# perf report --stdio
...
# Samples: 124 of event 'cycles'
46.61% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
41.26% 0.00% swapper [kernel.vmlinux] [k] start_secondary
...
# Samples: 91 of event 'evtx'
...
93.76% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--66.63%--call_cpuidle
| cpuidle_enter
| |
...
3 test cases are introduced to test config terms for symbol, raw and
numeric events.
Committer note:
Further testing shows that we can retrieve the event name using 'perf
evlist -v' and looking at the 'config' perf_event_attr field, i.e.:
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.724 MB perf.data (2076 samples) ]
# perf evlist
cycles
evtx
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
evtx: type: 4, size: 112, config: 0x6530160, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-19 19:44:00 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_config_cache(struct evlist *evlist)
|
2016-02-19 19:44:01 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2016-02-19 19:44:01 +08:00
|
|
|
|
2023-04-21 02:54:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "cachepmu"));
|
2023-05-03 06:38:20 +08:00
|
|
|
return test__checkevent_genhw(evlist);
|
2016-02-19 19:44:01 +08:00
|
|
|
}
|
perf tools: Enable config raw and numeric events
This patch allows setting config terms for raw and numeric events.
For example:
# perf stat -e cycles/name=cyc/ ls
...
1821108 cyc
...
# perf stat -e r6530160/name=event/ ls
...
1103195 event
...
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
...
# perf report --stdio
...
# Samples: 124 of event 'cycles'
46.61% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
41.26% 0.00% swapper [kernel.vmlinux] [k] start_secondary
...
# Samples: 91 of event 'evtx'
...
93.76% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--66.63%--call_cpuidle
| cpuidle_enter
| |
...
3 test cases are introduced to test config terms for symbol, raw and
numeric events.
Committer note:
Further testing shows that we can retrieve the event name using 'perf
evlist -v' and looking at the 'config' perf_event_attr field, i.e.:
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.724 MB perf.data (2076 samples) ]
# perf evlist
cycles
evtx
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
evtx: type: 4, size: 112, config: 0x6530160, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-19 19:44:00 +08:00
|
|
|
|
2023-05-03 06:38:18 +08:00
|
|
|
static bool test__pmu_cpu_valid(void)
|
|
|
|
{
|
2023-05-27 15:22:03 +08:00
|
|
|
return !!perf_pmus__find("cpu");
|
2023-05-03 06:38:18 +08:00
|
|
|
}
|
|
|
|
|
2023-07-07 02:37:05 +08:00
|
|
|
static bool test__pmu_cpu_event_valid(void)
|
|
|
|
{
|
|
|
|
struct perf_pmu *pmu = perf_pmus__find("cpu");
|
|
|
|
|
|
|
|
if (!pmu)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return perf_pmu__has_format(pmu, "event");
|
|
|
|
}
|
|
|
|
|
2018-06-11 17:34:22 +08:00
|
|
|
static bool test__intel_pt_valid(void)
|
|
|
|
{
|
2023-05-27 15:22:03 +08:00
|
|
|
return !!perf_pmus__find("intel_pt");
|
2018-06-11 17:34:22 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__intel_pt(struct evlist *evlist)
|
2018-05-11 22:48:54 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2018-05-11 22:48:54 +08:00
|
|
|
|
2023-04-21 02:54:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name setting", evsel__name_is(evsel, "intel_pt//u"));
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2018-05-11 22:48:54 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__checkevent_complex_name(struct evlist *evlist)
|
perf tests: Check that complex event name is parsed correctly
Extend regression testing to cover case of complex event names enabled
by the cset f92da71280fb ("perf record: Enable arbitrary event names
thru name= modifier").
Testing it:
# perf test
1: vmlinux symtab matches kallsyms : Skip
2: Detect openat syscall event : Ok
3: Detect openat syscall event on all cpus : Ok
4: Read samples using the mmap interface : Ok
5: Test data source output : Ok
6: Parse event definition strings : Ok <===!
7: Simple expression parser : Ok
...
Committer testing:
# perf test "event definition"
6: Parse event definition strings : Ok
# perf test -v 6 2> /tmp/before
# perf test -v 6 2> /tmp/after
# diff -u /tmp/before /tmp/after
--- /tmp/before 2018-06-19 10:50:21.485572638 -0300
+++ /tmp/after 2018-06-19 10:50:40.886572896 -0300
@@ -1,6 +1,6 @@
6: Parse event definition strings :
--- start ---
-test child forked, pid 24259
+test child forked, pid 24904
running test 0 'syscalls:sys_enter_openat'Using CPUID GenuineIntel-6-3D
registering plugin: /root/.traceevent/plugins/plugin_kvm.so
registering plugin: /root/.traceevent/plugins/plugin_hrtimer.so
@@ -136,9 +136,11 @@
running test 50 '4:0x6530160/name=numpmu/'
running test 51 'L1-dcache-misses/name=cachepmu/'
running test 52 'intel_pt//u'
+running test 53 'cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk'
running test 0 'cpu/config=10,config1,config2=3,period=1000/u'
running test 1 'cpu/config=1,name=krava/u,cpu/config=2/u'
running test 2 'cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/'
+running test 3 'cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2,umask=0x3/ukp'
el-capacity -> cpu/event=0x54,umask=0x2/
el-conflict -> cpu/event=0x54,umask=0x1/
el-start -> cpu/event=0xc8,umask=0x1/
#
Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/ad30b774-219b-7b80-c610-4e9e298cf8a7@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-06-19 16:45:40 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
perf tests: Check that complex event name is parsed correctly
Extend regression testing to cover case of complex event names enabled
by the cset f92da71280fb ("perf record: Enable arbitrary event names
thru name= modifier").
Testing it:
# perf test
1: vmlinux symtab matches kallsyms : Skip
2: Detect openat syscall event : Ok
3: Detect openat syscall event on all cpus : Ok
4: Read samples using the mmap interface : Ok
5: Test data source output : Ok
6: Parse event definition strings : Ok <===!
7: Simple expression parser : Ok
...
Committer testing:
# perf test "event definition"
6: Parse event definition strings : Ok
# perf test -v 6 2> /tmp/before
# perf test -v 6 2> /tmp/after
# diff -u /tmp/before /tmp/after
--- /tmp/before 2018-06-19 10:50:21.485572638 -0300
+++ /tmp/after 2018-06-19 10:50:40.886572896 -0300
@@ -1,6 +1,6 @@
6: Parse event definition strings :
--- start ---
-test child forked, pid 24259
+test child forked, pid 24904
running test 0 'syscalls:sys_enter_openat'Using CPUID GenuineIntel-6-3D
registering plugin: /root/.traceevent/plugins/plugin_kvm.so
registering plugin: /root/.traceevent/plugins/plugin_hrtimer.so
@@ -136,9 +136,11 @@
running test 50 '4:0x6530160/name=numpmu/'
running test 51 'L1-dcache-misses/name=cachepmu/'
running test 52 'intel_pt//u'
+running test 53 'cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk'
running test 0 'cpu/config=10,config1,config2=3,period=1000/u'
running test 1 'cpu/config=1,name=krava/u,cpu/config=2/u'
running test 2 'cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/'
+running test 3 'cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2,umask=0x3/ukp'
el-capacity -> cpu/event=0x54,umask=0x2/
el-conflict -> cpu/event=0x54,umask=0x1/
el-start -> cpu/event=0xc8,umask=0x1/
#
Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/ad30b774-219b-7b80-c610-4e9e298cf8a7@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-06-19 16:45:40 +08:00
|
|
|
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong complex name parsing",
|
|
|
|
evsel__name_is(evsel,
|
|
|
|
"COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks"));
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
perf tests: Check that complex event name is parsed correctly
Extend regression testing to cover case of complex event names enabled
by the cset f92da71280fb ("perf record: Enable arbitrary event names
thru name= modifier").
Testing it:
# perf test
1: vmlinux symtab matches kallsyms : Skip
2: Detect openat syscall event : Ok
3: Detect openat syscall event on all cpus : Ok
4: Read samples using the mmap interface : Ok
5: Test data source output : Ok
6: Parse event definition strings : Ok <===!
7: Simple expression parser : Ok
...
Committer testing:
# perf test "event definition"
6: Parse event definition strings : Ok
# perf test -v 6 2> /tmp/before
# perf test -v 6 2> /tmp/after
# diff -u /tmp/before /tmp/after
--- /tmp/before 2018-06-19 10:50:21.485572638 -0300
+++ /tmp/after 2018-06-19 10:50:40.886572896 -0300
@@ -1,6 +1,6 @@
6: Parse event definition strings :
--- start ---
-test child forked, pid 24259
+test child forked, pid 24904
running test 0 'syscalls:sys_enter_openat'Using CPUID GenuineIntel-6-3D
registering plugin: /root/.traceevent/plugins/plugin_kvm.so
registering plugin: /root/.traceevent/plugins/plugin_hrtimer.so
@@ -136,9 +136,11 @@
running test 50 '4:0x6530160/name=numpmu/'
running test 51 'L1-dcache-misses/name=cachepmu/'
running test 52 'intel_pt//u'
+running test 53 'cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk'
running test 0 'cpu/config=10,config1,config2=3,period=1000/u'
running test 1 'cpu/config=1,name=krava/u,cpu/config=2/u'
running test 2 'cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/'
+running test 3 'cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2,umask=0x3/ukp'
el-capacity -> cpu/event=0x54,umask=0x2/
el-conflict -> cpu/event=0x54,umask=0x1/
el-start -> cpu/event=0xc8,umask=0x1/
#
Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/ad30b774-219b-7b80-c610-4e9e298cf8a7@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-06-19 16:45:40 +08:00
|
|
|
}
|
|
|
|
|
perf parser: Add support to specify rXXX event with pmu
The current rXXXX event specification creates event under PERF_TYPE_RAW
pmu type. This change allows to use rXXXX within pmu syntax, so it's
type is used via the following syntax:
-e 'cpu/r3c/'
-e 'cpum_cf/r0/'
The XXXX number goes directly to perf_event_attr::config the same way as
in '-e rXXXX' event. The perf_event_attr::type is filled with pmu type.
Committer testing:
So, lets see what goes in perf_event_attr::config for, say, the
'instructions' PERF_TYPE_HARDWARE (0) event, first we should look at how
to encode this event as a PERF_TYPE_RAW event for this specific CPU, an
AMD Ryzen 5:
# cat /sys/devices/cpu/events/instructions
event=0xc0
#
Then try with it _and_ the instruction, just to see that they are close
enough:
# perf stat -e rc0,instructions sleep 1
Performance counter stats for 'sleep 1':
919,794 rc0
919,898 instructions
1.000754579 seconds time elapsed
0.000715000 seconds user
0.000000000 seconds sys
#
Now we should try, before this patch, the PMU event encoding:
# perf stat -e cpu/rc0/ sleep 1
event syntax error: 'cpu/rc0/'
\___ unknown term
valid terms: event,edge,inv,umask,cmask,config,config1,config2,name,period,percore
#
Now with this patch, the three ways of specifying the 'instructions' CPU
counter are accepted:
# perf stat -e cpu/rc0/,rc0,instructions sleep 1
Performance counter stats for 'sleep 1':
892,948 cpu/rc0/
893,052 rc0
893,156 instructions
1.000931819 seconds time elapsed
0.000916000 seconds user
0.000000000 seconds sys
#
Requested-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Link: http://lore.kernel.org/lkml/20200416221405.437788-1-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-04-17 06:14:05 +08:00
|
|
|
static int test__checkevent_raw_pmu(struct evlist *evlist)
|
|
|
|
{
|
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, 0x1a));
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
perf parser: Add support to specify rXXX event with pmu
The current rXXXX event specification creates event under PERF_TYPE_RAW
pmu type. This change allows to use rXXXX within pmu syntax, so it's
type is used via the following syntax:
-e 'cpu/r3c/'
-e 'cpum_cf/r0/'
The XXXX number goes directly to perf_event_attr::config the same way as
in '-e rXXXX' event. The perf_event_attr::type is filled with pmu type.
Committer testing:
So, lets see what goes in perf_event_attr::config for, say, the
'instructions' PERF_TYPE_HARDWARE (0) event, first we should look at how
to encode this event as a PERF_TYPE_RAW event for this specific CPU, an
AMD Ryzen 5:
# cat /sys/devices/cpu/events/instructions
event=0xc0
#
Then try with it _and_ the instruction, just to see that they are close
enough:
# perf stat -e rc0,instructions sleep 1
Performance counter stats for 'sleep 1':
919,794 rc0
919,898 instructions
1.000754579 seconds time elapsed
0.000715000 seconds user
0.000000000 seconds sys
#
Now we should try, before this patch, the PMU event encoding:
# perf stat -e cpu/rc0/ sleep 1
event syntax error: 'cpu/rc0/'
\___ unknown term
valid terms: event,edge,inv,umask,cmask,config,config1,config2,name,period,percore
#
Now with this patch, the three ways of specifying the 'instructions' CPU
counter are accepted:
# perf stat -e cpu/rc0/,rc0,instructions sleep 1
Performance counter stats for 'sleep 1':
892,948 cpu/rc0/
893,052 rc0
893,156 instructions
1.000931819 seconds time elapsed
0.000916000 seconds user
0.000000000 seconds sys
#
Requested-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Link: http://lore.kernel.org/lkml/20200416221405.437788-1-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-04-17 06:14:05 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__sym_event_slash(struct evlist *evlist)
|
2019-02-13 20:32:40 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2019-02-13 20:32:40 +08:00
|
|
|
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2019-02-13 20:32:40 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__sym_event_dc(struct evlist *evlist)
|
2019-02-13 20:32:40 +08:00
|
|
|
{
|
2019-09-03 16:39:52 +08:00
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
2019-02-13 20:32:40 +08:00
|
|
|
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
|
2023-05-03 06:38:19 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
2019-07-21 19:24:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2019-02-13 20:32:40 +08:00
|
|
|
}
|
|
|
|
|
2023-05-03 06:38:41 +08:00
|
|
|
static int test__term_equal_term(struct evlist *evlist)
|
|
|
|
{
|
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "name") == 0);
|
|
|
|
return TEST_OK;
|
|
|
|
}
|
|
|
|
|
2023-05-03 06:38:42 +08:00
|
|
|
static int test__term_equal_legacy(struct evlist *evlist)
|
|
|
|
{
|
|
|
|
struct evsel *evsel = evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
|
|
|
|
TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
|
|
|
|
TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "l1d") == 0);
|
|
|
|
return TEST_OK;
|
|
|
|
}
|
|
|
|
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#ifdef HAVE_LIBTRACEEVENT
|
2012-12-17 21:08:38 +08:00
|
|
|
static int count_tracepoints(void)
|
|
|
|
{
|
|
|
|
struct dirent *events_ent;
|
|
|
|
DIR *events_dir;
|
|
|
|
int cnt = 0;
|
|
|
|
|
2018-05-18 01:42:39 +08:00
|
|
|
events_dir = tracing_events__opendir();
|
2012-12-17 21:08:38 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("Can't open events dir", events_dir);
|
|
|
|
|
|
|
|
while ((events_ent = readdir(events_dir))) {
|
2018-05-18 01:27:29 +08:00
|
|
|
char *sys_path;
|
2012-12-17 21:08:38 +08:00
|
|
|
struct dirent *sys_ent;
|
|
|
|
DIR *sys_dir;
|
|
|
|
|
|
|
|
if (!strcmp(events_ent->d_name, ".")
|
|
|
|
|| !strcmp(events_ent->d_name, "..")
|
|
|
|
|| !strcmp(events_ent->d_name, "enable")
|
|
|
|
|| !strcmp(events_ent->d_name, "header_event")
|
|
|
|
|| !strcmp(events_ent->d_name, "header_page"))
|
|
|
|
continue;
|
|
|
|
|
2018-05-18 01:27:29 +08:00
|
|
|
sys_path = get_events_file(events_ent->d_name);
|
|
|
|
TEST_ASSERT_VAL("Can't get sys path", sys_path);
|
2012-12-17 21:08:38 +08:00
|
|
|
|
|
|
|
sys_dir = opendir(sys_path);
|
|
|
|
TEST_ASSERT_VAL("Can't open sys dir", sys_dir);
|
|
|
|
|
|
|
|
while ((sys_ent = readdir(sys_dir))) {
|
|
|
|
if (!strcmp(sys_ent->d_name, ".")
|
|
|
|
|| !strcmp(sys_ent->d_name, "..")
|
|
|
|
|| !strcmp(sys_ent->d_name, "enable")
|
|
|
|
|| !strcmp(sys_ent->d_name, "filter"))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
cnt++;
|
|
|
|
}
|
|
|
|
|
|
|
|
closedir(sys_dir);
|
2018-05-18 01:27:29 +08:00
|
|
|
put_events_file(sys_path);
|
2012-12-17 21:08:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
closedir(events_dir);
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:52 +08:00
|
|
|
static int test__all_tracepoints(struct evlist *evlist)
|
2012-12-17 21:08:38 +08:00
|
|
|
{
|
|
|
|
TEST_ASSERT_VAL("wrong events count",
|
2019-07-21 19:24:28 +08:00
|
|
|
count_tracepoints() == evlist->core.nr_entries);
|
2012-12-17 21:08:38 +08:00
|
|
|
|
|
|
|
return test__checkevent_tracepoint_multi(evlist);
|
|
|
|
}
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#endif /* HAVE_LIBTRACEVENT */
|
2012-12-17 21:08:38 +08:00
|
|
|
|
2013-01-19 03:56:57 +08:00
|
|
|
struct evlist_test {
|
2012-05-21 15:12:49 +08:00
|
|
|
const char *name;
|
2018-06-11 17:34:22 +08:00
|
|
|
bool (*valid)(void);
|
2019-07-21 19:23:52 +08:00
|
|
|
int (*check)(struct evlist *evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
};
|
|
|
|
|
2022-05-18 12:20:25 +08:00
|
|
|
static const struct evlist_test test__events[] = {
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#ifdef HAVE_LIBTRACEEVENT
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2015-04-16 21:52:53 +08:00
|
|
|
.name = "syscalls:sys_enter_openat",
|
2012-05-21 15:12:49 +08:00
|
|
|
.check = test__checkevent_tracepoint,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 0 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "syscalls:*",
|
|
|
|
.check = test__checkevent_tracepoint_multi,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 1 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#endif
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "r1a",
|
|
|
|
.check = test__checkevent_raw,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 2 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "1:1",
|
|
|
|
.check = test__checkevent_numeric,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 3 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "instructions",
|
|
|
|
.check = test__checkevent_symbolic_name,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 4 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "cycles/period=100000,config2/",
|
|
|
|
.check = test__checkevent_symbolic_name_config,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 5 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "faults",
|
|
|
|
.check = test__checkevent_symbolic_alias,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 6 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "L1-dcache-load-miss",
|
|
|
|
.check = test__checkevent_genhw,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 7 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "mem:0",
|
|
|
|
.check = test__checkevent_breakpoint,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 8 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "mem:0:x",
|
|
|
|
.check = test__checkevent_breakpoint_x,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 9 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "mem:0:r",
|
|
|
|
.check = test__checkevent_breakpoint_r,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 0 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "mem:0:w",
|
|
|
|
.check = test__checkevent_breakpoint_w,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 1 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#ifdef HAVE_LIBTRACEEVENT
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2015-04-16 21:52:53 +08:00
|
|
|
.name = "syscalls:sys_enter_openat:k",
|
2012-05-21 15:12:49 +08:00
|
|
|
.check = test__checkevent_tracepoint_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 2 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "syscalls:*:u",
|
|
|
|
.check = test__checkevent_tracepoint_multi_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 3 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#endif
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "r1a:kp",
|
|
|
|
.check = test__checkevent_raw_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 4 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "1:1:hp",
|
|
|
|
.check = test__checkevent_numeric_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 5 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "instructions:h",
|
|
|
|
.check = test__checkevent_symbolic_name_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 6 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "faults:u",
|
|
|
|
.check = test__checkevent_symbolic_alias_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 7 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "L1-dcache-load-miss:kp",
|
|
|
|
.check = test__checkevent_genhw_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 8 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "mem:0:u",
|
|
|
|
.check = test__checkevent_breakpoint_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 9 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "mem:0:x:k",
|
|
|
|
.check = test__checkevent_breakpoint_x_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 0 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "mem:0:r:hp",
|
|
|
|
.check = test__checkevent_breakpoint_r_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 1 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "mem:0:w:up",
|
|
|
|
.check = test__checkevent_breakpoint_w_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 2 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#ifdef HAVE_LIBTRACEEVENT
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2015-04-16 21:52:53 +08:00
|
|
|
.name = "r1,syscalls:sys_enter_openat:k,1:1:hp",
|
2012-05-21 15:12:49 +08:00
|
|
|
.check = test__checkevent_list,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 3 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#endif
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "instructions:G",
|
|
|
|
.check = test__checkevent_exclude_host_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 4 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "instructions:H",
|
|
|
|
.check = test__checkevent_exclude_guest_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 5 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-06-29 15:22:54 +08:00
|
|
|
.name = "mem:0:rw",
|
|
|
|
.check = test__checkevent_breakpoint_rw,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 6 */
|
2012-06-29 15:22:54 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-06-29 15:22:54 +08:00
|
|
|
.name = "mem:0:rw:kp",
|
|
|
|
.check = test__checkevent_breakpoint_rw_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 7 */
|
2012-06-29 15:22:54 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-08-08 18:23:52 +08:00
|
|
|
.name = "{instructions:k,cycles:upp}",
|
|
|
|
.check = test__group1,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 8 */
|
2012-08-08 18:23:52 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-08-08 18:23:52 +08:00
|
|
|
.name = "{faults:k,cache-references}:u,cycles:k",
|
|
|
|
.check = test__group2,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 9 */
|
2012-08-08 18:23:52 +08:00
|
|
|
},
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#ifdef HAVE_LIBTRACEEVENT
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2015-04-16 21:52:53 +08:00
|
|
|
.name = "group1{syscalls:sys_enter_openat:H,cycles:kppp},group2{cycles,1:3}:G,instructions:u",
|
2012-08-08 18:23:52 +08:00
|
|
|
.check = test__group3,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 0 */
|
2012-08-08 18:23:52 +08:00
|
|
|
},
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#endif
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-08-08 18:23:52 +08:00
|
|
|
.name = "{cycles:u,instructions:kp}:p",
|
|
|
|
.check = test__group4,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 1 */
|
2012-08-08 18:23:52 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-08-08 18:23:52 +08:00
|
|
|
.name = "{cycles,instructions}:G,{cycles:G,instructions:G},cycles",
|
|
|
|
.check = test__group5,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 2 */
|
2012-08-08 18:23:52 +08:00
|
|
|
},
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#ifdef HAVE_LIBTRACEEVENT
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-12-17 21:08:38 +08:00
|
|
|
.name = "*:*",
|
|
|
|
.check = test__all_tracepoints,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 3 */
|
2012-12-17 21:08:38 +08:00
|
|
|
},
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#endif
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2013-02-04 17:56:43 +08:00
|
|
|
.name = "{cycles,cache-misses:G}:H",
|
|
|
|
.check = test__group_gh1,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 4 */
|
2013-02-04 17:56:43 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2013-02-04 17:56:43 +08:00
|
|
|
.name = "{cycles,cache-misses:H}:G",
|
|
|
|
.check = test__group_gh2,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 5 */
|
2013-02-04 17:56:43 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2013-02-04 17:56:43 +08:00
|
|
|
.name = "{cycles:G,cache-misses:H}:u",
|
|
|
|
.check = test__group_gh3,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 6 */
|
2013-02-04 17:56:43 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2013-02-04 17:56:43 +08:00
|
|
|
.name = "{cycles:G,cache-misses:H}:uG",
|
|
|
|
.check = test__group_gh4,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 7 */
|
2013-02-04 17:56:43 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2013-02-02 03:37:11 +08:00
|
|
|
.name = "{cycles,cache-misses,branch-misses}:S",
|
|
|
|
.check = test__leader_sample1,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 8 */
|
2013-02-02 03:37:11 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2013-02-02 03:37:11 +08:00
|
|
|
.name = "{instructions,branch-misses}:Su",
|
|
|
|
.check = test__leader_sample2,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 9 */
|
2013-02-02 03:37:11 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2013-08-06 21:28:06 +08:00
|
|
|
.name = "instructions:uDp",
|
|
|
|
.check = test__checkevent_pinned_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 0 */
|
2013-08-06 21:28:06 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2013-08-06 21:28:06 +08:00
|
|
|
.name = "{cycles,cache-misses,branch-misses}:D",
|
|
|
|
.check = test__pinned_group,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 1 */
|
2013-08-06 21:28:06 +08:00
|
|
|
},
|
2014-05-29 23:26:52 +08:00
|
|
|
{
|
|
|
|
.name = "mem:0/1",
|
|
|
|
.check = test__checkevent_breakpoint_len,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 2 */
|
2014-05-29 23:26:52 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0/2:w",
|
|
|
|
.check = test__checkevent_breakpoint_len_w,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 3 */
|
2014-05-29 23:26:52 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0/4:rw:u",
|
|
|
|
.check = test__checkevent_breakpoint_len_rw_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 4 */
|
2014-05-29 23:26:52 +08:00
|
|
|
},
|
perf build: Use libtraceevent from the system
Remove the LIBTRACEEVENT_DYNAMIC and LIBTRACEFS_DYNAMIC make command
line variables.
If libtraceevent isn't installed or NO_LIBTRACEEVENT=1 is passed to the
build, don't compile in libtraceevent and libtracefs support.
This also disables CONFIG_TRACE that controls "perf trace".
CONFIG_LIBTRACEEVENT is used to control enablement in Build/Makefiles,
HAVE_LIBTRACEEVENT is used in C code.
Without HAVE_LIBTRACEEVENT tracepoints are disabled and as such the
commands kmem, kwork, lock, sched and timechart are removed. The
majority of commands continue to work including "perf test".
Committer notes:
Fixed up a tools/perf/util/Build reject and added:
#include <traceevent/event-parse.h>
to tools/perf/util/scripting-engines/trace-event-perl.c.
Committer testing:
$ rpm -qi libtraceevent-devel
Name : libtraceevent-devel
Version : 1.5.3
Release : 2.fc36
Architecture: x86_64
Install Date: Mon 25 Jul 2022 03:20:19 PM -03
Group : Unspecified
Size : 27728
License : LGPLv2+ and GPLv2+
Signature : RSA/SHA256, Fri 15 Apr 2022 02:11:58 PM -03, Key ID 999f7cbf38ab71f4
Source RPM : libtraceevent-1.5.3-2.fc36.src.rpm
Build Date : Fri 15 Apr 2022 10:57:01 AM -03
Build Host : buildvm-x86-05.iad2.fedoraproject.org
Packager : Fedora Project
Vendor : Fedora Project
URL : https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/
Bug URL : https://bugz.fedoraproject.org/libtraceevent
Summary : Development headers of libtraceevent
Description :
Development headers of libtraceevent-libs
$
Default build:
$ ldd ~/bin/perf | grep tracee
libtraceevent.so.1 => /lib64/libtraceevent.so.1 (0x00007f1dcaf8f000)
$
# perf trace -e sched:* --max-events 10
0.000 migration/0/17 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, dest_cpu: 1)
0.005 migration/0/17 sched:sched_wake_idle_without_ipi(cpu: 1)
0.011 migration/0/17 sched:sched_switch(prev_comm: "", prev_pid: 17 (migration/0), prev_state: 1, next_comm: "", next_prio: 120)
1.173 :0/0 sched:sched_wakeup(comm: "", pid: 3138 (gnome-terminal-), prio: 120)
1.180 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 3138 (gnome-terminal-), next_prio: 120)
0.156 migration/1/21 sched:sched_migrate_task(comm: "", pid: 1603763 (perf), prio: 120, orig_cpu: 1, dest_cpu: 2)
0.160 migration/1/21 sched:sched_wake_idle_without_ipi(cpu: 2)
0.166 migration/1/21 sched:sched_switch(prev_comm: "", prev_pid: 21 (migration/1), prev_state: 1, next_comm: "", next_prio: 120)
1.183 :0/0 sched:sched_wakeup(comm: "", pid: 1602985 (kworker/u16:0-f), prio: 120, target_cpu: 1)
1.186 :0/0 sched:sched_switch(prev_comm: "", prev_prio: 120, next_comm: "", next_pid: 1602985 (kworker/u16:0-f), next_prio: 120)
#
Had to tweak tools/perf/util/setup.py to make sure the python binding
shared object links with libtraceevent if -DHAVE_LIBTRACEEVENT is
present in CFLAGS.
Building with NO_LIBTRACEEVENT=1 uncovered some more build failures:
- Make building of data-convert-bt.c to CONFIG_LIBTRACEEVENT=y
- perf-$(CONFIG_LIBTRACEEVENT) += scripts/
- bpf_kwork.o needs also to be dependent on CONFIG_LIBTRACEEVENT=y
- The python binding needed some fixups and util/trace-event.c can't be
built and linked with the python binding shared object, so remove it
in tools/perf/util/setup.py and exclude it from the list of
dependencies in the python/perf.so Makefile.perf target.
Building without libtraceevent-devel installed uncovered more build
failures:
- The python binding tools/perf/util/python.c was assuming that
traceevent/parse-events.h was always available, which was the case
when we defaulted to using the in-kernel tools/lib/traceevent/ files,
now we need to enclose it under ifdef HAVE_LIBTRACEEVENT, just like
the other parts of it that deal with tracepoints.
- We have to ifdef the rules in the Build files with
CONFIG_LIBTRACEEVENT=y to build builtin-trace.c and
tools/perf/trace/beauty/ as we only ifdef setting CONFIG_TRACE=y when
setting NO_LIBTRACEEVENT=1 in the make command line, not when we don't
detect libtraceevent-devel installed in the system. Simplification here
to avoid these two ways of disabling builtin-trace.c and not having
CONFIG_TRACE=y when libtraceevent-devel isn't installed is the clean
way.
From Athira:
<quote>
tools/perf/arch/powerpc/util/Build
-perf-y += kvm-stat.o
+perf-$(CONFIG_LIBTRACEEVENT) += kvm-stat.o
</quote>
Then, ditto for arm64 and s390, detected by container cross build tests.
- s/390 uses test__checkevent_tracepoint() that is now only available if
HAVE_LIBTRACEEVENT is defined, enclose the callsite with ifder HAVE_LIBTRACEEVENT.
Also from Athira:
<quote>
With this change, I could successfully compile in these environment:
- Without libtraceevent-devel installed
- With libtraceevent-devel installed
- With “make NO_LIBTRACEEVENT=1”
</quote>
Then, finally rename CONFIG_TRACEEVENT to CONFIG_LIBTRACEEVENT for
consistency with other libraries detected in tools/perf/.
Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: bpf@vger.kernel.org
Link: http://lore.kernel.org/lkml/20221205225940.3079667-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2022-12-06 06:59:39 +08:00
|
|
|
#if defined(__s390x__) && defined(HAVE_LIBTRACEEVENT)
|
2014-04-25 23:34:07 +08:00
|
|
|
{
|
|
|
|
.name = "kvm-s390:kvm_s390_create_vm",
|
|
|
|
.check = test__checkevent_tracepoint,
|
2019-06-04 13:35:04 +08:00
|
|
|
.valid = kvm_s390_create_vm_valid,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 0 */
|
2014-04-25 23:34:07 +08:00
|
|
|
},
|
|
|
|
#endif
|
2015-04-08 05:25:14 +08:00
|
|
|
{
|
|
|
|
.name = "instructions:I",
|
|
|
|
.check = test__checkevent_exclude_idle_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 5 */
|
2015-04-08 05:25:14 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "instructions:kIG",
|
|
|
|
.check = test__checkevent_exclude_idle_modifier_1,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 6 */
|
2015-04-08 05:25:14 +08:00
|
|
|
},
|
2015-10-06 02:06:06 +08:00
|
|
|
{
|
|
|
|
.name = "task-clock:P,cycles",
|
|
|
|
.check = test__checkevent_precise_max_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 7 */
|
2015-10-06 02:06:06 +08:00
|
|
|
},
|
perf tools: Enable config raw and numeric events
This patch allows setting config terms for raw and numeric events.
For example:
# perf stat -e cycles/name=cyc/ ls
...
1821108 cyc
...
# perf stat -e r6530160/name=event/ ls
...
1103195 event
...
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
...
# perf report --stdio
...
# Samples: 124 of event 'cycles'
46.61% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
41.26% 0.00% swapper [kernel.vmlinux] [k] start_secondary
...
# Samples: 91 of event 'evtx'
...
93.76% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--66.63%--call_cpuidle
| cpuidle_enter
| |
...
3 test cases are introduced to test config terms for symbol, raw and
numeric events.
Committer note:
Further testing shows that we can retrieve the event name using 'perf
evlist -v' and looking at the 'config' perf_event_attr field, i.e.:
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.724 MB perf.data (2076 samples) ]
# perf evlist
cycles
evtx
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
evtx: type: 4, size: 112, config: 0x6530160, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-19 19:44:00 +08:00
|
|
|
{
|
|
|
|
.name = "instructions/name=insn/",
|
|
|
|
.check = test__checkevent_config_symbol,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 8 */
|
perf tools: Enable config raw and numeric events
This patch allows setting config terms for raw and numeric events.
For example:
# perf stat -e cycles/name=cyc/ ls
...
1821108 cyc
...
# perf stat -e r6530160/name=event/ ls
...
1103195 event
...
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
...
# perf report --stdio
...
# Samples: 124 of event 'cycles'
46.61% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
41.26% 0.00% swapper [kernel.vmlinux] [k] start_secondary
...
# Samples: 91 of event 'evtx'
...
93.76% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--66.63%--call_cpuidle
| cpuidle_enter
| |
...
3 test cases are introduced to test config terms for symbol, raw and
numeric events.
Committer note:
Further testing shows that we can retrieve the event name using 'perf
evlist -v' and looking at the 'config' perf_event_attr field, i.e.:
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.724 MB perf.data (2076 samples) ]
# perf evlist
cycles
evtx
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
evtx: type: 4, size: 112, config: 0x6530160, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-19 19:44:00 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "r1234/name=rawpmu/",
|
|
|
|
.check = test__checkevent_config_raw,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 9 */
|
perf tools: Enable config raw and numeric events
This patch allows setting config terms for raw and numeric events.
For example:
# perf stat -e cycles/name=cyc/ ls
...
1821108 cyc
...
# perf stat -e r6530160/name=event/ ls
...
1103195 event
...
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
...
# perf report --stdio
...
# Samples: 124 of event 'cycles'
46.61% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
41.26% 0.00% swapper [kernel.vmlinux] [k] start_secondary
...
# Samples: 91 of event 'evtx'
...
93.76% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--66.63%--call_cpuidle
| cpuidle_enter
| |
...
3 test cases are introduced to test config terms for symbol, raw and
numeric events.
Committer note:
Further testing shows that we can retrieve the event name using 'perf
evlist -v' and looking at the 'config' perf_event_attr field, i.e.:
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.724 MB perf.data (2076 samples) ]
# perf evlist
cycles
evtx
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
evtx: type: 4, size: 112, config: 0x6530160, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-19 19:44:00 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "4:0x6530160/name=numpmu/",
|
|
|
|
.check = test__checkevent_config_num,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 0 */
|
perf tools: Enable config raw and numeric events
This patch allows setting config terms for raw and numeric events.
For example:
# perf stat -e cycles/name=cyc/ ls
...
1821108 cyc
...
# perf stat -e r6530160/name=event/ ls
...
1103195 event
...
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
...
# perf report --stdio
...
# Samples: 124 of event 'cycles'
46.61% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
41.26% 0.00% swapper [kernel.vmlinux] [k] start_secondary
...
# Samples: 91 of event 'evtx'
...
93.76% 0.00% swapper [kernel.vmlinux] [k] cpu_startup_entry
|
---cpu_startup_entry
|
|--66.63%--call_cpuidle
| cpuidle_enter
| |
...
3 test cases are introduced to test config terms for symbol, raw and
numeric events.
Committer note:
Further testing shows that we can retrieve the event name using 'perf
evlist -v' and looking at the 'config' perf_event_attr field, i.e.:
# perf record -e cycles -e 4:0x6530160/name=evtx,call-graph=fp/ -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 1.724 MB perf.data (2076 samples) ]
# perf evlist
cycles
evtx
# perf evlist -v
cycles: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1
evtx: type: 4, size: 112, config: 0x6530160, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|CALLCHAIN|CPU|PERIOD|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, freq: 1, sample_id_all: 1, exclude_guest: 1
#
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Cody P Schafer <dev@codyps.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jeremie Galarneau <jeremie.galarneau@efficios.com>
Cc: Kirill Smelkov <kirr@nexedi.com>
Cc: Li Zefan <lizefan@huawei.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1455882283-79592-13-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2016-02-19 19:44:00 +08:00
|
|
|
},
|
2016-02-19 19:44:01 +08:00
|
|
|
{
|
|
|
|
.name = "L1-dcache-misses/name=cachepmu/",
|
|
|
|
.check = test__checkevent_config_cache,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 1 */
|
2016-02-19 19:44:01 +08:00
|
|
|
},
|
2018-05-11 22:48:54 +08:00
|
|
|
{
|
|
|
|
.name = "intel_pt//u",
|
2018-06-11 17:34:22 +08:00
|
|
|
.valid = test__intel_pt_valid,
|
2018-05-11 22:48:54 +08:00
|
|
|
.check = test__intel_pt,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 2 */
|
2018-05-11 22:48:54 +08:00
|
|
|
},
|
perf tests: Check that complex event name is parsed correctly
Extend regression testing to cover case of complex event names enabled
by the cset f92da71280fb ("perf record: Enable arbitrary event names
thru name= modifier").
Testing it:
# perf test
1: vmlinux symtab matches kallsyms : Skip
2: Detect openat syscall event : Ok
3: Detect openat syscall event on all cpus : Ok
4: Read samples using the mmap interface : Ok
5: Test data source output : Ok
6: Parse event definition strings : Ok <===!
7: Simple expression parser : Ok
...
Committer testing:
# perf test "event definition"
6: Parse event definition strings : Ok
# perf test -v 6 2> /tmp/before
# perf test -v 6 2> /tmp/after
# diff -u /tmp/before /tmp/after
--- /tmp/before 2018-06-19 10:50:21.485572638 -0300
+++ /tmp/after 2018-06-19 10:50:40.886572896 -0300
@@ -1,6 +1,6 @@
6: Parse event definition strings :
--- start ---
-test child forked, pid 24259
+test child forked, pid 24904
running test 0 'syscalls:sys_enter_openat'Using CPUID GenuineIntel-6-3D
registering plugin: /root/.traceevent/plugins/plugin_kvm.so
registering plugin: /root/.traceevent/plugins/plugin_hrtimer.so
@@ -136,9 +136,11 @@
running test 50 '4:0x6530160/name=numpmu/'
running test 51 'L1-dcache-misses/name=cachepmu/'
running test 52 'intel_pt//u'
+running test 53 'cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk'
running test 0 'cpu/config=10,config1,config2=3,period=1000/u'
running test 1 'cpu/config=1,name=krava/u,cpu/config=2/u'
running test 2 'cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/'
+running test 3 'cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2,umask=0x3/ukp'
el-capacity -> cpu/event=0x54,umask=0x2/
el-conflict -> cpu/event=0x54,umask=0x1/
el-start -> cpu/event=0xc8,umask=0x1/
#
Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/ad30b774-219b-7b80-c610-4e9e298cf8a7@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-06-19 16:45:40 +08:00
|
|
|
{
|
|
|
|
.name = "cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk",
|
|
|
|
.check = test__checkevent_complex_name,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 3 */
|
2019-02-13 20:32:40 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "cycles//u",
|
|
|
|
.check = test__sym_event_slash,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 4 */
|
2019-02-13 20:32:40 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "cycles:k",
|
|
|
|
.check = test__sym_event_dc,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 5 */
|
perf tools: Add support for exclusive groups/events
Peter suggested that using the exclusive mode in perf could avoid some
problems with bad scheduling of groups. Exclusive is implemented in the
kernel, but wasn't exposed by the perf tool, so hard to use without
custom low level API users.
Add support for marking groups or events with :e for exclusive in the
perf tool. The implementation is basically the same as the existing
pinned attribute.
Committer testing:
# perf test "parse event"
6: Parse event definition strings : Ok
# perf test -v "parse event" |& grep :u*e
running test 56 'instructions:uep'
running test 57 '{cycles,cache-misses,branch-misses}:e'
#
#
# grep "model name" -m1 /proc/cpuinfo
model name : AMD Ryzen 9 3900X 12-Core Processor
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
<not counted> cycles (0.00%)
<not counted> cache-misses (0.00%)
<not counted> branch-misses (0.00%)
1.001269893 seconds time elapsed
Some events weren't counted. Try disabling the NMI watchdog:
echo 0 > /proc/sys/kernel/nmi_watchdog
perf stat ...
echo 1 > /proc/sys/kernel/nmi_watchdog
# echo 0 > /proc/sys/kernel/nmi_watchdog
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
1,298,663,141 cycles
30,962,215 cache-misses
5,325,150 branch-misses
1.001474934 seconds time elapsed
#
# The output for asking for precise events on AMD needs to improve, it
# supposedly works only for system wide or per CPU
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:uep' sleep 1
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles).
/bin/dmesg | grep -i perf may provide additional information.
# perf stat -a -e '{cycles,cache-misses,branch-misses}:ue' sleep 1
Performance counter stats for 'system wide':
746,363,126 cycles
16,881,611 cache-misses
2,871,259 branch-misses
1.001636066 seconds time elapsed
#
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20201014144255.22699-1-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-10-14 22:42:55 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "instructions:uep",
|
|
|
|
.check = test__checkevent_exclusive_modifier,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 6 */
|
perf tools: Add support for exclusive groups/events
Peter suggested that using the exclusive mode in perf could avoid some
problems with bad scheduling of groups. Exclusive is implemented in the
kernel, but wasn't exposed by the perf tool, so hard to use without
custom low level API users.
Add support for marking groups or events with :e for exclusive in the
perf tool. The implementation is basically the same as the existing
pinned attribute.
Committer testing:
# perf test "parse event"
6: Parse event definition strings : Ok
# perf test -v "parse event" |& grep :u*e
running test 56 'instructions:uep'
running test 57 '{cycles,cache-misses,branch-misses}:e'
#
#
# grep "model name" -m1 /proc/cpuinfo
model name : AMD Ryzen 9 3900X 12-Core Processor
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
<not counted> cycles (0.00%)
<not counted> cache-misses (0.00%)
<not counted> branch-misses (0.00%)
1.001269893 seconds time elapsed
Some events weren't counted. Try disabling the NMI watchdog:
echo 0 > /proc/sys/kernel/nmi_watchdog
perf stat ...
echo 1 > /proc/sys/kernel/nmi_watchdog
# echo 0 > /proc/sys/kernel/nmi_watchdog
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
1,298,663,141 cycles
30,962,215 cache-misses
5,325,150 branch-misses
1.001474934 seconds time elapsed
#
# The output for asking for precise events on AMD needs to improve, it
# supposedly works only for system wide or per CPU
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:uep' sleep 1
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles).
/bin/dmesg | grep -i perf may provide additional information.
# perf stat -a -e '{cycles,cache-misses,branch-misses}:ue' sleep 1
Performance counter stats for 'system wide':
746,363,126 cycles
16,881,611 cache-misses
2,871,259 branch-misses
1.001636066 seconds time elapsed
#
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20201014144255.22699-1-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-10-14 22:42:55 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "{cycles,cache-misses,branch-misses}:e",
|
|
|
|
.check = test__exclusive_group,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 7 */
|
perf tools: Add support for exclusive groups/events
Peter suggested that using the exclusive mode in perf could avoid some
problems with bad scheduling of groups. Exclusive is implemented in the
kernel, but wasn't exposed by the perf tool, so hard to use without
custom low level API users.
Add support for marking groups or events with :e for exclusive in the
perf tool. The implementation is basically the same as the existing
pinned attribute.
Committer testing:
# perf test "parse event"
6: Parse event definition strings : Ok
# perf test -v "parse event" |& grep :u*e
running test 56 'instructions:uep'
running test 57 '{cycles,cache-misses,branch-misses}:e'
#
#
# grep "model name" -m1 /proc/cpuinfo
model name : AMD Ryzen 9 3900X 12-Core Processor
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
<not counted> cycles (0.00%)
<not counted> cache-misses (0.00%)
<not counted> branch-misses (0.00%)
1.001269893 seconds time elapsed
Some events weren't counted. Try disabling the NMI watchdog:
echo 0 > /proc/sys/kernel/nmi_watchdog
perf stat ...
echo 1 > /proc/sys/kernel/nmi_watchdog
# echo 0 > /proc/sys/kernel/nmi_watchdog
# perf stat -a -e '{cycles,cache-misses,branch-misses}:e' sleep 1
Performance counter stats for 'system wide':
1,298,663,141 cycles
30,962,215 cache-misses
5,325,150 branch-misses
1.001474934 seconds time elapsed
#
# The output for asking for precise events on AMD needs to improve, it
# supposedly works only for system wide or per CPU
#
# perf stat -a -e '{cycles,cache-misses,branch-misses}:uep' sleep 1
Error:
The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles).
/bin/dmesg | grep -i perf may provide additional information.
# perf stat -a -e '{cycles,cache-misses,branch-misses}:ue' sleep 1
Performance counter stats for 'system wide':
746,363,126 cycles
16,881,611 cache-misses
2,871,259 branch-misses
1.001636066 seconds time elapsed
#
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/20201014144255.22699-1-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-10-14 22:42:55 +08:00
|
|
|
},
|
2023-05-03 06:38:41 +08:00
|
|
|
{
|
|
|
|
.name = "cycles/name=name/",
|
|
|
|
.check = test__term_equal_term,
|
|
|
|
/* 8 */
|
|
|
|
},
|
2023-05-03 06:38:42 +08:00
|
|
|
{
|
|
|
|
.name = "cycles/name=l1d/",
|
|
|
|
.check = test__term_equal_legacy,
|
|
|
|
/* 9 */
|
|
|
|
},
|
perf parse: Allow config terms with breakpoints
Add config terms to the parsing of breakpoint events. Extend "Test event
parsing" to also cover using a confg term.
This makes breakpoint events consistent with other events which already
support config terms.
Example:
$ cat dr_test.c
#include <unistd.h>
#include <stdio.h>
void func0(void)
{
}
int main()
{
printf("func0 %p\n", &func0);
while (1) {
func0();
usleep(100000);
}
return 0;
}
$ gcc -g -O0 -o dr_test dr_test.c
$ ./dr_test &
[2] 19646
func0 0x55feb98dd169
$ perf record -e mem:0x55feb98dd169:x/name=breakpoint/ -p 19646 -- sleep 0.5
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.017 MB perf.data (5 samples) ]
$ perf script
dr_test 19646 5632.956628: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
dr_test 19646 5633.056866: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
dr_test 19646 5633.157084: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
dr_test 19646 5633.257309: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
dr_test 19646 5633.357532: 1 breakpoint: 55feb98dd169 func0+0x0 (/home/ahunter/git/work/dr_test)
$ sudo perf test "Test event parsing"
6: Parse event definition strings :
6.1: Test event parsing : Ok
$ sudo perf test -v "Test event parsing" |& grep mem
running test 8 'mem:0'
running test 9 'mem:0:x'
running test 10 'mem:0:r'
running test 11 'mem:0:w'
running test 19 'mem:0:u'
running test 20 'mem:0:x:k'
running test 21 'mem:0:r:hp'
running test 22 'mem:0:w:up'
running test 26 'mem:0:rw'
running test 27 'mem:0:rw:kp'
running test 42 'mem:0/1'
running test 43 'mem:0/2:w'
running test 44 'mem:0/4:rw:u'
running test 58 'mem:0/name=breakpoint/'
running test 59 'mem:0:x/name=breakpoint/'
running test 60 'mem:0:r/name=breakpoint/'
running test 61 'mem:0:w/name=breakpoint/'
running test 62 'mem:0/name=breakpoint/u'
running test 63 'mem:0:x/name=breakpoint/k'
running test 64 'mem:0:r/name=breakpoint/hp'
running test 65 'mem:0:w/name=breakpoint/up'
running test 66 'mem:0:rw/name=breakpoint/'
running test 67 'mem:0:rw/name=breakpoint/kp'
running test 68 'mem:0/1/name=breakpoint/'
running test 69 'mem:0/2:w/name=breakpoint/'
running test 70 'mem:0/4:rw/name=breakpoint/u'
running test 71 'mem:0/1/name=breakpoint1/,mem:0/4:rw/name=breakpoint2/'
Committer notes:
Folded follow up patch (see 2nd link below) to address warnings about
unused tokens:
perf tools: Suppress bison unused value warnings
Patch "perf tools: Allow config terms with breakpoints" introduced parse
tokens for colons and slashes within breakpoint parsing to prevent mix
up with colons and slashes related to config terms.
The token values are not needed but introduce bison "unused value"
warnings.
Suppress those warnings.
Committer testing:
# cat ~acme/c/mem_breakpoint.c
#include <stdio.h>
#include <unistd.h>
void func1(void) { }
void func2(void) { }
void func3(void) { }
void func4(void) { }
void func5(void) { }
int main()
{
printf("func1 %p\n", &func1);
printf("func2 %p\n", &func2);
printf("func3 %p\n", &func3);
printf("func4 %p\n", &func4);
printf("func5 %p\n", &func5);
while (1) {
func1(); func2(); func3(); func4(); func5();
usleep(100000);
}
return 0;
}
# ~acme/c/mem_breakpoint &
[1] 3186153
func1 0x401136
func2 0x40113d
func3 0x401144
func4 0x40114b
func5 0x401152
#
Trying to watch the first 4 functions for eXecutable access:
# perf record -e mem:0x401136:x/name=breakpoint1/,mem:0x40113d:x/name=breakpoint2/,mem:0x401144:x/name=breakpoint3/,mem:0x40114b:x/name=breakpoint4/ -p 3186153 -- sleep 0.5
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.026 MB perf.data (20 samples) ]
[root@five ~]# perf script
mem_breakpoint 3186153 131612.864793: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.864795: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.864796: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.864797: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.964868: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.964870: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.964871: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131612.964872: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.064945: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.064948: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.064948: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.064949: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.165024: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.165026: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.165027: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.165028: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.265103: 1 breakpoint1: 401136 func1+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.265105: 1 breakpoint2: 40113d func2+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.265106: 1 breakpoint3: 401144 func3+0x0 (/var/home/acme/c/mem_breakpoint)
mem_breakpoint 3186153 131613.265107: 1 breakpoint4: 40114b func4+0x0 (/var/home/acme/c/mem_breakpoint)
#
Then all the 5 functions:
# perf record -e mem:0x401136:x/name=breakpoint1/,mem:0x40113d:x/name=breakpoint2/,mem:0x401144:x/name=breakpoint3/,mem:0x40114b:x/name=breakpoint4/,mem:0x401152:x/name=breakpoint5/ -p 3186153 -- sleep 0.5
Error:
The sys_perf_event_open() syscall returned with 28 (No space left on device) for event (breakpoint5).
/bin/dmesg | grep -i perf may provide additional information.
# grep -m1 'model name' /proc/cpuinfo
model name : AMD Ryzen 9 5950X 16-Core Processor
#
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20230525082902.25332-2-adrian.hunter@intel.com
Link: https://lore.kernel.org/r/f7228dc9-fe18-a8e3-7d3f-52922e0e1113@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2023-05-25 16:29:02 +08:00
|
|
|
{
|
|
|
|
.name = "mem:0/name=breakpoint/",
|
|
|
|
.check = test__checkevent_breakpoint,
|
|
|
|
/* 0 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0:x/name=breakpoint/",
|
|
|
|
.check = test__checkevent_breakpoint_x,
|
|
|
|
/* 1 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0:r/name=breakpoint/",
|
|
|
|
.check = test__checkevent_breakpoint_r,
|
|
|
|
/* 2 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0:w/name=breakpoint/",
|
|
|
|
.check = test__checkevent_breakpoint_w,
|
|
|
|
/* 3 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0/name=breakpoint/u",
|
|
|
|
.check = test__checkevent_breakpoint_modifier_name,
|
|
|
|
/* 4 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0:x/name=breakpoint/k",
|
|
|
|
.check = test__checkevent_breakpoint_x_modifier_name,
|
|
|
|
/* 5 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0:r/name=breakpoint/hp",
|
|
|
|
.check = test__checkevent_breakpoint_r_modifier_name,
|
|
|
|
/* 6 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0:w/name=breakpoint/up",
|
|
|
|
.check = test__checkevent_breakpoint_w_modifier_name,
|
|
|
|
/* 7 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0:rw/name=breakpoint/",
|
|
|
|
.check = test__checkevent_breakpoint_rw,
|
|
|
|
/* 8 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0:rw/name=breakpoint/kp",
|
|
|
|
.check = test__checkevent_breakpoint_rw_modifier_name,
|
|
|
|
/* 9 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0/1/name=breakpoint/",
|
|
|
|
.check = test__checkevent_breakpoint_len,
|
|
|
|
/* 0 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0/2:w/name=breakpoint/",
|
|
|
|
.check = test__checkevent_breakpoint_len_w,
|
|
|
|
/* 1 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0/4:rw/name=breakpoint/u",
|
|
|
|
.check = test__checkevent_breakpoint_len_rw_modifier,
|
|
|
|
/* 2 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0/1/name=breakpoint1/,mem:0/4:rw/name=breakpoint2/",
|
|
|
|
.check = test__checkevent_breakpoint_2_events,
|
|
|
|
/* 3 */
|
|
|
|
},
|
2012-05-21 15:12:49 +08:00
|
|
|
};
|
|
|
|
|
2022-05-18 12:20:25 +08:00
|
|
|
static const struct evlist_test test__events_pmu[] = {
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:49 +08:00
|
|
|
.name = "cpu/config=10,config1,config2=3,period=1000/u",
|
2023-05-03 06:38:18 +08:00
|
|
|
.valid = test__pmu_cpu_valid,
|
2012-05-21 15:12:49 +08:00
|
|
|
.check = test__checkevent_pmu,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 0 */
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-05-21 15:12:53 +08:00
|
|
|
.name = "cpu/config=1,name=krava/u,cpu/config=2/u",
|
2023-05-03 06:38:18 +08:00
|
|
|
.valid = test__pmu_cpu_valid,
|
2012-05-21 15:12:53 +08:00
|
|
|
.check = test__checkevent_pmu_name,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 1 */
|
2012-05-21 15:12:53 +08:00
|
|
|
},
|
2015-08-11 18:30:50 +08:00
|
|
|
{
|
|
|
|
.name = "cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/",
|
2023-05-03 06:38:18 +08:00
|
|
|
.valid = test__pmu_cpu_valid,
|
2015-08-11 18:30:50 +08:00
|
|
|
.check = test__checkevent_pmu_partial_time_callgraph,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 2 */
|
2015-08-11 18:30:50 +08:00
|
|
|
},
|
perf tests: Check that complex event name is parsed correctly
Extend regression testing to cover case of complex event names enabled
by the cset f92da71280fb ("perf record: Enable arbitrary event names
thru name= modifier").
Testing it:
# perf test
1: vmlinux symtab matches kallsyms : Skip
2: Detect openat syscall event : Ok
3: Detect openat syscall event on all cpus : Ok
4: Read samples using the mmap interface : Ok
5: Test data source output : Ok
6: Parse event definition strings : Ok <===!
7: Simple expression parser : Ok
...
Committer testing:
# perf test "event definition"
6: Parse event definition strings : Ok
# perf test -v 6 2> /tmp/before
# perf test -v 6 2> /tmp/after
# diff -u /tmp/before /tmp/after
--- /tmp/before 2018-06-19 10:50:21.485572638 -0300
+++ /tmp/after 2018-06-19 10:50:40.886572896 -0300
@@ -1,6 +1,6 @@
6: Parse event definition strings :
--- start ---
-test child forked, pid 24259
+test child forked, pid 24904
running test 0 'syscalls:sys_enter_openat'Using CPUID GenuineIntel-6-3D
registering plugin: /root/.traceevent/plugins/plugin_kvm.so
registering plugin: /root/.traceevent/plugins/plugin_hrtimer.so
@@ -136,9 +136,11 @@
running test 50 '4:0x6530160/name=numpmu/'
running test 51 'L1-dcache-misses/name=cachepmu/'
running test 52 'intel_pt//u'
+running test 53 'cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk'
running test 0 'cpu/config=10,config1,config2=3,period=1000/u'
running test 1 'cpu/config=1,name=krava/u,cpu/config=2/u'
running test 2 'cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/'
+running test 3 'cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2,umask=0x3/ukp'
el-capacity -> cpu/event=0x54,umask=0x2/
el-conflict -> cpu/event=0x54,umask=0x1/
el-start -> cpu/event=0xc8,umask=0x1/
#
Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/ad30b774-219b-7b80-c610-4e9e298cf8a7@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-06-19 16:45:40 +08:00
|
|
|
{
|
perf tests: Fix complex event name parsing
The 'umask' event parameter is unsupported on some architectures like
powerpc64.
This can be observed on a powerpc64le system running Fedora 27 as shown
below.
# perf test "Parse event definition strings" -v
6: Parse event definition strings :
--- start ---
test child forked, pid 45915
...
running test 3 'cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2,umask=0x3/ukp'Invalid event/parameter 'umask'
Invalid event/parameter 'umask'
failed to parse event 'cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2,umask=0x3/ukp', err 1, str 'unknown term'
event syntax error: '..,event=0x2,umask=0x3/ukp'
\___ unknown term
valid terms: event,mark,pmc,cache_sel,pmcxsel,unit,thresh_stop,thresh_start,combine,thresh_sel,thresh_cmp,sample_mode,config,config1,config2,name,period,freq,branch_type,time,call-graph,stack-size,no-inherit,inherit,max-stack,no-overwrite,overwrite,driver-config
mem_access -> cpu/event=0x10401e0/
running test 0 'config=10,config1,config2=3,umask=1'
test child finished with 1
---- end ----
Parse event definition strings: FAILED!
Committer testing:
After applying the patch these test passes and in verbose mode we get:
# perf test -v "event definition"
6: Parse event definition strings:
--- start ---
test child forked, pid 11061
running test 0 'syscalls:sys_enter_openat'Using CPUID GenuineIntel-6-9E
<SNIP>
running test 53 'cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk'
running test 0 'cpu/config=10,config1,config2=3,period=1000/u'
running test 1 'cpu/config=1,name=krava/u,cpu/config=2/u'
running test 2 'cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/'
running test 3 'cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2/ukp'
<SNIP>
test child finished with 0
---- end ----
Parse event definition strings: Ok
#
Suggested-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Fixes: 06dc5bf21f3f ("perf tests: Check that complex event name is parsed correctly")
Link: http://lkml.kernel.org/r/20180726105502.31670-1-sandipan@linux.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-07-26 18:55:02 +08:00
|
|
|
.name = "cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2/ukp",
|
2023-07-07 02:37:05 +08:00
|
|
|
.valid = test__pmu_cpu_event_valid,
|
perf tests: Check that complex event name is parsed correctly
Extend regression testing to cover case of complex event names enabled
by the cset f92da71280fb ("perf record: Enable arbitrary event names
thru name= modifier").
Testing it:
# perf test
1: vmlinux symtab matches kallsyms : Skip
2: Detect openat syscall event : Ok
3: Detect openat syscall event on all cpus : Ok
4: Read samples using the mmap interface : Ok
5: Test data source output : Ok
6: Parse event definition strings : Ok <===!
7: Simple expression parser : Ok
...
Committer testing:
# perf test "event definition"
6: Parse event definition strings : Ok
# perf test -v 6 2> /tmp/before
# perf test -v 6 2> /tmp/after
# diff -u /tmp/before /tmp/after
--- /tmp/before 2018-06-19 10:50:21.485572638 -0300
+++ /tmp/after 2018-06-19 10:50:40.886572896 -0300
@@ -1,6 +1,6 @@
6: Parse event definition strings :
--- start ---
-test child forked, pid 24259
+test child forked, pid 24904
running test 0 'syscalls:sys_enter_openat'Using CPUID GenuineIntel-6-3D
registering plugin: /root/.traceevent/plugins/plugin_kvm.so
registering plugin: /root/.traceevent/plugins/plugin_hrtimer.so
@@ -136,9 +136,11 @@
running test 50 '4:0x6530160/name=numpmu/'
running test 51 'L1-dcache-misses/name=cachepmu/'
running test 52 'intel_pt//u'
+running test 53 'cycles/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks'/Duk'
running test 0 'cpu/config=10,config1,config2=3,period=1000/u'
running test 1 'cpu/config=1,name=krava/u,cpu/config=2/u'
running test 2 'cpu/config=1,call-graph=fp,time,period=100000/,cpu/config=2,call-graph=no,time=0,period=2000/'
+running test 3 'cpu/name='COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks',period=0x1,event=0x2,umask=0x3/ukp'
el-capacity -> cpu/event=0x54,umask=0x2/
el-conflict -> cpu/event=0x54,umask=0x1/
el-start -> cpu/event=0xc8,umask=0x1/
#
Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/ad30b774-219b-7b80-c610-4e9e298cf8a7@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-06-19 16:45:40 +08:00
|
|
|
.check = test__checkevent_complex_name,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 3 */
|
perf parser: Add support to specify rXXX event with pmu
The current rXXXX event specification creates event under PERF_TYPE_RAW
pmu type. This change allows to use rXXXX within pmu syntax, so it's
type is used via the following syntax:
-e 'cpu/r3c/'
-e 'cpum_cf/r0/'
The XXXX number goes directly to perf_event_attr::config the same way as
in '-e rXXXX' event. The perf_event_attr::type is filled with pmu type.
Committer testing:
So, lets see what goes in perf_event_attr::config for, say, the
'instructions' PERF_TYPE_HARDWARE (0) event, first we should look at how
to encode this event as a PERF_TYPE_RAW event for this specific CPU, an
AMD Ryzen 5:
# cat /sys/devices/cpu/events/instructions
event=0xc0
#
Then try with it _and_ the instruction, just to see that they are close
enough:
# perf stat -e rc0,instructions sleep 1
Performance counter stats for 'sleep 1':
919,794 rc0
919,898 instructions
1.000754579 seconds time elapsed
0.000715000 seconds user
0.000000000 seconds sys
#
Now we should try, before this patch, the PMU event encoding:
# perf stat -e cpu/rc0/ sleep 1
event syntax error: 'cpu/rc0/'
\___ unknown term
valid terms: event,edge,inv,umask,cmask,config,config1,config2,name,period,percore
#
Now with this patch, the three ways of specifying the 'instructions' CPU
counter are accepted:
# perf stat -e cpu/rc0/,rc0,instructions sleep 1
Performance counter stats for 'sleep 1':
892,948 cpu/rc0/
893,052 rc0
893,156 instructions
1.000931819 seconds time elapsed
0.000916000 seconds user
0.000000000 seconds sys
#
Requested-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Link: http://lore.kernel.org/lkml/20200416221405.437788-1-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-04-17 06:14:05 +08:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "software/r1a/",
|
|
|
|
.check = test__checkevent_raw_pmu,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 4 */
|
perf parser: Add support to specify rXXX event with pmu
The current rXXXX event specification creates event under PERF_TYPE_RAW
pmu type. This change allows to use rXXXX within pmu syntax, so it's
type is used via the following syntax:
-e 'cpu/r3c/'
-e 'cpum_cf/r0/'
The XXXX number goes directly to perf_event_attr::config the same way as
in '-e rXXXX' event. The perf_event_attr::type is filled with pmu type.
Committer testing:
So, lets see what goes in perf_event_attr::config for, say, the
'instructions' PERF_TYPE_HARDWARE (0) event, first we should look at how
to encode this event as a PERF_TYPE_RAW event for this specific CPU, an
AMD Ryzen 5:
# cat /sys/devices/cpu/events/instructions
event=0xc0
#
Then try with it _and_ the instruction, just to see that they are close
enough:
# perf stat -e rc0,instructions sleep 1
Performance counter stats for 'sleep 1':
919,794 rc0
919,898 instructions
1.000754579 seconds time elapsed
0.000715000 seconds user
0.000000000 seconds sys
#
Now we should try, before this patch, the PMU event encoding:
# perf stat -e cpu/rc0/ sleep 1
event syntax error: 'cpu/rc0/'
\___ unknown term
valid terms: event,edge,inv,umask,cmask,config,config1,config2,name,period,percore
#
Now with this patch, the three ways of specifying the 'instructions' CPU
counter are accepted:
# perf stat -e cpu/rc0/,rc0,instructions sleep 1
Performance counter stats for 'sleep 1':
892,948 cpu/rc0/
893,052 rc0
893,156 instructions
1.000931819 seconds time elapsed
0.000916000 seconds user
0.000000000 seconds sys
#
Requested-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sumanth Korikkar <sumanthk@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Link: http://lore.kernel.org/lkml/20200416221405.437788-1-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2020-04-17 06:14:05 +08:00
|
|
|
},
|
2020-07-25 20:19:58 +08:00
|
|
|
{
|
|
|
|
.name = "software/r0x1a/",
|
|
|
|
.check = test__checkevent_raw_pmu,
|
2022-05-18 12:20:25 +08:00
|
|
|
/* 5 */
|
2020-07-25 20:19:58 +08:00
|
|
|
},
|
2023-05-03 06:38:30 +08:00
|
|
|
{
|
|
|
|
.name = "cpu/L1-dcache-load-miss/",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__checkevent_genhw,
|
|
|
|
/* 6 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "cpu/L1-dcache-load-miss/kp",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__checkevent_genhw_modifier,
|
|
|
|
/* 7 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "cpu/L1-dcache-misses,name=cachepmu/",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__checkevent_config_cache,
|
|
|
|
/* 8 */
|
|
|
|
},
|
2023-05-03 06:38:40 +08:00
|
|
|
{
|
|
|
|
.name = "cpu/instructions/",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__checkevent_symbolic_name,
|
|
|
|
/* 9 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "cpu/cycles,period=100000,config2/",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__checkevent_symbolic_name_config,
|
|
|
|
/* 0 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "cpu/instructions/h",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__checkevent_symbolic_name_modifier,
|
|
|
|
/* 1 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "cpu/instructions/G",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__checkevent_exclude_host_modifier,
|
|
|
|
/* 2 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "cpu/instructions/H",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__checkevent_exclude_guest_modifier,
|
|
|
|
/* 3 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "{cpu/instructions/k,cpu/cycles/upp}",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__group1,
|
|
|
|
/* 4 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "{cpu/cycles/u,cpu/instructions/kp}:p",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__group4,
|
|
|
|
/* 5 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "{cpu/cycles/,cpu/cache-misses/G}:H",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__group_gh1,
|
|
|
|
/* 6 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "{cpu/cycles/,cpu/cache-misses/H}:G",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__group_gh2,
|
|
|
|
/* 7 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "{cpu/cycles/G,cpu/cache-misses/H}:u",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__group_gh3,
|
|
|
|
/* 8 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "{cpu/cycles/G,cpu/cache-misses/H}:uG",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__group_gh4,
|
|
|
|
/* 9 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "{cpu/cycles/,cpu/cache-misses/,cpu/branch-misses/}:S",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__leader_sample1,
|
|
|
|
/* 0 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "{cpu/instructions/,cpu/branch-misses/}:Su",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__leader_sample2,
|
|
|
|
/* 1 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "cpu/instructions/uDp",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__checkevent_pinned_modifier,
|
|
|
|
/* 2 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "{cpu/cycles/,cpu/cache-misses/,cpu/branch-misses/}:D",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__pinned_group,
|
|
|
|
/* 3 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "cpu/instructions/I",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__checkevent_exclude_idle_modifier,
|
|
|
|
/* 4 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "cpu/instructions/kIG",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__checkevent_exclude_idle_modifier_1,
|
|
|
|
/* 5 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "cpu/cycles/u",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__sym_event_slash,
|
|
|
|
/* 6 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "cpu/cycles/k",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__sym_event_dc,
|
|
|
|
/* 7 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "cpu/instructions/uep",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__checkevent_exclusive_modifier,
|
|
|
|
/* 8 */
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "{cpu/cycles/,cpu/cache-misses/,cpu/branch-misses/}:e",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__exclusive_group,
|
|
|
|
/* 9 */
|
|
|
|
},
|
2023-05-03 06:38:41 +08:00
|
|
|
{
|
|
|
|
.name = "cpu/cycles,name=name/",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__term_equal_term,
|
|
|
|
/* 0 */
|
|
|
|
},
|
2023-05-03 06:38:42 +08:00
|
|
|
{
|
|
|
|
.name = "cpu/cycles,name=l1d/",
|
|
|
|
.valid = test__pmu_cpu_valid,
|
|
|
|
.check = test__term_equal_legacy,
|
|
|
|
/* 1 */
|
|
|
|
},
|
2012-05-21 15:12:49 +08:00
|
|
|
};
|
|
|
|
|
2013-01-19 03:56:57 +08:00
|
|
|
struct terms_test {
|
2012-06-15 14:31:42 +08:00
|
|
|
const char *str;
|
|
|
|
int (*check)(struct list_head *terms);
|
|
|
|
};
|
|
|
|
|
2022-05-18 12:20:24 +08:00
|
|
|
static const struct terms_test test__terms[] = {
|
2012-06-15 14:31:42 +08:00
|
|
|
[0] = {
|
2023-02-18 06:32:11 +08:00
|
|
|
.str = "config=10,config1,config2=3,config3=4,umask=1,read,r0xead",
|
2012-06-15 14:31:42 +08:00
|
|
|
.check = test__checkterms_simple,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-05-18 12:20:25 +08:00
|
|
|
static int test_event(const struct evlist_test *e)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
perf parse: Report initial event parsing error
Record the first event parsing error and report. Implementing feedback
from Jiri Olsa:
https://lkml.org/lkml/2019/10/28/680
An example error is:
$ tools/perf/perf stat -e c/c/
WARNING: multiple event parsing errors
event syntax error: 'c/c/'
\___ unknown term
valid terms: event,filter_rem,filter_opc0,edge,filter_isoc,filter_tid,filter_loc,filter_nc,inv,umask,filter_opc1,tid_en,thresh,filter_all_op,filter_not_nm,filter_state,filter_nm,config,config1,config2,name,period,percore
Initial error:
event syntax error: 'c/c/'
\___ Cannot find PMU `c'. Missing kernel support?
Run 'perf list' for a list of valid events
Usage: perf stat [<options>] [<command>]
-e, --event <event> event selector. use 'perf list' to list available events
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: Allison Randal <allison@lohutok.net>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Anju T Sudhakar <anju@linux.vnet.ibm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Davidlohr Bueso <dave@stgolabs.net>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Thomas Richter <tmricht@linux.ibm.com>
Link: http://lore.kernel.org/lkml/20191116074652.9960-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-11-16 15:46:52 +08:00
|
|
|
struct parse_events_error err;
|
2019-07-21 19:23:52 +08:00
|
|
|
struct evlist *evlist;
|
2012-05-21 15:12:49 +08:00
|
|
|
int ret;
|
|
|
|
|
2018-06-11 17:34:22 +08:00
|
|
|
if (e->valid && !e->valid()) {
|
2022-05-18 12:20:26 +08:00
|
|
|
pr_debug("... SKIP\n");
|
|
|
|
return TEST_OK;
|
2018-06-11 17:34:22 +08:00
|
|
|
}
|
|
|
|
|
2019-07-21 19:23:55 +08:00
|
|
|
evlist = evlist__new();
|
2022-05-18 12:20:26 +08:00
|
|
|
if (evlist == NULL) {
|
|
|
|
pr_err("Failed allocation");
|
|
|
|
return TEST_FAIL;
|
|
|
|
}
|
2021-11-07 17:00:01 +08:00
|
|
|
parse_events_error__init(&err);
|
2018-06-11 17:34:21 +08:00
|
|
|
ret = parse_events(evlist, e->name, &err);
|
2012-05-21 15:12:49 +08:00
|
|
|
if (ret) {
|
2018-06-11 17:34:21 +08:00
|
|
|
pr_debug("failed to parse event '%s', err %d, str '%s'\n",
|
|
|
|
e->name, ret, err.str);
|
2021-11-07 17:00:00 +08:00
|
|
|
parse_events_error__print(&err, e->name);
|
2022-05-18 12:20:26 +08:00
|
|
|
ret = TEST_FAIL;
|
2023-05-03 06:38:39 +08:00
|
|
|
if (err.str && strstr(err.str, "can't access trace events"))
|
2022-05-18 12:20:26 +08:00
|
|
|
ret = TEST_SKIP;
|
2014-01-04 04:30:04 +08:00
|
|
|
} else {
|
|
|
|
ret = e->check(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
2021-11-07 17:00:01 +08:00
|
|
|
parse_events_error__exit(&err);
|
2019-07-21 19:23:56 +08:00
|
|
|
evlist__delete(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-01-17 23:10:15 +08:00
|
|
|
static int test_event_fake_pmu(const char *str)
|
|
|
|
{
|
|
|
|
struct parse_events_error err;
|
|
|
|
struct evlist *evlist;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
evlist = evlist__new();
|
|
|
|
if (!evlist)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
parse_events_error__init(&err);
|
2023-05-03 06:38:36 +08:00
|
|
|
ret = __parse_events(evlist, str, /*pmu_filter=*/NULL, &err,
|
|
|
|
&perf_pmu__fake, /*warn_if_reordered=*/true);
|
2022-01-17 23:10:15 +08:00
|
|
|
if (ret) {
|
|
|
|
pr_debug("failed to parse event '%s', err %d, str '%s'\n",
|
|
|
|
str, ret, err.str);
|
|
|
|
parse_events_error__print(&err, str);
|
|
|
|
}
|
|
|
|
|
|
|
|
parse_events_error__exit(&err);
|
|
|
|
evlist__delete(evlist);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
static int combine_test_results(int existing, int latest)
|
|
|
|
{
|
|
|
|
if (existing == TEST_FAIL)
|
|
|
|
return TEST_FAIL;
|
|
|
|
if (existing == TEST_SKIP)
|
|
|
|
return latest == TEST_OK ? TEST_SKIP : latest;
|
|
|
|
return latest;
|
|
|
|
}
|
|
|
|
|
2022-05-18 12:20:25 +08:00
|
|
|
static int test_events(const struct evlist_test *events, int cnt)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2022-05-18 12:20:26 +08:00
|
|
|
int ret = TEST_OK;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2022-05-18 12:20:25 +08:00
|
|
|
for (int i = 0; i < cnt; i++) {
|
|
|
|
const struct evlist_test *e = &events[i];
|
2022-05-18 12:20:26 +08:00
|
|
|
int test_ret;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
pr_debug("running test %d '%s'\n", i, e->name);
|
|
|
|
test_ret = test_event(e);
|
|
|
|
if (test_ret != TEST_OK) {
|
|
|
|
pr_debug("Event test failure: test %d '%s'", i, e->name);
|
|
|
|
ret = combine_test_results(ret, test_ret);
|
|
|
|
}
|
2012-06-15 14:31:42 +08:00
|
|
|
}
|
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__events2(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
|
|
|
|
{
|
|
|
|
return test_events(test__events, ARRAY_SIZE(test__events));
|
2012-06-15 14:31:42 +08:00
|
|
|
}
|
|
|
|
|
2022-05-18 12:20:24 +08:00
|
|
|
static int test_term(const struct terms_test *t)
|
2012-06-15 14:31:42 +08:00
|
|
|
{
|
2013-07-03 03:27:24 +08:00
|
|
|
struct list_head terms;
|
2012-06-15 14:31:42 +08:00
|
|
|
int ret;
|
|
|
|
|
2013-07-03 03:27:24 +08:00
|
|
|
INIT_LIST_HEAD(&terms);
|
2012-06-15 14:31:42 +08:00
|
|
|
|
2013-07-03 03:27:24 +08:00
|
|
|
ret = parse_events_terms(&terms, t->str);
|
2012-06-15 14:31:42 +08:00
|
|
|
if (ret) {
|
|
|
|
pr_debug("failed to parse terms '%s', err %d\n",
|
|
|
|
t->str , ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-07-03 03:27:24 +08:00
|
|
|
ret = t->check(&terms);
|
2016-02-13 03:48:00 +08:00
|
|
|
parse_events_terms__purge(&terms);
|
2012-06-15 14:31:42 +08:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-05-18 12:20:24 +08:00
|
|
|
static int test_terms(const struct terms_test *terms, int cnt)
|
2012-06-15 14:31:42 +08:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2022-05-18 12:20:24 +08:00
|
|
|
for (int i = 0; i < cnt; i++) {
|
|
|
|
const struct terms_test *t = &terms[i];
|
2012-06-15 14:31:42 +08:00
|
|
|
|
|
|
|
pr_debug("running test %d '%s'\n", i, t->str);
|
|
|
|
ret = test_term(t);
|
2012-05-21 15:12:49 +08:00
|
|
|
if (ret)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
static int test__terms2(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
|
|
|
|
{
|
|
|
|
return test_terms(test__terms, ARRAY_SIZE(test__terms));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__pmu_events(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
|
2012-10-10 20:53:18 +08:00
|
|
|
{
|
2023-05-27 15:22:01 +08:00
|
|
|
struct perf_pmu *pmu = NULL;
|
2023-05-03 06:38:17 +08:00
|
|
|
int ret = TEST_OK;
|
2012-10-10 20:53:18 +08:00
|
|
|
|
2023-05-27 15:22:03 +08:00
|
|
|
while ((pmu = perf_pmus__scan(pmu)) != NULL) {
|
2023-05-03 06:38:17 +08:00
|
|
|
struct stat st;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
struct dirent *ent;
|
|
|
|
DIR *dir;
|
|
|
|
int err;
|
2012-10-10 20:53:18 +08:00
|
|
|
|
2023-05-03 06:38:17 +08:00
|
|
|
snprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s/events/",
|
|
|
|
sysfs__mountpoint(), pmu->name);
|
2012-10-10 20:53:18 +08:00
|
|
|
|
2023-05-03 06:38:17 +08:00
|
|
|
err = stat(path, &st);
|
|
|
|
if (err) {
|
|
|
|
pr_debug("skipping PMU %s events tests: %s\n", pmu->name, path);
|
|
|
|
continue;
|
|
|
|
}
|
2012-10-10 20:53:18 +08:00
|
|
|
|
2023-05-03 06:38:17 +08:00
|
|
|
dir = opendir(path);
|
|
|
|
if (!dir) {
|
|
|
|
pr_debug("can't open pmu event dir: %s\n", path);
|
|
|
|
ret = combine_test_results(ret, TEST_SKIP);
|
2012-10-10 20:53:18 +08:00
|
|
|
continue;
|
2023-05-03 06:38:17 +08:00
|
|
|
}
|
2012-10-10 20:53:18 +08:00
|
|
|
|
2023-05-03 06:38:17 +08:00
|
|
|
while ((ent = readdir(dir))) {
|
|
|
|
struct evlist_test e = { .name = NULL, };
|
|
|
|
char name[2 * NAME_MAX + 1 + 12 + 3];
|
|
|
|
int test_ret;
|
2012-10-10 20:53:18 +08:00
|
|
|
|
2023-05-03 06:38:17 +08:00
|
|
|
/* Names containing . are special and cannot be used directly */
|
|
|
|
if (strchr(ent->d_name, '.'))
|
|
|
|
continue;
|
2012-10-10 20:53:18 +08:00
|
|
|
|
2023-05-03 06:38:17 +08:00
|
|
|
snprintf(name, sizeof(name), "%s/event=%s/u", pmu->name, ent->d_name);
|
2022-10-13 09:12:05 +08:00
|
|
|
|
2023-05-03 06:38:17 +08:00
|
|
|
e.name = name;
|
|
|
|
e.check = test__checkevent_pmu_events;
|
|
|
|
|
|
|
|
test_ret = test_event(&e);
|
|
|
|
if (test_ret != TEST_OK) {
|
|
|
|
pr_debug("Test PMU event failed for '%s'", name);
|
|
|
|
ret = combine_test_results(ret, test_ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_pmu_core(pmu->name))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Names containing '-' are recognized as prefixes and suffixes
|
|
|
|
* due to '-' being a legacy PMU separator. This fails when the
|
|
|
|
* prefix or suffix collides with an existing legacy token. For
|
|
|
|
* example, branch-brs has a prefix (branch) that collides with
|
|
|
|
* a PE_NAME_CACHE_TYPE token causing a parse error as a suffix
|
|
|
|
* isn't expected after this. As event names in the config
|
|
|
|
* slashes are allowed a '-' in the name we check this works
|
|
|
|
* above.
|
|
|
|
*/
|
|
|
|
if (strchr(ent->d_name, '-'))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
snprintf(name, sizeof(name), "%s:u,%s/event=%s/u",
|
|
|
|
ent->d_name, pmu->name, ent->d_name);
|
|
|
|
e.name = name;
|
|
|
|
e.check = test__checkevent_pmu_events_mix;
|
|
|
|
test_ret = test_event(&e);
|
|
|
|
if (test_ret != TEST_OK) {
|
|
|
|
pr_debug("Test PMU event failed for '%s'", name);
|
|
|
|
ret = combine_test_results(ret, test_ret);
|
|
|
|
}
|
2022-05-18 12:20:26 +08:00
|
|
|
}
|
2012-10-10 20:53:18 +08:00
|
|
|
|
2023-05-03 06:38:17 +08:00
|
|
|
closedir(dir);
|
|
|
|
}
|
2012-10-10 20:53:18 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
static int test__pmu_events2(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
|
|
|
|
{
|
|
|
|
return test_events(test__events_pmu, ARRAY_SIZE(test__events_pmu));
|
|
|
|
}
|
|
|
|
|
2021-09-02 14:59:55 +08:00
|
|
|
static bool test_alias(char **event, char **alias)
|
|
|
|
{
|
|
|
|
char path[PATH_MAX];
|
|
|
|
DIR *dir;
|
|
|
|
struct dirent *dent;
|
|
|
|
const char *sysfs = sysfs__mountpoint();
|
|
|
|
char buf[128];
|
|
|
|
FILE *file;
|
|
|
|
|
|
|
|
if (!sysfs)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
snprintf(path, PATH_MAX, "%s/bus/event_source/devices/", sysfs);
|
|
|
|
dir = opendir(path);
|
|
|
|
if (!dir)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
while ((dent = readdir(dir))) {
|
|
|
|
if (!strcmp(dent->d_name, ".") ||
|
|
|
|
!strcmp(dent->d_name, ".."))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
snprintf(path, PATH_MAX, "%s/bus/event_source/devices/%s/alias",
|
|
|
|
sysfs, dent->d_name);
|
|
|
|
|
|
|
|
if (!file_available(path))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
file = fopen(path, "r");
|
|
|
|
if (!file)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (!fgets(buf, sizeof(buf), file)) {
|
|
|
|
fclose(file);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Remove the last '\n' */
|
|
|
|
buf[strlen(buf) - 1] = 0;
|
|
|
|
|
|
|
|
fclose(file);
|
|
|
|
*event = strdup(dent->d_name);
|
|
|
|
*alias = strdup(buf);
|
|
|
|
closedir(dir);
|
|
|
|
|
|
|
|
if (*event == NULL || *alias == NULL) {
|
|
|
|
free(*event);
|
|
|
|
free(*alias);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
closedir(dir);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_pmu_events_alias(struct evlist *evlist)
|
|
|
|
{
|
|
|
|
struct evsel *evsel1 = evlist__first(evlist);
|
|
|
|
struct evsel *evsel2 = evlist__last(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong type", evsel1->core.attr.type == evsel2->core.attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", evsel1->core.attr.config == evsel2->core.attr.config);
|
2022-05-18 12:20:26 +08:00
|
|
|
return TEST_OK;
|
2021-09-02 14:59:55 +08:00
|
|
|
}
|
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
static int test__pmu_events_alias(char *event, char *alias)
|
2021-09-02 14:59:55 +08:00
|
|
|
{
|
2022-05-18 12:20:25 +08:00
|
|
|
struct evlist_test e = { .name = NULL, };
|
2021-09-02 14:59:55 +08:00
|
|
|
char name[2 * NAME_MAX + 20];
|
|
|
|
|
|
|
|
snprintf(name, sizeof(name), "%s/event=1/,%s/event=1/",
|
|
|
|
event, alias);
|
|
|
|
|
|
|
|
e.name = name;
|
|
|
|
e.check = test__checkevent_pmu_events_alias;
|
|
|
|
return test_event(&e);
|
|
|
|
}
|
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
static int test__alias(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
|
2022-01-17 23:10:15 +08:00
|
|
|
{
|
2022-05-18 12:20:26 +08:00
|
|
|
char *event, *alias;
|
|
|
|
int ret;
|
2022-01-17 23:10:15 +08:00
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
if (!test_alias(&event, &alias))
|
|
|
|
return TEST_SKIP;
|
2022-01-17 23:10:15 +08:00
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
ret = test__pmu_events_alias(event, alias);
|
|
|
|
|
|
|
|
free(event);
|
|
|
|
free(alias);
|
2022-01-17 23:10:15 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
static int test__pmu_events_alias2(struct test_suite *test __maybe_unused,
|
|
|
|
int subtest __maybe_unused)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2022-05-18 12:20:26 +08:00
|
|
|
static const char events[][30] = {
|
|
|
|
"event-hyphen",
|
|
|
|
"event-two-hyph",
|
|
|
|
};
|
|
|
|
int ret = TEST_OK;
|
2012-10-10 20:53:18 +08:00
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
for (unsigned int i = 0; i < ARRAY_SIZE(events); i++) {
|
|
|
|
int test_ret = test_event_fake_pmu(&events[i][0]);
|
2021-09-02 14:59:55 +08:00
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
if (test_ret != TEST_OK) {
|
|
|
|
pr_debug("check_parse_fake %s failed\n", &events[i][0]);
|
|
|
|
ret = combine_test_results(ret, test_ret);
|
|
|
|
}
|
2021-09-02 14:59:55 +08:00
|
|
|
}
|
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
return ret;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
2021-11-04 14:41:50 +08:00
|
|
|
|
2022-05-18 12:20:26 +08:00
|
|
|
static struct test_case tests__parse_events[] = {
|
|
|
|
TEST_CASE_REASON("Test event parsing",
|
|
|
|
events2,
|
|
|
|
"permissions"),
|
|
|
|
TEST_CASE_REASON("Parsing of all PMU events from sysfs",
|
|
|
|
pmu_events,
|
|
|
|
"permissions"),
|
|
|
|
TEST_CASE_REASON("Parsing of given PMU events from sysfs",
|
|
|
|
pmu_events2,
|
|
|
|
"permissions"),
|
|
|
|
TEST_CASE_REASON("Parsing of aliased events from sysfs", alias,
|
|
|
|
"no aliases in sysfs"),
|
|
|
|
TEST_CASE("Parsing of aliased events", pmu_events_alias2),
|
|
|
|
TEST_CASE("Parsing of terms (event modifiers)", terms2),
|
|
|
|
{ .name = NULL, }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct test_suite suite__parse_events = {
|
|
|
|
.desc = "Parse event definition strings",
|
|
|
|
.test_cases = tests__parse_events,
|
|
|
|
};
|