perf evsel: Improve tracepoint constructor setup

It needs to properly set the sample_type, sample_period and the KVM
related perf_event_attr fields.

Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-v9x3q9rv4caxtox7wtjpchq5@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 a91f408e
...@@ -117,14 +117,18 @@ struct perf_evsel *perf_evsel__newtp(const char *sys, const char *name, int idx) ...@@ -117,14 +117,18 @@ struct perf_evsel *perf_evsel__newtp(const char *sys, const char *name, int idx)
if (evsel != NULL) { if (evsel != NULL) {
struct perf_event_attr attr = { struct perf_event_attr attr = {
.type = PERF_TYPE_TRACEPOINT, .type = PERF_TYPE_TRACEPOINT,
.sample_type = (PERF_SAMPLE_RAW | PERF_SAMPLE_TIME |
PERF_SAMPLE_CPU | PERF_SAMPLE_PERIOD),
}; };
evsel->tp_format = event_format__new(sys, name); evsel->tp_format = event_format__new(sys, name);
if (evsel->tp_format == NULL) if (evsel->tp_format == NULL)
goto out_free; goto out_free;
event_attr_init(&attr);
attr.config = evsel->tp_format->id; attr.config = evsel->tp_format->id;
attr.sample_period = 1;
perf_evsel__init(evsel, &attr, idx); perf_evsel__init(evsel, &attr, idx);
evsel->name = evsel->tp_format->name; evsel->name = evsel->tp_format->name;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册