From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932715AbcFOCYv (ORCPT ); Tue, 14 Jun 2016 22:24:51 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:60642 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932663AbcFOCYI (ORCPT ); Tue, 14 Jun 2016 22:24:08 -0400 From: Wang Nan To: CC: , , Wang Nan , He Kuang , "Arnaldo Carvalho de Melo" , Jiri Olsa , Masami Hiramatsu , Namhyung Kim , Zefan Li Subject: [PATCH v7 8/8] perf record: Unmap overwrite evlist when event terminate Date: Wed, 15 Jun 2016 02:23:35 +0000 Message-ID: <1465957415-83376-9-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1465957415-83376-1-git-send-email-wangnan0@huawei.com> References: <1465957415-83376-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.193.250] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090203.5760BC3C.007A,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: de6f5f2245716e4d67c8eb270760e394 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When see POLLERR or POLLHUP, unmap ring buffer from both the main evlist and overwrite evlist. Signed-off-by: Wang Nan Cc: He Kuang Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Zefan Li Cc: pi3orama@163.com --- tools/perf/builtin-record.c | 30 +++++++++++++++++++++--------- tools/perf/util/evlist.c | 3 +-- tools/perf/util/evlist.h | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index b9094f0..ca6376c 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -914,6 +914,26 @@ out: return err; } +static void record__munmap_filtered(struct fdarray *fda, int fd, void *arg) +{ + struct record *rec = (struct record *)arg; + + perf_evlist__mmap_put(rec->evlist, fda->priv[fd].idx); + if (rec->overwrite_evlist) + perf_evlist__mmap_put(rec->overwrite_evlist, fda->priv[fd].idx); +} + +static int record__filter_pollfd(struct record *rec) +{ + /* + * Although we may have auxiliray evlist, there is + * only one pollfd, so we don't need to filter pollfd + * for auxiliray evlist. + */ + return fdarray__filter(&rec->evlist->pollfd, POLLERR | POLLHUP, + record__munmap_filtered, rec); +} + static int __cmd_record(struct record *rec, int argc, const char **argv) { int err; @@ -1150,15 +1170,7 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) err = 0; waking++; - /* - * Although we may have auxiliray evlist, there is - * only one pollfd, so we don't need to filter pollfd - * for auxiliray evlist. - * - * TODO: if an event is terminated (POLLERR | POLLHUP), - * unmap mmaps for auxiliray evlist too. - */ - if (perf_evlist__filter_pollfd(rec->evlist, POLLERR | POLLHUP) == 0) + if (record__filter_pollfd(rec) == 0) draining = true; } diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index e8fcb22..d43ee81 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -27,7 +27,6 @@ #include #include -static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx); static void __perf_evlist__munmap(struct perf_evlist *evlist, int idx); #define FD(e, x, y) (*(int *)xyarray__entry(e->fd, x, y)) @@ -863,7 +862,7 @@ static void perf_evlist__mmap_get(struct perf_evlist *evlist, int idx) atomic_inc(&evlist->mmap[idx].refcnt); } -static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx) +void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx) { struct perf_mmap *md = &evlist->mmap[idx]; diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 41e65ac..ba5e006 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -141,7 +141,7 @@ union perf_event *perf_evlist__mmap_read_backward(struct perf_evlist *evlist, void perf_evlist__mmap_read_catchup(struct perf_evlist *evlist, int idx); void perf_evlist__mmap_consume(struct perf_evlist *evlist, int idx); - +void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx); int perf_evlist__pause(struct perf_evlist *evlist); int perf_evlist__resume(struct perf_evlist *evlist); int perf_evlist__open(struct perf_evlist *evlist); -- 1.8.3.4