[PATCH 5/9] perf tools: Disable write_backward for leader sampling group events

From: Jiri Olsa
Date: Mon Apr 23 2018 - 05:10:00 EST


.. and other related fields that do not need to be enabled
for events that have sampling leader.

It fixes the perf top usage Ingo reported broken:

# perf top -e '{cycles,msr/aperf/}:S'

The msr/aperf/ is configured for write_back sampling, which
is not allowed by msr pmu, so it fails to create the event.

Adjusting related attr test.

Reported-by: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Kan Liang <kan.liang@xxxxxxxxx>
Link: http://lkml.kernel.org/n/tip-bh7wxrci19km6iwbv4qg555o@xxxxxxxxxxxxxx
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
tools/perf/tests/attr/test-record-group-sampling | 3 +++
tools/perf/util/evsel.c | 7 +++++--
2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/attr/test-record-group-sampling b/tools/perf/tests/attr/test-record-group-sampling
index f906b793196f..8a33ca4f9e1f 100644
--- a/tools/perf/tests/attr/test-record-group-sampling
+++ b/tools/perf/tests/attr/test-record-group-sampling
@@ -35,3 +35,6 @@ inherit=0
# sampling disabled
sample_freq=0
sample_period=0
+freq=0
+write_backward=0
+sample_id_all=0
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 7472f876cd70..81b7f1cdc956 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -930,8 +930,11 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts,
* than leader in case leader 'leads' the sampling.
*/
if ((leader != evsel) && leader->sample_read) {
- attr->sample_freq = 0;
- attr->sample_period = 0;
+ attr->freq = 0;
+ attr->sample_freq = 0;
+ attr->sample_period = 0;
+ attr->write_backward = 0;
+ attr->sample_id_all = 0;
}

if (opts->no_samples)
--
2.13.6