Skip to content

Commit ee4c758

Browse files
olsajiriacmel
authored andcommitted
perf tools: Force period term to overload global settings
Currently the command line option settings beats the per event period settings: With no global settings, we get per-event configuration: $ perf record -e 'cpu/instructions,period=20000/' sleep 1 $ perf evlist -v ... { sample_period, sample_freq }: 20000 ... With 'c' option period setup, we get 'c' option value: $ perf record -e 'cpu/instructions,period=20000/' -c 1000 sleep 1 $ perf evlist -v ... { sample_period, sample_freq }: 1000 ... This patch makes the per-event settings overload the global 'c' option setup: $ perf record -e 'cpu/instructions,period=20000/' -c 1000 sleep 1 $ perf evlist -v ... { sample_period, sample_freq }: 20000 ... I think the making the per-event settings to overload any other config makes more sense than current state. However it breaks the current 'period' term handling, which might cause some noise.. so let's see ;-). Also fixing parse event tests with the new behaviour. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Kan Liang <kan.liang@intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1438162936-59698-3-git-send-email-kan.liang@intel.com Signed-off-by: Kan Liang <kan.liang@intel.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 930a2e2 commit ee4c758

5 files changed

Lines changed: 16 additions & 4 deletions

File tree

‎tools/perf/Documentation/perf-record.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ OPTIONS
4646
/sys/bus/event_sources/devices/<pmu>/format/*
4747

4848
There are also some params which are not defined in .../<pmu>/format/*.
49-
These params can be used to set event defaults.
49+
These params can be used to overload default config values per event.
5050
Here is a list of the params.
5151
- 'period': Set event sampling period
5252

‎tools/perf/tests/parse-events.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,12 @@ static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist)
8282
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
8383
TEST_ASSERT_VAL("wrong config",
8484
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
85+
/*
86+
* The period value gets configured within perf_evlist__config,
87+
* while this test executes only parse events method.
88+
*/
8589
TEST_ASSERT_VAL("wrong period",
86-
100000 == evsel->attr.sample_period);
90+
0 == evsel->attr.sample_period);
8791
TEST_ASSERT_VAL("wrong config1",
8892
0 == evsel->attr.config1);
8993
TEST_ASSERT_VAL("wrong config2",
@@ -406,7 +410,11 @@ static int test__checkevent_pmu(struct perf_evlist *evlist)
406410
TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config);
407411
TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1);
408412
TEST_ASSERT_VAL("wrong config2", 3 == evsel->attr.config2);
409-
TEST_ASSERT_VAL("wrong period", 1000 == evsel->attr.sample_period);
413+
/*
414+
* The period value gets configured within perf_evlist__config,
415+
* while this test executes only parse events method.
416+
*/
417+
TEST_ASSERT_VAL("wrong period", 0 == evsel->attr.sample_period);
410418

411419
return 0;
412420
}

‎tools/perf/util/evsel.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,8 @@ static void apply_config_terms(struct perf_event_attr *attr __maybe_unused,
594594

595595
list_for_each_entry(term, config_terms, list) {
596596
switch (term->type) {
597+
case PERF_EVSEL__CONFIG_TERM_PERIOD:
598+
attr->sample_period = term->val.period;
597599
default:
598600
break;
599601
}

‎tools/perf/util/evsel.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ struct cgroup_sel;
3838
* perf_evsel::config_terms list head.
3939
*/
4040
enum {
41+
PERF_EVSEL__CONFIG_TERM_PERIOD,
4142
PERF_EVSEL__CONFIG_TERM_MAX,
4243
};
4344

‎tools/perf/util/parse-events.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,6 @@ do { \
596596
break;
597597
case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
598598
CHECK_TYPE_VAL(NUM);
599-
attr->sample_period = term->val.num;
600599
break;
601600
case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE:
602601
/*
@@ -649,6 +648,8 @@ do { \
649648

650649
list_for_each_entry(term, head_config, list) {
651650
switch (term->type_term) {
651+
case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
652+
ADD_CONFIG_TERM(PERIOD, period, term->val.num);
652653
default:
653654
break;
654655
}

0 commit comments

Comments
 (0)