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"
|
2015-10-19 23:23:49 +08:00
|
|
|
#include "util.h"
|
2017-04-18 23:26:44 +08:00
|
|
|
#include <dirent.h>
|
2017-04-18 21:46:11 +08:00
|
|
|
#include <errno.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)
|
|
|
|
|
2012-05-21 15:12:49 +08:00
|
|
|
static int test__checkevent_tracepoint(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_type",
|
2012-08-01 20:48:58 +08:00
|
|
|
PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_tracepoint_multi(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1);
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 0 == evlist->nr_groups);
|
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",
|
|
|
|
PERF_TYPE_TRACEPOINT == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_type",
|
2012-08-01 20:48:58 +08:00
|
|
|
PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_period",
|
|
|
|
1 == evsel->attr.sample_period);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_raw(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 0x1a == evsel->attr.config);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_numeric(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_symbolic_name(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
2015-07-29 17:42:11 +08:00
|
|
|
/*
|
|
|
|
* The period value gets configured within perf_evlist__config,
|
|
|
|
* while this test executes only parse events method.
|
|
|
|
*/
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong period",
|
2015-07-29 17:42:11 +08:00
|
|
|
0 == evsel->attr.sample_period);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong config1",
|
|
|
|
0 == evsel->attr.config1);
|
|
|
|
TEST_ASSERT_VAL("wrong config2",
|
|
|
|
1 == evsel->attr.config2);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_symbolic_alias(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_genhw(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HW_CACHE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", (1 << 16) == evsel->attr.config);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_breakpoint(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
|
|
|
|
evsel->attr.bp_type);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_4 ==
|
|
|
|
evsel->attr.bp_len);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_breakpoint_x(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_type",
|
|
|
|
HW_BREAKPOINT_X == evsel->attr.bp_type);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_len", sizeof(long) == evsel->attr.bp_len);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_breakpoint_r(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type",
|
|
|
|
PERF_TYPE_BREAKPOINT == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_type",
|
|
|
|
HW_BREAKPOINT_R == evsel->attr.bp_type);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_len",
|
|
|
|
HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_breakpoint_w(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type",
|
|
|
|
PERF_TYPE_BREAKPOINT == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_type",
|
|
|
|
HW_BREAKPOINT_W == evsel->attr.bp_type);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_len",
|
|
|
|
HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-06-29 15:22:54 +08:00
|
|
|
static int test__checkevent_breakpoint_rw(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-06-29 15:22:54 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type",
|
|
|
|
PERF_TYPE_BREAKPOINT == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_type",
|
|
|
|
(HW_BREAKPOINT_R|HW_BREAKPOINT_W) == evsel->attr.bp_type);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_len",
|
|
|
|
HW_BREAKPOINT_LEN_4 == evsel->attr.bp_len);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-21 15:12:49 +08:00
|
|
|
static int test__checkevent_tracepoint_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
return test__checkevent_tracepoint(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
test__checkevent_tracepoint_multi_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", evlist->nr_entries > 1);
|
|
|
|
|
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 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);
|
|
|
|
}
|
|
|
|
|
|
|
|
return test__checkevent_tracepoint_multi(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_raw_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
return test__checkevent_raw(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_numeric_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
return test__checkevent_numeric(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_symbolic_name_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
return test__checkevent_symbolic_name(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_exclude_host_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
|
|
|
|
|
|
|
|
return test__checkevent_symbolic_name(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_exclude_guest_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
|
|
|
|
return test__checkevent_symbolic_name(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_symbolic_alias_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
return test__checkevent_symbolic_alias(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_genhw_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
return test__checkevent_genhw(evlist);
|
|
|
|
}
|
|
|
|
|
2015-04-08 05:25:14 +08:00
|
|
|
static int test__checkevent_exclude_idle_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong exclude idle", evsel->attr.exclude_idle);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
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);
|
|
|
|
|
|
|
|
return test__checkevent_symbolic_name(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_exclude_idle_modifier_1(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong exclude idle", evsel->attr.exclude_idle);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
|
|
|
|
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);
|
|
|
|
|
|
|
|
return test__checkevent_symbolic_name(evlist);
|
|
|
|
}
|
|
|
|
|
2012-05-21 15:12:49 +08:00
|
|
|
static int test__checkevent_breakpoint_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
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-06-29 05:18:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name",
|
2012-08-17 03:10:21 +08:00
|
|
|
!strcmp(perf_evsel__name(evsel), "mem:0:u"));
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
return test__checkevent_breakpoint(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_breakpoint_x_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
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-06-29 05:18:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name",
|
2012-08-17 03:10:21 +08:00
|
|
|
!strcmp(perf_evsel__name(evsel), "mem:0:x:k"));
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
return test__checkevent_breakpoint_x(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_breakpoint_r_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
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-06-29 05:18:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name",
|
2012-08-17 03:10:21 +08:00
|
|
|
!strcmp(perf_evsel__name(evsel), "mem:0:r:hp"));
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
return test__checkevent_breakpoint_r(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_breakpoint_w_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
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-06-29 05:18:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name",
|
2012-08-17 03:10:21 +08:00
|
|
|
!strcmp(perf_evsel__name(evsel), "mem:0:w:up"));
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
return test__checkevent_breakpoint_w(evlist);
|
|
|
|
}
|
|
|
|
|
2012-06-29 15:22:54 +08:00
|
|
|
static int test__checkevent_breakpoint_rw_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-06-29 15:22:54 +08:00
|
|
|
|
|
|
|
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-06-29 05:18:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name",
|
2012-08-17 03:10:21 +08:00
|
|
|
!strcmp(perf_evsel__name(evsel), "mem:0:rw:kp"));
|
2012-06-29 15:22:54 +08:00
|
|
|
|
|
|
|
return test__checkevent_breakpoint_rw(evlist);
|
|
|
|
}
|
|
|
|
|
2012-05-21 15:12:49 +08:00
|
|
|
static int test__checkevent_pmu(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config);
|
|
|
|
TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1);
|
|
|
|
TEST_ASSERT_VAL("wrong config2", 3 == evsel->attr.config2);
|
2015-07-29 17:42:11 +08:00
|
|
|
/*
|
|
|
|
* The period value gets configured within perf_evlist__config,
|
|
|
|
* while this test executes only parse events method.
|
|
|
|
*/
|
|
|
|
TEST_ASSERT_VAL("wrong period", 0 == evsel->attr.sample_period);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_list(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
|
|
|
|
|
|
|
|
/* r1 */
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
|
|
|
|
TEST_ASSERT_VAL("wrong config1", 0 == evsel->attr.config1);
|
|
|
|
TEST_ASSERT_VAL("wrong config2", 0 == evsel->attr.config2);
|
|
|
|
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);
|
|
|
|
|
2015-04-16 21:52:53 +08:00
|
|
|
/* syscalls:sys_enter_openat:k */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = perf_evsel__next(evsel);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_type",
|
2012-08-01 20:48:58 +08:00
|
|
|
PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period);
|
|
|
|
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);
|
|
|
|
|
|
|
|
/* 1:1:hp */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = perf_evsel__next(evsel);
|
2012-05-21 15:12:49 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
|
|
|
|
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);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-21 15:12:53 +08:00
|
|
|
static int test__checkevent_pmu_name(struct perf_evlist *evlist)
|
|
|
|
{
|
2012-08-15 03:42:15 +08:00
|
|
|
struct perf_evsel *evsel = perf_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 */
|
2012-05-21 15:12:53 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
|
2012-06-13 00:55:13 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name", !strcmp(perf_evsel__name(evsel), "krava"));
|
2012-05-21 15:12:53 +08:00
|
|
|
|
2012-06-21 18:25:16 +08:00
|
|
|
/* cpu/config=2/u" */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = perf_evsel__next(evsel);
|
2012-05-21 15:12:53 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config);
|
2012-06-21 18:25:16 +08:00
|
|
|
TEST_ASSERT_VAL("wrong name",
|
2012-08-17 03:10:21 +08:00
|
|
|
!strcmp(perf_evsel__name(evsel), "cpu/config=2/u"));
|
2012-05-21 15:12:53 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-08-11 18:30:50 +08:00
|
|
|
static int test__checkevent_pmu_partial_time_callgraph(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
/* cpu/config=1,call-graph=fp,time,period=100000/ */
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 1 == evsel->attr.config);
|
|
|
|
/*
|
|
|
|
* The period, time and callgraph value gets configured
|
|
|
|
* within perf_evlist__config,
|
|
|
|
* while this test executes only parse events method.
|
|
|
|
*/
|
|
|
|
TEST_ASSERT_VAL("wrong period", 0 == evsel->attr.sample_period);
|
2018-05-29 03:00:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong callgraph", !evsel__has_callchain(evsel));
|
2015-08-11 18:30:50 +08:00
|
|
|
TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->attr.sample_type));
|
|
|
|
|
|
|
|
/* cpu/config=2,call-graph=no,time=0,period=2000/ */
|
|
|
|
evsel = perf_evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 2 == evsel->attr.config);
|
|
|
|
/*
|
|
|
|
* The period, time and callgraph value gets configured
|
|
|
|
* within perf_evlist__config,
|
|
|
|
* while this test executes only parse events method.
|
|
|
|
*/
|
|
|
|
TEST_ASSERT_VAL("wrong period", 0 == evsel->attr.sample_period);
|
2018-05-29 03:00:29 +08:00
|
|
|
TEST_ASSERT_VAL("wrong callgraph", !evsel__has_callchain(evsel));
|
2015-08-11 18:30:50 +08:00
|
|
|
TEST_ASSERT_VAL("wrong time", !(PERF_SAMPLE_TIME & evsel->attr.sample_type));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-10 20:53:18 +08:00
|
|
|
static int test__checkevent_pmu_events(struct perf_evlist *evlist)
|
|
|
|
{
|
2013-11-14 02:54:30 +08:00
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
2012-10-10 20:53:18 +08:00
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
|
|
|
|
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);
|
2013-08-06 21:28:06 +08:00
|
|
|
TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned);
|
2012-10-10 20:53:18 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
static int test__checkevent_pmu_events_mix(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
/* pmu-event:u */
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
|
|
|
|
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);
|
|
|
|
TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned);
|
|
|
|
|
|
|
|
/* cpu/pmu-event/u*/
|
|
|
|
evsel = perf_evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->attr.type);
|
|
|
|
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);
|
|
|
|
TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
TEST_ASSERT_VAL("wrong config", !term->config);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
TEST_ASSERT_VAL("wrong config", !term->config);
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
TEST_ASSERT_VAL("wrong config", !term->config);
|
|
|
|
|
|
|
|
/* 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"));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-08 18:23:52 +08:00
|
|
|
static int test__group1(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* instructions:k */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = leader = perf_evlist__first(evlist);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
2012-11-29 14:38:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* cycles:upp */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = perf_evsel__next(evsel);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
|
|
|
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);
|
2012-10-21 00:29:34 +08:00
|
|
|
/* use of precise requires exclude_guest */
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__group2(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* faults + :ku modifier */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = leader = perf_evlist__first(evlist);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_SW_PAGE_FAULTS == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
2012-11-29 14:38:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* cache-references + :u modifier */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = perf_evsel__next(evsel);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CACHE_REFERENCES == evsel->attr.config);
|
|
|
|
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);
|
2013-02-04 17:56:43 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* cycles:k */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = perf_evsel__next(evsel);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
2012-11-29 14:38:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-11 06:15:03 +08:00
|
|
|
static int test__group3(struct perf_evlist *evlist __maybe_unused)
|
2012-08-08 18:23:52 +08:00
|
|
|
{
|
|
|
|
struct perf_evsel *evsel, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries);
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
2015-04-16 21:52:53 +08:00
|
|
|
/* group1 syscalls:sys_enter_openat:H */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = leader = perf_evlist__first(evlist);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_TRACEPOINT == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_type",
|
|
|
|
PERF_TP_SAMPLE_TYPE == evsel->attr.sample_type);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_period", 1 == evsel->attr.sample_period);
|
|
|
|
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 exclude guest", evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
2012-11-29 14:38:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong group name",
|
|
|
|
!strcmp(leader->group_name, "group1"));
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* group1 cycles:kppp */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = perf_evsel__next(evsel);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
|
|
|
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);
|
2012-10-21 00:29:34 +08:00
|
|
|
/* use of precise requires exclude_guest */
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 3);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* group2 cycles + G modifier */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = leader = perf_evsel__next(evsel);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
2012-11-29 14:38:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong group name",
|
|
|
|
!strcmp(leader->group_name, "group2"));
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* group2 1:3 + G modifier */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = perf_evsel__next(evsel);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", 1 == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 3 == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* instructions:u */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = perf_evsel__next(evsel);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
2012-11-29 14:38:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-11 06:15:03 +08:00
|
|
|
static int test__group4(struct perf_evlist *evlist __maybe_unused)
|
2012-08-08 18:23:52 +08:00
|
|
|
{
|
|
|
|
struct perf_evsel *evsel, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* cycles:u + p */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = leader = perf_evlist__first(evlist);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
|
|
|
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);
|
2012-10-21 00:29:34 +08:00
|
|
|
/* use of precise requires exclude_guest */
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 1);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
2012-11-29 14:38:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* instructions:kp + p */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = perf_evsel__next(evsel);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
|
|
|
|
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);
|
2012-10-21 00:29:34 +08:00
|
|
|
/* use of precise requires exclude_guest */
|
|
|
|
TEST_ASSERT_VAL("wrong exclude guest", evsel->attr.exclude_guest);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", evsel->attr.precise_ip == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-11 06:15:03 +08:00
|
|
|
static int test__group5(struct perf_evlist *evlist __maybe_unused)
|
2012-08-08 18:23:52 +08:00
|
|
|
{
|
|
|
|
struct perf_evsel *evsel, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 5 == evlist->nr_entries);
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 2 == evlist->nr_groups);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* cycles + G */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = leader = perf_evlist__first(evlist);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
2012-11-29 14:38:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* instructions + G */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = perf_evsel__next(evsel);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* cycles:G */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = leader = perf_evsel__next(evsel);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
2012-11-29 14:38:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
|
2013-02-02 03:37:11 +08:00
|
|
|
TEST_ASSERT_VAL("wrong sample_read", !evsel->sample_read);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* instructions:G */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = perf_evsel__next(evsel);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
2013-01-22 17:09:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
/* cycles */
|
2012-08-15 03:42:15 +08:00
|
|
|
evsel = perf_evsel__next(evsel);
|
2012-08-08 18:23:52 +08:00
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
|
|
|
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 exclude guest", evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
2012-11-29 14:38:30 +08:00
|
|
|
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
|
2012-08-08 18:23:52 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-04 17:56:43 +08:00
|
|
|
static int test__group_gh1(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
|
|
|
|
|
|
|
|
/* cycles + :H group modifier */
|
|
|
|
evsel = leader = perf_evlist__first(evlist);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
|
|
|
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 exclude guest", evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
|
|
|
|
|
|
|
|
/* cache-misses:G + :H group modifier */
|
|
|
|
evsel = perf_evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__group_gh2(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
|
|
|
|
|
|
|
|
/* cycles + :G group modifier */
|
|
|
|
evsel = leader = perf_evlist__first(evlist);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
|
|
|
|
|
|
|
|
/* cache-misses:H + :G group modifier */
|
|
|
|
evsel = perf_evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__group_gh3(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
|
|
|
|
|
|
|
|
/* cycles:G + :u group modifier */
|
|
|
|
evsel = leader = perf_evlist__first(evlist);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
|
|
|
|
|
|
|
|
/* cache-misses:H + :u group modifier */
|
|
|
|
evsel = perf_evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config);
|
|
|
|
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 exclude guest", evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__group_gh4(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong number of groups", 1 == evlist->nr_groups);
|
|
|
|
|
|
|
|
/* cycles:G + :uG group modifier */
|
|
|
|
evsel = leader = perf_evlist__first(evlist);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", perf_evsel__is_group_leader(evsel));
|
|
|
|
TEST_ASSERT_VAL("wrong nr_members", evsel->nr_members == 2);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 0);
|
|
|
|
|
|
|
|
/* cache-misses:H + :uG group modifier */
|
|
|
|
evsel = perf_evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config);
|
|
|
|
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 exclude guest", !evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
|
|
|
TEST_ASSERT_VAL("wrong group_idx", perf_evsel__group_idx(evsel) == 1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-02 03:37:11 +08:00
|
|
|
static int test__leader_sample1(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
|
|
|
|
|
|
|
|
/* cycles - sampling group leader */
|
|
|
|
evsel = leader = perf_evlist__first(evlist);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
|
|
|
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 exclude guest", evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
|
|
|
|
|
|
|
|
/* cache-misses - not sampling */
|
|
|
|
evsel = perf_evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config);
|
|
|
|
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 exclude guest", evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
|
|
|
|
|
|
|
|
/* branch-misses - not sampling */
|
|
|
|
evsel = perf_evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config);
|
|
|
|
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 exclude guest", evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__leader_sample2(struct perf_evlist *evlist __maybe_unused)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
|
|
|
|
|
|
|
|
/* instructions - sampling group leader */
|
|
|
|
evsel = leader = perf_evlist__first(evlist);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_INSTRUCTIONS == evsel->attr.config);
|
|
|
|
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 exclude guest", evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
|
|
|
|
|
|
|
|
/* branch-misses - not sampling */
|
|
|
|
evsel = perf_evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config);
|
|
|
|
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 exclude guest", evsel->attr.exclude_guest);
|
|
|
|
TEST_ASSERT_VAL("wrong exclude host", !evsel->attr.exclude_host);
|
|
|
|
TEST_ASSERT_VAL("wrong precise_ip", !evsel->attr.precise_ip);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
|
|
|
TEST_ASSERT_VAL("wrong sample_read", evsel->sample_read);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-08-06 21:28:06 +08:00
|
|
|
static int test__checkevent_pinned_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
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);
|
|
|
|
TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned);
|
|
|
|
|
|
|
|
return test__checkevent_symbolic_name(evlist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__pinned_group(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel, *leader;
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 3 == evlist->nr_entries);
|
|
|
|
|
|
|
|
/* cycles - group leader */
|
|
|
|
evsel = leader = perf_evlist__first(evlist);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
|
|
|
|
TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
|
|
|
|
TEST_ASSERT_VAL("wrong leader", evsel->leader == leader);
|
|
|
|
TEST_ASSERT_VAL("wrong pinned", evsel->attr.pinned);
|
|
|
|
|
|
|
|
/* cache-misses - can not be pinned, but will go on with the leader */
|
|
|
|
evsel = perf_evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_CACHE_MISSES == evsel->attr.config);
|
|
|
|
TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned);
|
|
|
|
|
|
|
|
/* branch-misses - ditto */
|
|
|
|
evsel = perf_evsel__next(evsel);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_HW_BRANCH_MISSES == evsel->attr.config);
|
|
|
|
TEST_ASSERT_VAL("wrong pinned", !evsel->attr.pinned);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-05-29 23:26:52 +08:00
|
|
|
static int test__checkevent_breakpoint_len(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_type", (HW_BREAKPOINT_R | HW_BREAKPOINT_W) ==
|
|
|
|
evsel->attr.bp_type);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_1 ==
|
|
|
|
evsel->attr.bp_len);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_breakpoint_len_w(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config", 0 == evsel->attr.config);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_type", HW_BREAKPOINT_W ==
|
|
|
|
evsel->attr.bp_type);
|
|
|
|
TEST_ASSERT_VAL("wrong bp_len", HW_BREAKPOINT_LEN_2 ==
|
|
|
|
evsel->attr.bp_len);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
test__checkevent_breakpoint_len_rw_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
return test__checkevent_breakpoint_rw(evlist);
|
|
|
|
}
|
|
|
|
|
2015-10-06 02:06:06 +08:00
|
|
|
static int test__checkevent_precise_max_modifier(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong number of entries", 2 == evlist->nr_entries);
|
|
|
|
TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->attr.type);
|
|
|
|
TEST_ASSERT_VAL("wrong config",
|
|
|
|
PERF_COUNT_SW_TASK_CLOCK == evsel->attr.config);
|
|
|
|
return 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
|
|
|
static int test__checkevent_config_symbol(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "insn") == 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_config_raw(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "rawpmu") == 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__checkevent_config_num(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "numpmu") == 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-02-19 19:44:01 +08:00
|
|
|
static int test__checkevent_config_cache(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "cachepmu") == 0);
|
|
|
|
return 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
|
|
|
|
2018-06-11 17:34:22 +08:00
|
|
|
static bool test__intel_pt_valid(void)
|
|
|
|
{
|
|
|
|
return !!perf_pmu__find("intel_pt");
|
|
|
|
}
|
|
|
|
|
2018-05-11 22:48:54 +08:00
|
|
|
static int test__intel_pt(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "intel_pt//u") == 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static int test__checkevent_complex_name(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
struct perf_evsel *evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
|
|
TEST_ASSERT_VAL("wrong complex name parsing", strcmp(evsel->name, "COMPLEX_CYCLES_NAME:orig=cycles,desc=chip-clock-ticks") == 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test__all_tracepoints(struct perf_evlist *evlist)
|
|
|
|
{
|
|
|
|
TEST_ASSERT_VAL("wrong events count",
|
|
|
|
count_tracepoints() == evlist->nr_entries);
|
|
|
|
|
|
|
|
return test__checkevent_tracepoint_multi(evlist);
|
|
|
|
}
|
|
|
|
|
2013-01-19 03:56:57 +08:00
|
|
|
struct evlist_test {
|
2012-05-21 15:12:49 +08:00
|
|
|
const char *name;
|
|
|
|
__u32 type;
|
2014-04-25 23:34:06 +08:00
|
|
|
const int id;
|
2018-06-11 17:34:22 +08:00
|
|
|
bool (*valid)(void);
|
2012-05-21 15:12:49 +08:00
|
|
|
int (*check)(struct perf_evlist *evlist);
|
|
|
|
};
|
|
|
|
|
2013-01-19 03:56:57 +08:00
|
|
|
static struct evlist_test test__events[] = {
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 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 = "r1a",
|
|
|
|
.check = test__checkevent_raw,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 10,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 11,
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 12,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 13,
|
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 = "r1a:kp",
|
|
|
|
.check = test__checkevent_raw_modifier,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 14,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 15,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 16,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 17,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 18,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 19,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 20,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 21,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 22,
|
2012-05-21 15:12:49 +08:00
|
|
|
},
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 23,
|
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:G",
|
|
|
|
.check = test__checkevent_exclude_host_modifier,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 24,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 25,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 26,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 27,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 28,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 29,
|
2012-08-08 18:23:52 +08:00
|
|
|
},
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 30,
|
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:u,instructions:kp}:p",
|
|
|
|
.check = test__group4,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 31,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 32,
|
2012-08-08 18:23:52 +08:00
|
|
|
},
|
2014-04-25 23:34:06 +08:00
|
|
|
{
|
2012-12-17 21:08:38 +08:00
|
|
|
.name = "*:*",
|
|
|
|
.check = test__all_tracepoints,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 33,
|
2012-12-17 21:08:38 +08:00
|
|
|
},
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 34,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 35,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 36,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 37,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 38,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 39,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 40,
|
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,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 41,
|
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,
|
|
|
|
.id = 42,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0/2:w",
|
|
|
|
.check = test__checkevent_breakpoint_len_w,
|
|
|
|
.id = 43,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "mem:0/4:rw:u",
|
|
|
|
.check = test__checkevent_breakpoint_len_rw_modifier,
|
|
|
|
.id = 44
|
|
|
|
},
|
2014-04-25 23:34:07 +08:00
|
|
|
#if defined(__s390x__)
|
|
|
|
{
|
|
|
|
.name = "kvm-s390:kvm_s390_create_vm",
|
|
|
|
.check = test__checkevent_tracepoint,
|
|
|
|
.id = 100,
|
|
|
|
},
|
|
|
|
#endif
|
2015-04-08 05:25:14 +08:00
|
|
|
{
|
|
|
|
.name = "instructions:I",
|
|
|
|
.check = test__checkevent_exclude_idle_modifier,
|
|
|
|
.id = 45,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "instructions:kIG",
|
|
|
|
.check = test__checkevent_exclude_idle_modifier_1,
|
|
|
|
.id = 46,
|
|
|
|
},
|
2015-10-06 02:06:06 +08:00
|
|
|
{
|
|
|
|
.name = "task-clock:P,cycles",
|
|
|
|
.check = test__checkevent_precise_max_modifier,
|
|
|
|
.id = 47,
|
|
|
|
},
|
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,
|
|
|
|
.id = 48,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "r1234/name=rawpmu/",
|
|
|
|
.check = test__checkevent_config_raw,
|
|
|
|
.id = 49,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.name = "4:0x6530160/name=numpmu/",
|
|
|
|
.check = test__checkevent_config_num,
|
|
|
|
.id = 50,
|
|
|
|
},
|
2016-02-19 19:44:01 +08:00
|
|
|
{
|
|
|
|
.name = "L1-dcache-misses/name=cachepmu/",
|
|
|
|
.check = test__checkevent_config_cache,
|
|
|
|
.id = 51,
|
|
|
|
},
|
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,
|
|
|
|
.id = 52,
|
|
|
|
},
|
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,
|
|
|
|
.id = 53
|
|
|
|
}
|
2012-05-21 15:12:49 +08:00
|
|
|
};
|
|
|
|
|
2013-01-19 03:56:57 +08:00
|
|
|
static 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",
|
|
|
|
.check = test__checkevent_pmu,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 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",
|
|
|
|
.check = test__checkevent_pmu_name,
|
2014-04-25 23:34:06 +08:00
|
|
|
.id = 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/",
|
|
|
|
.check = test__checkevent_pmu_partial_time_callgraph,
|
|
|
|
.id = 2,
|
|
|
|
},
|
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",
|
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,
|
|
|
|
.id = 3,
|
|
|
|
}
|
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;
|
|
|
|
__u32 type;
|
|
|
|
int (*check)(struct list_head *terms);
|
|
|
|
};
|
|
|
|
|
2013-01-19 03:56:57 +08:00
|
|
|
static struct terms_test test__terms[] = {
|
2012-06-15 14:31:42 +08:00
|
|
|
[0] = {
|
|
|
|
.str = "config=10,config1,config2=3,umask=1",
|
|
|
|
.check = test__checkterms_simple,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2013-01-19 03:56:57 +08:00
|
|
|
static int test_event(struct evlist_test *e)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2018-06-11 17:34:21 +08:00
|
|
|
struct parse_events_error err = { .idx = 0, };
|
2012-05-21 15:12:49 +08:00
|
|
|
struct perf_evlist *evlist;
|
|
|
|
int ret;
|
|
|
|
|
2018-06-11 17:34:22 +08:00
|
|
|
if (e->valid && !e->valid()) {
|
|
|
|
pr_debug("... SKIP");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-11 15:43:12 +08:00
|
|
|
evlist = perf_evlist__new();
|
2012-05-21 15:12:49 +08:00
|
|
|
if (evlist == NULL)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
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);
|
|
|
|
parse_events_print_error(&err, e->name);
|
2014-01-04 04:30:04 +08:00
|
|
|
} else {
|
|
|
|
ret = e->check(evlist);
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|
2014-12-18 04:24:45 +08:00
|
|
|
|
2012-05-21 15:12:49 +08:00
|
|
|
perf_evlist__delete(evlist);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-01-19 03:56:57 +08:00
|
|
|
static int test_events(struct evlist_test *events, unsigned cnt)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2012-08-22 02:03:15 +08:00
|
|
|
int ret1, ret2 = 0;
|
2012-05-21 15:12:49 +08:00
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; i < cnt; i++) {
|
2013-01-19 03:56:57 +08:00
|
|
|
struct evlist_test *e = &events[i];
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2018-06-11 17:34:22 +08:00
|
|
|
pr_debug("running test %d '%s'", e->id, e->name);
|
2012-08-22 02:03:15 +08:00
|
|
|
ret1 = test_event(e);
|
|
|
|
if (ret1)
|
|
|
|
ret2 = ret1;
|
2018-06-11 17:34:22 +08:00
|
|
|
pr_debug("\n");
|
2012-06-15 14:31:42 +08:00
|
|
|
}
|
|
|
|
|
2012-08-22 02:03:15 +08:00
|
|
|
return ret2;
|
2012-06-15 14:31:42 +08:00
|
|
|
}
|
|
|
|
|
2013-01-19 03:56:57 +08:00
|
|
|
static int test_term(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;
|
|
|
|
}
|
|
|
|
|
2013-01-19 03:56:57 +08:00
|
|
|
static int test_terms(struct terms_test *terms, unsigned cnt)
|
2012-06-15 14:31:42 +08:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; i < cnt; i++) {
|
2013-01-19 03:56:57 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test_pmu(void)
|
|
|
|
{
|
|
|
|
struct stat st;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/format/",
|
2013-11-06 01:48:50 +08:00
|
|
|
sysfs__mountpoint());
|
2012-05-21 15:12:49 +08:00
|
|
|
|
|
|
|
ret = stat(path, &st);
|
|
|
|
if (ret)
|
2012-07-18 00:20:59 +08:00
|
|
|
pr_debug("omitting PMU cpu tests\n");
|
2012-05-21 15:12:49 +08:00
|
|
|
return !ret;
|
|
|
|
}
|
|
|
|
|
2012-10-10 20:53:18 +08:00
|
|
|
static int test_pmu_events(void)
|
|
|
|
{
|
|
|
|
struct stat st;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
struct dirent *ent;
|
|
|
|
DIR *dir;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
snprintf(path, PATH_MAX, "%s/bus/event_source/devices/cpu/events/",
|
2013-11-06 01:48:50 +08:00
|
|
|
sysfs__mountpoint());
|
2012-10-10 20:53:18 +08:00
|
|
|
|
|
|
|
ret = stat(path, &st);
|
|
|
|
if (ret) {
|
2013-04-09 01:06:50 +08:00
|
|
|
pr_debug("omitting PMU cpu events tests\n");
|
2012-10-10 20:53:18 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
dir = opendir(path);
|
|
|
|
if (!dir) {
|
|
|
|
pr_debug("can't open pmu event dir");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!ret && (ent = readdir(dir))) {
|
2018-06-11 17:34:22 +08:00
|
|
|
struct evlist_test e = { .id = 0, };
|
perf tests: Avoid possible truncation with dirent->d_name + snprintf
Addressing a few cases spotted by a new warning in gcc 7:
tests/parse-events.c: In function 'test_pmu_events':
tests/parse-events.c:1790:39: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 90 [-Werror=format-truncation=]
snprintf(name, MAX_NAME, "cpu/event=%s/u", ent->d_name);
^~
In file included from /usr/include/stdio.h:939:0,
from /git/linux/tools/perf/util/map.h:9,
from /git/linux/tools/perf/util/symbol.h:7,
from /git/linux/tools/perf/util/evsel.h:10,
from tests/parse-events.c:3:
/usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 13 and 268 bytes into a destination of size 100
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests/parse-events.c:1798:29: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 100 [-Werror=format-truncation=]
snprintf(name, MAX_NAME, "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: 945aea220bb8 ("perf tests: Move test objects into 'tests' directory")
Link: http://lkml.kernel.org/n/tip-ty4q2p8zp1dp3mskvubxskm5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-02-10 01:48:46 +08:00
|
|
|
char name[2 * NAME_MAX + 1 + 12 + 3];
|
2012-10-10 20:53:18 +08:00
|
|
|
|
2016-06-06 22:36:06 +08:00
|
|
|
/* Names containing . are special and cannot be used directly */
|
|
|
|
if (strchr(ent->d_name, '.'))
|
2012-10-10 20:53:18 +08:00
|
|
|
continue;
|
|
|
|
|
perf tests: Avoid possible truncation with dirent->d_name + snprintf
Addressing a few cases spotted by a new warning in gcc 7:
tests/parse-events.c: In function 'test_pmu_events':
tests/parse-events.c:1790:39: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 90 [-Werror=format-truncation=]
snprintf(name, MAX_NAME, "cpu/event=%s/u", ent->d_name);
^~
In file included from /usr/include/stdio.h:939:0,
from /git/linux/tools/perf/util/map.h:9,
from /git/linux/tools/perf/util/symbol.h:7,
from /git/linux/tools/perf/util/evsel.h:10,
from tests/parse-events.c:3:
/usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 13 and 268 bytes into a destination of size 100
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests/parse-events.c:1798:29: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 100 [-Werror=format-truncation=]
snprintf(name, MAX_NAME, "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: 945aea220bb8 ("perf tests: Move test objects into 'tests' directory")
Link: http://lkml.kernel.org/n/tip-ty4q2p8zp1dp3mskvubxskm5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-02-10 01:48:46 +08:00
|
|
|
snprintf(name, sizeof(name), "cpu/event=%s/u", ent->d_name);
|
2012-10-10 20:53:18 +08:00
|
|
|
|
|
|
|
e.name = name;
|
|
|
|
e.check = test__checkevent_pmu_events;
|
|
|
|
|
|
|
|
ret = test_event(&e);
|
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
|
|
|
if (ret)
|
|
|
|
break;
|
perf tests: Avoid possible truncation with dirent->d_name + snprintf
Addressing a few cases spotted by a new warning in gcc 7:
tests/parse-events.c: In function 'test_pmu_events':
tests/parse-events.c:1790:39: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 90 [-Werror=format-truncation=]
snprintf(name, MAX_NAME, "cpu/event=%s/u", ent->d_name);
^~
In file included from /usr/include/stdio.h:939:0,
from /git/linux/tools/perf/util/map.h:9,
from /git/linux/tools/perf/util/symbol.h:7,
from /git/linux/tools/perf/util/evsel.h:10,
from tests/parse-events.c:3:
/usr/include/bits/stdio2.h:64:10: note: '__builtin___snprintf_chk' output between 13 and 268 bytes into a destination of size 100
return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
__bos (__s), __fmt, __va_arg_pack ());
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests/parse-events.c:1798:29: error: '%s' directive output may be truncated writing up to 255 bytes into a region of size 100 [-Werror=format-truncation=]
snprintf(name, MAX_NAME, "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: 945aea220bb8 ("perf tests: Move test objects into 'tests' directory")
Link: http://lkml.kernel.org/n/tip-ty4q2p8zp1dp3mskvubxskm5@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2017-02-10 01:48:46 +08:00
|
|
|
snprintf(name, sizeof(name), "%s:u,cpu/event=%s/u", ent->d_name, ent->d_name);
|
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
|
|
|
e.name = name;
|
|
|
|
e.check = test__checkevent_pmu_events_mix;
|
|
|
|
ret = test_event(&e);
|
2012-10-10 20:53:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
closedir(dir);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-08-04 02:16:31 +08:00
|
|
|
int test__parse_events(struct test *test __maybe_unused, int subtest __maybe_unused)
|
2012-05-21 15:12:49 +08:00
|
|
|
{
|
2012-08-22 02:03:15 +08:00
|
|
|
int ret1, ret2 = 0;
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2012-07-04 06:00:47 +08:00
|
|
|
#define TEST_EVENTS(tests) \
|
|
|
|
do { \
|
2012-08-22 02:03:15 +08:00
|
|
|
ret1 = test_events(tests, ARRAY_SIZE(tests)); \
|
|
|
|
if (!ret2) \
|
|
|
|
ret2 = ret1; \
|
2012-07-04 06:00:47 +08:00
|
|
|
} while (0)
|
2012-06-15 14:31:42 +08:00
|
|
|
|
2012-07-04 06:00:47 +08:00
|
|
|
TEST_EVENTS(test__events);
|
2012-06-15 14:31:42 +08:00
|
|
|
|
2012-07-04 06:00:47 +08:00
|
|
|
if (test_pmu())
|
|
|
|
TEST_EVENTS(test__events_pmu);
|
2012-05-21 15:12:49 +08:00
|
|
|
|
2012-10-10 20:53:18 +08:00
|
|
|
if (test_pmu()) {
|
|
|
|
int ret = test_pmu_events();
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-08-22 02:03:15 +08:00
|
|
|
ret1 = test_terms(test__terms, ARRAY_SIZE(test__terms));
|
|
|
|
if (!ret2)
|
|
|
|
ret2 = ret1;
|
|
|
|
|
|
|
|
return ret2;
|
2012-05-21 15:12:49 +08:00
|
|
|
}
|