Skip to content

Commit 3206771

Browse files
kliang2acmel
authored andcommitted
perf tools: Per-event time support
This patchkit adds the ability to turn off time stamps per event. One usaful case for partial time is to work with per-event callgraph to enable "PEBS threshold > 1" (https://lkml.org/lkml/2015/5/10/196), which can significantly reduce the sampling overhead. The event samples with time stamps off will not be ordered. Signed-off-by: Kan Liang <kan.liang@intel.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Andi Kleen <ak@linux.intel.com> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1438677022-34296-2-git-send-email-kan.liang@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 3422111 commit 3206771

File tree

7 files changed

+31
-5
lines changed

7 files changed

+31
-5
lines changed

tools/perf/Documentation/perf-record.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ OPTIONS
4949
These params can be used to overload default config values per event.
5050
Here is a list of the params.
5151
- 'period': Set event sampling period
52-
52+
- 'time': Disable/enable time stamping. Acceptable values are 1 for
53+
enabling time stamping. 0 for disabling time stamping.
54+
The default is 1.
5355
Note: If user explicitly sets options which conflict with the params,
5456
the value set by the params will be overridden.
5557

tools/perf/util/evsel.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,15 +587,23 @@ perf_evsel__config_callgraph(struct perf_evsel *evsel,
587587
}
588588
}
589589

590-
static void apply_config_terms(struct perf_event_attr *attr __maybe_unused,
591-
struct list_head *config_terms)
590+
static void apply_config_terms(struct perf_evsel *evsel)
592591
{
593592
struct perf_evsel_config_term *term;
593+
struct list_head *config_terms = &evsel->config_terms;
594+
struct perf_event_attr *attr = &evsel->attr;
594595

595596
list_for_each_entry(term, config_terms, list) {
596597
switch (term->type) {
597598
case PERF_EVSEL__CONFIG_TERM_PERIOD:
598599
attr->sample_period = term->val.period;
600+
break;
601+
case PERF_EVSEL__CONFIG_TERM_TIME:
602+
if (term->val.time)
603+
perf_evsel__set_sample_bit(evsel, TIME);
604+
else
605+
perf_evsel__reset_sample_bit(evsel, TIME);
606+
break;
599607
default:
600608
break;
601609
}
@@ -798,7 +806,7 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts)
798806
* Apply event specific term settings,
799807
* it overloads any global configuration.
800808
*/
801-
apply_config_terms(attr, &evsel->config_terms);
809+
apply_config_terms(evsel);
802810
}
803811

804812
static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)

tools/perf/util/evsel.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct cgroup_sel;
3939
*/
4040
enum {
4141
PERF_EVSEL__CONFIG_TERM_PERIOD,
42+
PERF_EVSEL__CONFIG_TERM_TIME,
4243
PERF_EVSEL__CONFIG_TERM_MAX,
4344
};
4445

@@ -47,6 +48,7 @@ struct perf_evsel_config_term {
4748
int type;
4849
union {
4950
u64 period;
51+
bool time;
5052
} val;
5153
};
5254

tools/perf/util/parse-events.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,14 @@ do { \
603603
* attr->branch_sample_type = term->val.num;
604604
*/
605605
break;
606+
case PARSE_EVENTS__TERM_TYPE_TIME:
607+
CHECK_TYPE_VAL(NUM);
608+
if (term->val.num > 1) {
609+
err->str = strdup("expected 0 or 1");
610+
err->idx = term->err_val;
611+
return -EINVAL;
612+
}
613+
break;
606614
case PARSE_EVENTS__TERM_TYPE_NAME:
607615
CHECK_TYPE_VAL(STR);
608616
break;
@@ -650,6 +658,10 @@ do { \
650658
switch (term->type_term) {
651659
case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
652660
ADD_CONFIG_TERM(PERIOD, period, term->val.num);
661+
break;
662+
case PARSE_EVENTS__TERM_TYPE_TIME:
663+
ADD_CONFIG_TERM(TIME, time, term->val.num);
664+
break;
653665
default:
654666
break;
655667
}

tools/perf/util/parse-events.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ enum {
6363
PARSE_EVENTS__TERM_TYPE_NAME,
6464
PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD,
6565
PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE,
66+
PARSE_EVENTS__TERM_TYPE_TIME,
6667
};
6768

6869
struct parse_events_term {

tools/perf/util/parse-events.l

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ config2 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); }
183183
name { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); }
184184
period { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); }
185185
branch_type { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_BRANCH_SAMPLE_TYPE); }
186+
time { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_TIME); }
186187
, { return ','; }
187188
"/" { BEGIN(INITIAL); return '/'; }
188189
{name_minus} { return str(yyscanner, PE_NAME); }

tools/perf/util/pmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ static char *formats_error_string(struct list_head *formats)
607607
{
608608
struct perf_pmu_format *format;
609609
char *err, *str;
610-
static const char *static_terms = "config,config1,config2,name,period,branch_type\n";
610+
static const char *static_terms = "config,config1,config2,name,period,branch_type,time\n";
611611
unsigned i = 0;
612612

613613
if (!asprintf(&str, "valid terms:"))

0 commit comments

Comments
 (0)