[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1463126174-119290-12-git-send-email-wangnan0@huawei.com>
Date: Fri, 13 May 2016 07:56:08 +0000
From: Wang Nan <wangnan0@...wei.com>
To: <acme@...nel.org>
CC: <arnaldo.melo@...il.com>, <linux-kernel@...r.kernel.org>,
Wang Nan <wangnan0@...wei.com>, He Kuang <hekuang@...wei.com>,
"Arnaldo Carvalho de Melo" <acme@...hat.com>,
Jiri Olsa <jolsa@...nel.org>,
Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
Namhyung Kim <namhyung@...nel.org>,
"Zefan Li" <lizefan@...wei.com>, <pi3orama@....com>
Subject: [PATCH 11/17] perf tools: Set write_backward attribut bit for overwrite events
write_backward attribute makes kernel filling ring buffer from the end
of it, makes reading from overwrite ring buffer possible.
This patch selects this attribute if evsel->overwrite is selected
explicitly by user.
Overwrite and write_backward are still controled separatly for legacy
readonly mmap users (most of them are in perf/tests).
Signed-off-by: Wang Nan <wangnan0@...wei.com>
Signed-off-by: He Kuang <hekuang@...wei.com>
Cc: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Jiri Olsa <jolsa@...nel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
Cc: Namhyung Kim <namhyung@...nel.org>
Cc: Zefan Li <lizefan@...wei.com>
Cc: pi3orama@....com
---
tools/perf/builtin-record.c | 7 +++++++
tools/perf/util/evlist.c | 2 ++
tools/perf/util/evlist.h | 1 +
tools/perf/util/evsel.c | 13 +++++++++++++
4 files changed, 23 insertions(+)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 939aa68..49c41c3 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -300,6 +300,13 @@ static int record__open(struct record *rec)
perf_evlist__config(evlist, opts, &callchain_param);
evlist__for_each(evlist, pos) {
+ if (pos->overwrite) {
+ if (!pos->attr.write_backward) {
+ ui__warning("Unable to read from overwrite ring buffer\n\n");
+ rc = -ENOSYS;
+ goto out;
+ }
+ }
try_again:
if (perf_evsel__open(pos, pos->cpus, pos->threads) < 0) {
if (perf_evsel__fallback(pos, errno, msg, sizeof(msg))) {
diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index f0b0457..dc2e509 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -1043,6 +1043,8 @@ perf_evlist__channel_for_evsel(struct perf_evsel *evsel __maybe_unused)
if (evsel->overwrite)
flag |= PERF_EVLIST__CHANNEL_RDONLY;
+ if (evsel->attr.write_backward)
+ flag |= PERF_EVLIST__CHANNEL_BACKWARD;
return flag;
}
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index c53bdbd..bdd8e98 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -24,6 +24,7 @@ struct record_opts;
enum perf_evlist_mmap_flag {
PERF_EVLIST__CHANNEL_ENABLED = 1,
PERF_EVLIST__CHANNEL_RDONLY = 2,
+ PERF_EVLIST__CHANNEL_BACKWARD = 4,
};
/**
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index be4fc25..f1b060b 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -678,6 +678,19 @@ static void apply_config_terms(struct perf_evsel *evsel,
}
}
+ /*
+ * Set backward after config term processing because it is
+ * possible to set overwrite globally, without config
+ * terms.
+ */
+ if (evsel->overwrite) {
+ if (opts->has_write_backward)
+ attr->write_backward = 1;
+ else
+ pr_err("Reading from overwrite event %s is not supported\n",
+ evsel->name);
+ }
+
/* User explicitly set per-event callgraph, clear the old setting and reset. */
if ((callgraph_buf != NULL) || (dump_size > 0)) {
--
1.8.3.4
Powered by blists - more mailing lists