aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-07-29 05:42:11 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-07-29 15:18:21 -0400
commitee4c75887d12bcd6ecd897291797d969256f39ca (patch)
tree9615b63684b35e15608bc2f4d0515a6b28203d8f
parent930a2e29758f865e3a7b34b8b3b37c08d40f0254 (diff)
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>
-rw-r--r--tools/perf/Documentation/perf-record.txt2
-rw-r--r--tools/perf/tests/parse-events.c12
-rw-r--r--tools/perf/util/evsel.c2
-rw-r--r--tools/perf/util/evsel.h1
-rw-r--r--tools/perf/util/parse-events.c3
5 files changed, 16 insertions, 4 deletions
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 63ee0408761d..ac41350ca485 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -46,7 +46,7 @@ OPTIONS
46 /sys/bus/event_sources/devices/<pmu>/format/* 46 /sys/bus/event_sources/devices/<pmu>/format/*
47 47
48 There are also some params which are not defined in .../<pmu>/format/*. 48 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.
50 Here is a list of the params. 50 Here is a list of the params.
51 - 'period': Set event sampling period 51 - 'period': Set event sampling period
52 52
diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index d76963f7ad3d..f65bb89e109e 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -82,8 +82,12 @@ static int test__checkevent_symbolic_name_config(struct perf_evlist *evlist)
82 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type); 82 TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
83 TEST_ASSERT_VAL("wrong config", 83 TEST_ASSERT_VAL("wrong config",
84 PERF_COUNT_HW_CPU_CYCLES == evsel->attr.config); 84 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 */
85 TEST_ASSERT_VAL("wrong period", 89 TEST_ASSERT_VAL("wrong period",
86 100000 == evsel->attr.sample_period); 90 0 == evsel->attr.sample_period);
87 TEST_ASSERT_VAL("wrong config1", 91 TEST_ASSERT_VAL("wrong config1",
88 0 == evsel->attr.config1); 92 0 == evsel->attr.config1);
89 TEST_ASSERT_VAL("wrong config2", 93 TEST_ASSERT_VAL("wrong config2",
@@ -406,7 +410,11 @@ static int test__checkevent_pmu(struct perf_evlist *evlist)
406 TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config); 410 TEST_ASSERT_VAL("wrong config", 10 == evsel->attr.config);
407 TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1); 411 TEST_ASSERT_VAL("wrong config1", 1 == evsel->attr.config1);
408 TEST_ASSERT_VAL("wrong config2", 3 == evsel->attr.config2); 412 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);
410 418
411 return 0; 419 return 0;
412} 420}
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 048d61dde3f6..7d3acba5a512 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -594,6 +594,8 @@ static void apply_config_terms(struct perf_event_attr *attr __maybe_unused,
594 594
595 list_for_each_entry(term, config_terms, list) { 595 list_for_each_entry(term, config_terms, list) {
596 switch (term->type) { 596 switch (term->type) {
597 case PERF_EVSEL__CONFIG_TERM_PERIOD:
598 attr->sample_period = term->val.period;
597 default: 599 default:
598 break; 600 break;
599 } 601 }
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 033981974fd2..a7d2175358b8 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -38,6 +38,7 @@ struct cgroup_sel;
38 * perf_evsel::config_terms list head. 38 * perf_evsel::config_terms list head.
39*/ 39*/
40enum { 40enum {
41 PERF_EVSEL__CONFIG_TERM_PERIOD,
41 PERF_EVSEL__CONFIG_TERM_MAX, 42 PERF_EVSEL__CONFIG_TERM_MAX,
42}; 43};
43 44
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 3271d134e8c1..09bee93fd0ec 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -596,7 +596,6 @@ do { \
596 break; 596 break;
597 case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: 597 case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
598 CHECK_TYPE_VAL(NUM); 598 CHECK_TYPE_VAL(NUM);
599 attr->sample_period = term->val.num;
600 break; 599 break;
601 case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE: 600 case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE:
602 /* 601 /*
@@ -649,6 +648,8 @@ do { \
649 648
650 list_for_each_entry(term, head_config, list) { 649 list_for_each_entry(term, head_config, list) {
651 switch (term->type_term) { 650 switch (term->type_term) {
651 case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
652 ADD_CONFIG_TERM(PERIOD, period, term->val.num);
652 default: 653 default:
653 break; 654 break;
654 } 655 }