Commit 09af2a55 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf record: Support per-event freq term

Now perf can set per-event value of time and (sampling) period.  But I
guess most users like me just want to set frequency rather than period.
So add the 'freq' term in the event parser.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Kan Liang <kan.liang@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1439102724-14079-1-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 31191a85
...@@ -49,6 +49,7 @@ OPTIONS ...@@ -49,6 +49,7 @@ OPTIONS
These params can be used to overload default config values per event. 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
- 'freq': Set event sampling frequency
- 'time': Disable/enable time stamping. Acceptable values are 1 for - 'time': Disable/enable time stamping. Acceptable values are 1 for
enabling time stamping. 0 for disabling time stamping. enabling time stamping. 0 for disabling time stamping.
The default is 1. The default is 1.
......
...@@ -600,6 +600,10 @@ static void apply_config_terms(struct perf_evsel *evsel) ...@@ -600,6 +600,10 @@ static void apply_config_terms(struct perf_evsel *evsel)
attr->sample_period = term->val.period; attr->sample_period = term->val.period;
attr->freq = 0; attr->freq = 0;
break; break;
case PERF_EVSEL__CONFIG_TERM_FREQ:
attr->sample_freq = term->val.freq;
attr->freq = 1;
break;
case PERF_EVSEL__CONFIG_TERM_TIME: case PERF_EVSEL__CONFIG_TERM_TIME:
if (term->val.time) if (term->val.time)
perf_evsel__set_sample_bit(evsel, TIME); perf_evsel__set_sample_bit(evsel, TIME);
......
...@@ -39,6 +39,7 @@ struct cgroup_sel; ...@@ -39,6 +39,7 @@ struct cgroup_sel;
*/ */
enum { enum {
PERF_EVSEL__CONFIG_TERM_PERIOD, PERF_EVSEL__CONFIG_TERM_PERIOD,
PERF_EVSEL__CONFIG_TERM_FREQ,
PERF_EVSEL__CONFIG_TERM_TIME, PERF_EVSEL__CONFIG_TERM_TIME,
PERF_EVSEL__CONFIG_TERM_MAX, PERF_EVSEL__CONFIG_TERM_MAX,
}; };
...@@ -48,6 +49,7 @@ struct perf_evsel_config_term { ...@@ -48,6 +49,7 @@ struct perf_evsel_config_term {
int type; int type;
union { union {
u64 period; u64 period;
u64 freq;
bool time; bool time;
} val; } val;
}; };
......
...@@ -597,6 +597,9 @@ do { \ ...@@ -597,6 +597,9 @@ do { \
case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
CHECK_TYPE_VAL(NUM); CHECK_TYPE_VAL(NUM);
break; break;
case PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ:
CHECK_TYPE_VAL(NUM);
break;
case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE: case PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE:
/* /*
* TODO uncomment when the field is available * TODO uncomment when the field is available
...@@ -659,6 +662,9 @@ do { \ ...@@ -659,6 +662,9 @@ do { \
case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD: case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
ADD_CONFIG_TERM(PERIOD, period, term->val.num); ADD_CONFIG_TERM(PERIOD, period, term->val.num);
break; break;
case PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ:
ADD_CONFIG_TERM(FREQ, freq, term->val.num);
break;
case PARSE_EVENTS__TERM_TYPE_TIME: case PARSE_EVENTS__TERM_TYPE_TIME:
ADD_CONFIG_TERM(TIME, time, term->val.num); ADD_CONFIG_TERM(TIME, time, term->val.num);
break; break;
......
...@@ -62,6 +62,7 @@ enum { ...@@ -62,6 +62,7 @@ enum {
PARSE_EVENTS__TERM_TYPE_CONFIG2, PARSE_EVENTS__TERM_TYPE_CONFIG2,
PARSE_EVENTS__TERM_TYPE_NAME, PARSE_EVENTS__TERM_TYPE_NAME,
PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD,
PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ,
PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE,
PARSE_EVENTS__TERM_TYPE_TIME, PARSE_EVENTS__TERM_TYPE_TIME,
}; };
......
...@@ -182,6 +182,7 @@ config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); } ...@@ -182,6 +182,7 @@ config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); }
config2 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); } config2 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); }
name { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); } name { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); }
period { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); } 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); } branch_type { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); }
time { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_TIME); } time { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_TIME); }
, { return ','; } , { return ','; }
......
...@@ -634,7 +634,7 @@ static char *formats_error_string(struct list_head *formats) ...@@ -634,7 +634,7 @@ static char *formats_error_string(struct list_head *formats)
{ {
struct perf_pmu_format *format; struct perf_pmu_format *format;
char *err, *str; 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; unsigned i = 0;
if (!asprintf(&str, "valid terms:")) if (!asprintf(&str, "valid terms:"))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment