From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752151AbcGPUsE (ORCPT ); Sat, 16 Jul 2016 16:48:04 -0400 Received: from terminus.zytor.com ([198.137.202.10]:38690 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751871AbcGPUru (ORCPT ); Sat, 16 Jul 2016 16:47:50 -0400 Date: Sat, 16 Jul 2016 13:47:40 -0700 From: tip-bot for Wang Nan Message-ID: Cc: wangnan0@huawei.com, hpa@zytor.com, mhiramat@kernel.org, mingo@kernel.org, acme@redhat.com, hekuang@huawei.com, lizefan@huawei.com, tglx@linutronix.de, jolsa@kernel.org, nilayvaish@gmail.com, namhyung@kernel.org, linux-kernel@vger.kernel.org Reply-To: acme@redhat.com, hekuang@huawei.com, mingo@kernel.org, mhiramat@kernel.org, hpa@zytor.com, wangnan0@huawei.com, linux-kernel@vger.kernel.org, nilayvaish@gmail.com, jolsa@kernel.org, namhyung@kernel.org, lizefan@huawei.com, tglx@linutronix.de In-Reply-To: <1468485287-33422-6-git-send-email-wangnan0@huawei.com> References: <1468485287-33422-6-git-send-email-wangnan0@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf evlist: Record mmap cookie into fdarray private field Git-Commit-ID: 4876075b3205af992bf1012f6d6fbc03593d55b9 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 4876075b3205af992bf1012f6d6fbc03593d55b9 Gitweb: http://git.kernel.org/tip/4876075b3205af992bf1012f6d6fbc03593d55b9 Author: Wang Nan AuthorDate: Thu, 14 Jul 2016 08:34:37 +0000 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 15 Jul 2016 17:27:47 -0300 perf evlist: Record mmap cookie into fdarray private field Insetad of saving a index into fdarray entries private field, save the corresponding 'struct perf_mmap' pointer, and release them directly using perf_mmap__put(). Following commits introduce multiple mmap arrays to evlist. Without this patch, perf_evlist__munmap_filtered() is unable to retrive correct 'struct perf_mmap' pointer. Signed-off-by: Wang Nan Acked-by: Jiri Olsa Cc: He Kuang Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Nilay Vaish Cc: Zefan Li Cc: pi3orama@163.com Link: http://lkml.kernel.org/r/1468485287-33422-6-git-send-email-wangnan0@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evlist.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index a4137e0..1462085 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -30,6 +30,7 @@ static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx); static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx); static void perf_mmap__munmap(struct perf_mmap *map); +static void perf_mmap__put(struct perf_mmap *map); #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) #define SID(e, x, y) xyarray__entry(e->sample_id, x, y) @@ -466,7 +467,8 @@ int perf_evlist__alloc_pollfd(struct perf_evlist *evlist) return 0; } -static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx, short revent) +static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, + struct perf_mmap *map, short revent) { int pos = fdarray__add(&evlist->pollfd, fd, revent | POLLERR | POLLHUP); /* @@ -474,7 +476,7 @@ static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx * close the associated evlist->mmap[] entry. */ if (pos >= 0) { - evlist->pollfd.priv[pos].idx = idx; + evlist->pollfd.priv[pos].ptr = map; fcntl(fd, F_SETFL, O_NONBLOCK); } @@ -484,15 +486,16 @@ static int __perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd, int idx int perf_evlist__add_pollfd(struct perf_evlist *evlist, int fd) { - return __perf_evlist__add_pollfd(evlist, fd, -1, POLLIN); + return __perf_evlist__add_pollfd(evlist, fd, NULL, POLLIN); } static void perf_evlist__munmap_filtered(struct fdarray *fda, int fd, void *arg __maybe_unused) { - struct perf_evlist *evlist = container_of(fda, struct perf_evlist, pollfd); + struct perf_mmap *map = fda->priv[fd].ptr; - perf_evlist__mmap_put(evlist, fda->priv[fd].idx); + if (map) + perf_mmap__put(map); } int perf_evlist__filter_pollfd(struct perf_evlist *evlist, short revents_and_mask) @@ -1098,7 +1101,7 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, * Therefore don't add it for polling. */ if (!evsel->system_wide && - __perf_evlist__add_pollfd(evlist, fd, idx, revent) < 0) { + __perf_evlist__add_pollfd(evlist, fd, &evlist->mmap[idx], revent) < 0) { perf_evlist__mmap_put(evlist, idx); return -1; }