perf record: Support per-event freq term
authorNamhyung Kim <namhyung@kernel.org>
Sun, 9 Aug 2015 06:45:23 +0000 (15:45 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 10 Aug 2015 20:20:26 +0000 (17:20 -0300)
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: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri 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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/Documentation/perf-record.txt
tools/perf/util/evsel.c
tools/perf/util/evsel.h
tools/perf/util/parse-events.c
tools/perf/util/parse-events.h
tools/perf/util/parse-events.l
tools/perf/util/pmu.c

index 0d852d1bc90f0a514b00c6d6abcfb725f748f1c0..afbe45ef7e3ec00b164036ea15d5d1f6319cb161 100644 (file)
@@ -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.
index a59710f88d8acb91a1567c5d082f2b7d6c3c54ba..f664a22b5fea8af7dc1a5a7f00a5ec4d3f3b3431 100644 (file)
@@ -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);
index b948f69d255888463abd2ed6d76c9564624355a3..fdf2674ab339785c4217df7eb68bf6632066d540 100644 (file)
@@ -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;
 };
index 828936dc3f1ee9bd77d9142634c7fc1676ea66b2..dbf315df422016c48952cd072eb8d2a2c1056dfb 100644 (file)
@@ -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;
index e6f9aacc1ccecd38079634dda34c364e4206bf9b..ce2d13a16226e8fe73c02aaccb34a95c9b45cc09 100644 (file)
@@ -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,
 };
index f5427505ae77b319d0910f220fcdd7bfc9b13599..4306f5ad75c756b74ad7350773ec273b6043988b 100644 (file)
@@ -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 ','; }
index d4b0e6454bc627e8491d5bcf04e732c36226a3dd..d85f11b8cacf00cefeb7b97c6b3aa42da69ed4bc 100644 (file)
@@ -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:"))