mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wang Nan <wangnan0@huawei.com>
To: <acme@kernel.org>
Cc: <pi3orama@163.com>, <linux-kernel@vger.kernel.org>,
	Wang Nan <wangnan0@huawei.com>, He Kuang <hekuang@huawei.com>,
	"Arnaldo Carvalho de Melo" <acme@redhat.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>,
	Namhyung Kim <namhyung@kernel.org>,
	"Zefan Li" <lizefan@huawei.com>
Subject: [PATCH v2 01/13] perf tools: Add overwrite attribute to evsel and check write_backward
Date: Fri, 20 May 2016 16:38:23 +0000	[thread overview]
Message-ID: <1463762315-155689-2-git-send-email-wangnan0@huawei.com> (raw)
In-Reply-To: <1463762315-155689-1-git-send-email-wangnan0@huawei.com>

Add 'overwrite' attribute to evsel to mark whether this event is set
overwritable. Following commits will support syntax like
 # perf record -e cycles/overwrite/ ...

Overwritable evsel require kernel support write_backward. Add it to
perf_missing_feature.

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: He Kuang <hekuang@huawei.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
---
 tools/perf/util/evsel.c | 13 +++++++++++++
 tools/perf/util/evsel.h |  1 +
 2 files changed, 14 insertions(+)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index a23f547..ed74ae4 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -37,6 +37,7 @@ static struct {
 	bool clockid;
 	bool clockid_wrong;
 	bool lbr_flags;
+	bool write_backward;
 } perf_missing_features;
 
 static clockid_t clockid;
@@ -1376,6 +1377,8 @@ fallback_missing_features:
 	if (perf_missing_features.lbr_flags)
 		evsel->attr.branch_sample_type &= ~(PERF_SAMPLE_BRANCH_NO_FLAGS |
 				     PERF_SAMPLE_BRANCH_NO_CYCLES);
+	if (perf_missing_features.write_backward)
+		evsel->attr.write_backward = false;
 retry_sample_id:
 	if (perf_missing_features.sample_id_all)
 		evsel->attr.sample_id_all = 0;
@@ -1438,6 +1441,12 @@ retry_open:
 				err = -EINVAL;
 				goto out_close;
 			}
+
+			if (evsel->overwrite &&
+			    perf_missing_features.write_backward) {
+				err = -EINVAL;
+				goto out_close;
+			}
 		}
 	}
 
@@ -1500,6 +1509,10 @@ try_fallback:
 			  PERF_SAMPLE_BRANCH_NO_FLAGS))) {
 		perf_missing_features.lbr_flags = true;
 		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:
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 8a644fe..c1f1015 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -112,6 +112,7 @@ struct perf_evsel {
 	bool			tracking;
 	bool			per_pkg;
 	bool			precise_max;
+	bool			overwrite;
 	/* parse modifier helper */
 	int			exclude_GH;
 	int			nr_members;
-- 
1.8.3.4

  reply	other threads:[~2016-05-20 16:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-20 16:38 [PATCH v2 00/13] perf tools: Support overwritable ring buffer Wang Nan
2016-05-20 16:38 ` Wang Nan [this message]
2016-05-24  5:45   ` [tip:perf/urgent] perf evsel: Add overwrite attribute and check write_backward tip-bot for Wang Nan
2016-05-20 16:38 ` [PATCH v2 02/13] perf tools: Record fd into perf_mmap Wang Nan
2016-05-24  5:46   ` [tip:perf/urgent] perf evsel: " tip-bot for Wang Nan
2016-05-20 16:38 ` [PATCH v2 03/13] perf tools: Add API to pause a evlist Wang Nan
2016-05-20 18:05   ` Arnaldo Carvalho de Melo
2016-05-20 16:38 ` [PATCH v2 04/13] perf record: Prevent reading invalid data in record__mmap_read Wang Nan
2016-05-20 16:38 ` [PATCH v2 05/13] perf record: Rename variable to make code clear Wang Nan
2016-05-20 16:38 ` [PATCH v2 06/13] perf record: Read from backward ring buffer Wang Nan
2016-05-20 16:38 ` [PATCH v2 07/13] perf evlist: Introduce aux perf evlist Wang Nan
2016-05-20 16:38 ` [PATCH v2 08/13] perf tools: Don't poll and mmap overwritable events Wang Nan
2016-05-20 16:38 ` [PATCH v2 09/13] perf tools: Enable overwrite settings Wang Nan
2016-05-20 16:38 ` [PATCH v2 10/13] perf record: Introduce rec->overwrite_evlist for overwritable events Wang Nan
2016-05-20 16:38 ` [PATCH v2 11/13] perf record: Toggle overwrite ring buffer for reading Wang Nan
2016-05-20 16:38 ` [PATCH v2 12/13] perf tools: Don't warn about out of order event if write_backward is used Wang Nan
2016-05-20 16:38 ` [PATCH v2 13/13] perf tools: Check write_backward during evlist config Wang Nan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1463762315-155689-2-git-send-email-wangnan0@huawei.com \
    --to=wangnan0@huawei.com \
    --cc=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=hekuang@huawei.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=masami.hiramatsu.pt@hitachi.com \
    --cc=namhyung@kernel.org \
    --cc=pi3orama@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®