public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Wang Nan <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, lizefan@huawei.com, hekuang@huawei.com,
	wangnan0@huawei.com, mingo@kernel.org, namhyung@kernel.org,
	mhiramat@kernel.org, jolsa@kernel.org,
	linux-kernel@vger.kernel.org, hpa@zytor.com, acme@redhat.com
Subject: [tip:perf/urgent] perf evsel: Record fd into perf_mmap
Date: Mon, 23 May 2016 22:46:24 -0700	[thread overview]
Message-ID: <tip-d4c6fb36ac2c82f8f0c05b04cf102dcdc2d5a14d@git.kernel.org> (raw)
In-Reply-To: <1463762315-155689-3-git-send-email-wangnan0@huawei.com>

Commit-ID:  d4c6fb36ac2c82f8f0c05b04cf102dcdc2d5a14d
Gitweb:     http://git.kernel.org/tip/d4c6fb36ac2c82f8f0c05b04cf102dcdc2d5a14d
Author:     Wang Nan <wangnan0@huawei.com>
AuthorDate: Fri, 20 May 2016 16:38:24 +0000
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Fri, 20 May 2016 14:56:58 -0300

perf evsel: Record fd into perf_mmap

Add a fd field into struct perf_mmap so that perf can track the mmap fd.

This feature will be used for toggling overwrite ring buffers.

Signed-off-by: Wang 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-3-git-send-email-wangnan0@huawei.com
Signed-off-by: He Kuang <hekuang@huawei.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c | 6 ++++++
 tools/perf/util/evlist.h | 1 +
 2 files changed, 7 insertions(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index c4bfe11..1a370db 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -881,6 +881,7 @@ static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx)
 	if (evlist->mmap[idx].base != NULL) {
 		munmap(evlist->mmap[idx].base, evlist->mmap_len);
 		evlist->mmap[idx].base = NULL;
+		evlist->mmap[idx].fd = -1;
 		atomic_set(&evlist->mmap[idx].refcnt, 0);
 	}
 	auxtrace_mmap__munmap(&evlist->mmap[idx].auxtrace_mmap);
@@ -901,10 +902,14 @@ void perf_evlist__munmap(struct perf_evlist *evlist)
 
 static int perf_evlist__alloc_mmap(struct perf_evlist *evlist)
 {
+	int i;
+
 	evlist->nr_mmaps = cpu_map__nr(evlist->cpus);
 	if (cpu_map__empty(evlist->cpus))
 		evlist->nr_mmaps = thread_map__nr(evlist->threads);
 	evlist->mmap = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap));
+	for (i = 0; i < evlist->nr_mmaps; i++)
+		evlist->mmap[i].fd = -1;
 	return evlist->mmap != NULL ? 0 : -ENOMEM;
 }
 
@@ -941,6 +946,7 @@ static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx,
 		evlist->mmap[idx].base = NULL;
 		return -1;
 	}
+	evlist->mmap[idx].fd = fd;
 
 	if (auxtrace_mmap__mmap(&evlist->mmap[idx].auxtrace_mmap,
 				&mp->auxtrace_mp, evlist->mmap[idx].base, fd))
diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h
index 85d1b598..0d165b1 100644
--- a/tools/perf/util/evlist.h
+++ b/tools/perf/util/evlist.h
@@ -28,6 +28,7 @@ struct record_opts;
 struct perf_mmap {
 	void		 *base;
 	int		 mask;
+	int		 fd;
 	atomic_t	 refcnt;
 	u64		 prev;
 	struct auxtrace_mmap auxtrace_mmap;

  reply	other threads:[~2016-05-24  5:46 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 ` [PATCH v2 01/13] perf tools: Add overwrite attribute to evsel and check write_backward Wang Nan
2016-05-24  5:45   ` [tip:perf/urgent] perf evsel: Add overwrite attribute " 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-bot for Wang Nan [this message]
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=tip-d4c6fb36ac2c82f8f0c05b04cf102dcdc2d5a14d@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=acme@redhat.com \
    --cc=hekuang@huawei.com \
    --cc=hpa@zytor.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=lizefan@huawei.com \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wangnan0@huawei.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