diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index 0d852d1bc90f0a514b00c6d6abcfb725f748f1c0..afbe45ef7e3ec00b164036ea15d5d1f6319cb161 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -49,6 +49,7 @@ OPTIONS These params can be used to overload default config values per event. Here is a list of the params. - 'period': Set event sampling period + - 'freq': Set event sampling frequency - 'time': Disable/enable time stamping. Acceptable values are 1 for enabling time stamping. 0 for disabling time stamping. The default is 1. diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index a59710f88d8acb91a1567c5d082f2b7d6c3c54ba..f664a22b5fea8af7dc1a5a7f00a5ec4d3f3b3431 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -600,6 +600,10 @@ static void apply_config_terms(struct perf_evsel *evsel) attr->sample_period = term->val.period; attr->freq = 0; break; + case PERF_EVSEL__CONFIG_TERM_FREQ: + attr->sample_freq = term->val.freq; + attr->freq = 1; + break; case PERF_EVSEL__CONFIG_TERM_TIME: if (term->val.time) perf_evsel__set_sample_bit(evsel, TIME); diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index b948f69d255888463abd2ed6d76c9564624355a3..fdf2674ab339785c4217df7eb68bf6632066d540 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -39,6 +39,7 @@ struct cgroup_sel; */ enum { PERF_EVSEL__CONFIG_TERM_PERIOD, + PERF_EVSEL__CONFIG_TERM_FREQ, PERF_EVSEL__CONFIG_TERM_TIME, PERF_EVSEL__CONFIG_TERM_MAX, }; @@ -48,6 +49,7 @@ struct perf_evsel_config_term { int type; union { u64 period; + u64 freq; bool time; } val; }; diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 828936dc3f1ee9bd77d9142634c7fc1676ea66b2..dbf315df422016c48952cd072eb8d2a2c1056dfb 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -597,6 +597,9 @@ do { \ case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: CHECK_TYPE_VAL(NUM); break; + case PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ: + CHECK_TYPE_VAL(NUM); + break; case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE: /* * TODO uncomment when the field is available @@ -659,6 +662,9 @@ do { \ case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: ADD_CONFIG_TERM(PERIOD, period, term->val.num); break; + case PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ: + ADD_CONFIG_TERM(FREQ, freq, term->val.num); + break; case PARSE_EVENTS__TERM_TYPE_TIME: ADD_CONFIG_TERM(TIME, time, term->val.num); break; diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h index e6f9aacc1ccecd38079634dda34c364e4206bf9b..ce2d13a16226e8fe73c02aaccb34a95c9b45cc09 100644 --- a/tools/perf/util/parse-events.h +++ b/tools/perf/util/parse-events.h @@ -62,6 +62,7 @@ enum { PARSE_EVENTS__TERM_TYPE_CONFIG2, PARSE_EVENTS__TERM_TYPE_NAME, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD, + PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE, PARSE_EVENTS__TERM_TYPE_TIME, }; diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l index f5427505ae77b319d0910f220fcdd7bfc9b13599..4306f5ad75c756b74ad7350773ec273b6043988b 100644 --- a/tools/perf/util/parse-events.l +++ b/tools/perf/util/parse-events.l @@ -182,6 +182,7 @@ config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); } config2 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); } name { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); } period { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); } +freq { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ); } branch_type { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); } time { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_TIME); } , { return ','; } diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index d4b0e6454bc627e8491d5bcf04e732c36226a3dd..d85f11b8cacf00cefeb7b97c6b3aa42da69ed4bc 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -634,7 +634,7 @@ static char *formats_error_string(struct list_head *formats) { struct perf_pmu_format *format; char *err, *str; - static const char *static_terms = "config,config1,config2,name,period,branch_type,time\n"; + static const char *static_terms = "config,config1,config2,name,period,freq,branch_type,time\n"; unsigned i = 0; if (!asprintf(&str, "valid terms:"))