提交 ee4c7588 编写于 作者: J Jiri Olsa 提交者: Arnaldo Carvalho de Melo

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: NJiri Olsa <jolsa@kernel.org>
Tested-by: NArnaldo 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.comSigned-off-by: NKan Liang <kan.liang@intel.com>
Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 930a2e29
...@@ -46,7 +46,7 @@ OPTIONS ...@@ -46,7 +46,7 @@ OPTIONS
/sys/bus/event_sources/devices/<pmu>/format/* /sys/bus/event_sources/devices/<pmu>/format/*
There are also some params which are not defined in .../<pmu>/format/*. There are also some params which are not defined in .../<pmu>/format/*.
These params can be used to set event defaults. These params can be used to overload default config values per event.
Here is a list of the params. Here is a list of the params.
- 'period': Set event sampling period - 'period': Set event sampling period
......
...@@ -82,8 +82,12 @@ static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist) ...@@ -82,8 +82,12 @@ static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist)
TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
TEST_ASSERT_VAL("wrong config", TEST_ASSERT_VAL("wrong config",
PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config);
/*
* The period value gets configured within perf_evlist__config,
* while this test executes only parse events method.
*/
TEST_ASSERT_VAL("wrong period", TEST_ASSERT_VAL("wrong period",
100000 == evsel->attr.sample_period); 0 == evsel->attr.sample_period);
TEST_ASSERT_VAL("wrong config1", TEST_ASSERT_VAL("wrong config1",
0 == evsel->attr.config1); 0 == evsel->attr.config1);
TEST_ASSERT_VAL("wrong config2", TEST_ASSERT_VAL("wrong config2",
...@@ -406,7 +410,11 @@ static int test__checkevent_pmu(struct perf_evlist *evlist) ...@@ -406,7 +410,11 @@ static int test__checkevent_pmu(struct perf_evlist *evlist)
TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config); TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config);
TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1); TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1);
TEST_ASSERT_VAL("wrong config2", 3 == evsel->attr.config2); TEST_ASSERT_VAL("wrong config2", 3 == evsel->attr.config2);
TEST_ASSERT_VAL("wrong period", 1000 == evsel->attr.sample_period); /*
* 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);
return 0; return 0;
} }
......
...@@ -594,6 +594,8 @@ static void apply_config_terms(struct perf_event_attr *attr __maybe_unused, ...@@ -594,6 +594,8 @@ static void apply_config_terms(struct perf_event_attr *attr __maybe_unused,
list_for_each_entry(term, config_terms, list) { list_for_each_entry(term, config_terms, list) {
switch (term->type) { switch (term->type) {
case PERF_EVSEL__CONFIG_TERM_PERIOD:
attr->sample_period = term->val.period;
default: default:
break; break;
} }
......
...@@ -38,6 +38,7 @@ struct cgroup_sel; ...@@ -38,6 +38,7 @@ struct cgroup_sel;
* perf_evsel::config_terms list head. * perf_evsel::config_terms list head.
*/ */
enum { enum {
PERF_EVSEL__CONFIG_TERM_PERIOD,
PERF_EVSEL__CONFIG_TERM_MAX, PERF_EVSEL__CONFIG_TERM_MAX,
}; };
......
...@@ -596,7 +596,6 @@ do { \ ...@@ -596,7 +596,6 @@ do { \
break; break;
case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
CHECK_TYPE_VAL(NUM); CHECK_TYPE_VAL(NUM);
attr->sample_period = term->val.num;
break; break;
case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE: case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE:
/* /*
...@@ -649,6 +648,8 @@ do { \ ...@@ -649,6 +648,8 @@ do { \
list_for_each_entry(term, head_config, list) { list_for_each_entry(term, head_config, list) {
switch (term->type_term) { switch (term->type_term) {
case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
ADD_CONFIG_TERM(PERIOD, period, term->val.num);
default: default:
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册