perf record: Support per-event freq term
Namhyung Kim
maintainerPATCH 1/2 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.
--- tools/perf/Documentation/perf-record.txt | 1 + tools/perf/util/evsel.c | 4 ++++ tools/perf/util/evsel.h | 2 ++ tools/perf/util/parse-events.c | 6 ++++++ tools/perf/util/parse-events.h | 1 + tools/perf/util/parse-events.l | 1 + tools/perf/util/pmu.c | 2 +- 7 files changed, 16 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-record.txt +1 -0
@@ -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.
tools/perf/util/evsel.c +4 -0
@@ -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 );
tools/perf/util/evsel.h +2 -0
@@ -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; };
tools/perf/util/parse-events.c +6 -0
@@ -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 ;
tools/perf/util/parse-events.h +1 -0
@@ -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, };
tools/perf/util/parse-events.l +1 -0
@@ -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 ','; }
tools/perf/util/pmu.c +1 -1
@@ -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:" ))
Signature · 1 line
2.5.0
Namhyung Kim
maintainerPATCH 2/2 perf evlist: Be more specific on -F/--freq
Currently perf evlist -F shows the number as if it's always sampling frequency. But we now support per-event freq/period settings. So it'd better to show more detailed info whether it's freq or period.
$ perf record -e 'cpu/config=1/,cpu/config=2,period=300000/' sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.017 MB perf.data ]
$ perf evlist -F cpu/config=1/: sample_freq=4000 cpu/config=2,period=300000/: sample_period=300000
--- tools/perf/util/evsel.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/perf/util/evsel.c +7 -2
@@ -2158,8 +2158,13 @@ int perf_evsel__fprintf(struct perf_evsel *evsel, printed +=perf_event_attr__fprintf (fp, &evsel->attr, __print_attr__fprintf, &first); }else if (details->freq) { - printed +=comma_fprintf (fp, &first," sample_freq=%" PRIu64, - (u64 )evsel->attr.sample_freq); +const char *term ="sample_freq" ; + +if (!evsel->attr.freq) + term ="sample_period" ; + + printed +=comma_fprintf (fp, &first," %s=%" PRIu64, + term, (u64 )evsel->attr.sample_freq); } out:fputc ('\n' , fp);
Signature · 1 line
2.5.0
Re: [PATCH 2/2] perf evlist: Be more specific on -F/--freq
Quoted 8 lines · Namhyung Kim
Currently perf evlist -F shows the number as if it's always sampling frequency. But we now support per-event freq/period settings. So it'd better to show more detailed info whether it's freq or period.
$ perf record -e 'cpu/config=1/,cpu/config=2,period=300000/' sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.017 MB perf.data ]
Quoted 5 lines
$ perf evlist -F cpu/config=1/: sample_freq=4000 cpu/config=2,period=300000/: sample_period=300000Signed-off-by Namhyung Kim <[email protected]>
thanks,
jirka
Quoted 27 lines
--- tools/perf/util/evsel.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)tools/perf/util/evsel.c +7
-2@@ -2158,8 +2158,13 @@ int perf_evsel__fprintf(struct perf_evsel *evsel, printed +=perf_event_attr__fprintf (fp, &evsel->attr, __print_attr__fprintf, &first); }else if (details->freq) { - printed +=comma_fprintf (fp, &first," sample_freq=%" PRIu64, - (u64 )evsel->attr.sample_freq); +const char *term ="sample_freq" ; + +if (!evsel->attr.freq) + term ="sample_period" ; + + printed +=comma_fprintf (fp, &first," %s=%" PRIu64, + term, (u64 )evsel->attr.sample_freq); } out:fputc ('\n' , fp);Signature · 1 line
2.5.0
tip-bot for Namhyung Kim
merge bot[tip:perf/core] perf evlist: Be more specific on -F/--freq
In reply to Namhyung Kimperf evlist: Be more specific on -F/--freq
Commit-ID: 4605bb55b91449a1a953a51f0334d3bc02351adb Gitweb: http://git.kernel.org/tip/4605bb55b91449a1a953a51f0334d3bc02351adb Author: Namhyung Kim <[email protected]> AuthorDate: Sun, 9 Aug 2015 15:45:24 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 10 Aug 2015 17:20:26 -0300
perf evlist: Be more specific on -F/--freq
Currently perf evlist -F shows the number as if it's always sampling frequency. But we now support per-event freq/period settings. So it'd better to show more detailed info whether it's freq or period.
$ perf record -e 'cpu/config=1/,cpu/config=2,period=300000/' sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.017 MB perf.data ]
$ perf evlist -F cpu/config=1/: sample_freq=4000 cpu/config=2,period=300000/: sample_period=300000
--- tools/perf/util/evsel.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/perf/util/evsel.c +7 -2
@@ -2158,8 +2158,13 @@ int perf_evsel__fprintf(struct perf_evsel *evsel, printed +=perf_event_attr__fprintf (fp, &evsel->attr, __print_attr__fprintf, &first); }else if (details->freq) { - printed +=comma_fprintf (fp, &first," sample_freq=%" PRIu64, - (u64 )evsel->attr.sample_freq); +const char *term ="sample_freq" ; + +if (!evsel->attr.freq) + term ="sample_period" ; + + printed +=comma_fprintf (fp, &first," %s=%" PRIu64, + term, (u64 )evsel->attr.sample_freq); } out:fputc ('\n' , fp);
Quoted 6 lines · Namhyung Kim
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.
Cc Kan Liang <[email protected]>Signed-off-by Namhyung Kim <[email protected]>
thanks,
jirka
Quoted 121 lines
--- tools/perf/Documentation/perf-record.txt | 1 + tools/perf/util/evsel.c | 4 ++++ tools/perf/util/evsel.h | 2 ++ tools/perf/util/parse-events.c | 6 ++++++ tools/perf/util/parse-events.h | 1 + tools/perf/util/parse-events.l | 1 + tools/perf/util/pmu.c | 2 +- 7 files changed, 16 insertions(+), 1 deletion(-)tools/perf/Documentation/perf-record.txt +1
-0@@ -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.tools/perf/util/evsel.c +4
-0@@ -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 );tools/perf/util/evsel.h +2
-0@@ -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; };tools/perf/util/parse-events.c +6
-0@@ -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 ;tools/perf/util/parse-events.h +1
-0@@ -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, };tools/perf/util/parse-events.l +1
-0@@ -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 ','; }tools/perf/util/pmu.c +1
-1@@ -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:" ))Signature · 1 line
2.5.0
Em Sun, Aug 09, 2015 at 11:34:11AM +0200, Jiri Olsa escreveu:
Quoted 9 lines · Namhyung Kim
Quoted 6 lines
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.
Cc Kan Liang <[email protected]>Signed-off-by Namhyung Kim <[email protected]>Acked-by Jiri Olsa <[email protected]>
Thanks, applied both patches.
- Arnaldo
tip-bot for Namhyung Kim
merge botperf record: Support per-event freq term
Commit-ID: 09af2a553577a6e53e40011a910be0f27ce56f3e Gitweb: http://git.kernel.org/tip/09af2a553577a6e53e40011a910be0f27ce56f3e Author: Namhyung Kim <[email protected]> AuthorDate: Sun, 9 Aug 2015 15:45:23 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 10 Aug 2015 17:20:26 -0300
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.
--- tools/perf/Documentation/perf-record.txt | 1 + tools/perf/util/evsel.c | 4 ++++ tools/perf/util/evsel.h | 2 ++ tools/perf/util/parse-events.c | 6 ++++++ tools/perf/util/parse-events.h | 1 + tools/perf/util/parse-events.l | 1 + tools/perf/util/pmu.c | 2 +- 7 files changed, 16 insertions(+), 1 deletion(-)
tools/perf/Documentation/perf-record.txt +1 -0
@@ -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.
tools/perf/util/evsel.c +4 -0
@@ -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 );
tools/perf/util/evsel.h +2 -0
@@ -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; };
tools/perf/util/parse-events.c +6 -0
@@ -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 ;
tools/perf/util/parse-events.h +1 -0
@@ -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, };
tools/perf/util/parse-events.l +1 -0
@@ -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 ','; }
tools/perf/util/pmu.c +1 -1
@@ -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:" ))