Commit b90dc17a authored by Wang Nan's avatar Wang Nan Committed by Arnaldo Carvalho de Melo

perf evsel: Add overwrite attribute and check write_backward

Add 'overwrite' attribute to evsel to mark whether this event is
overwritable. The following commits will support syntax like:

  # perf record -e cycles/overwrite/ ...

An overwritable evsel requires kernel support for the
perf_event_attr.write_backward ring buffer feature.

Add it to perf_missing_feature.
Signed-off-by: default avatarWang Nan <wangnan0@huawei.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1463762315-155689-2-git-send-email-wangnan0@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 408cf677
...@@ -37,6 +37,7 @@ static struct { ...@@ -37,6 +37,7 @@ static struct {
bool clockid; bool clockid;
bool clockid_wrong; bool clockid_wrong;
bool lbr_flags; bool lbr_flags;
bool write_backward;
} perf_missing_features; } perf_missing_features;
static clockid_t clockid; static clockid_t clockid;
...@@ -1376,6 +1377,8 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, ...@@ -1376,6 +1377,8 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
if (perf_missing_features.lbr_flags) if (perf_missing_features.lbr_flags)
evsel->attr.branch_sample_type &= ~(PERF_SAMPLE_BRANCH_NO_FLAGS | evsel->attr.branch_sample_type &= ~(PERF_SAMPLE_BRANCH_NO_FLAGS |
PERF_SAMPLE_BRANCH_NO_CYCLES); PERF_SAMPLE_BRANCH_NO_CYCLES);
if (perf_missing_features.write_backward)
evsel->attr.write_backward = false;
retry_sample_id: retry_sample_id:
if (perf_missing_features.sample_id_all) if (perf_missing_features.sample_id_all)
evsel->attr.sample_id_all = 0; evsel->attr.sample_id_all = 0;
...@@ -1438,6 +1441,12 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, ...@@ -1438,6 +1441,12 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
err = -EINVAL; err = -EINVAL;
goto out_close; goto out_close;
} }
if (evsel->overwrite &&
perf_missing_features.write_backward) {
err = -EINVAL;
goto out_close;
}
} }
} }
...@@ -1500,6 +1509,10 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, ...@@ -1500,6 +1509,10 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus,
PERF_SAMPLE_BRANCH_NO_FLAGS))) { PERF_SAMPLE_BRANCH_NO_FLAGS))) {
perf_missing_features.lbr_flags = true; perf_missing_features.lbr_flags = true;
goto fallback_missing_features; goto fallback_missing_features;
} else if (!perf_missing_features.write_backward &&
evsel->attr.write_backward) {
perf_missing_features.write_backward = true;
goto fallback_missing_features;
} }
out_close: out_close:
......
...@@ -112,6 +112,7 @@ struct perf_evsel { ...@@ -112,6 +112,7 @@ struct perf_evsel {
bool tracking; bool tracking;
bool per_pkg; bool per_pkg;
bool precise_max; bool precise_max;
bool overwrite;
/* parse modifier helper */ /* parse modifier helper */
int exclude_GH; int exclude_GH;
int nr_members; int nr_members;
......
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