From patchwork Wed Jun 15 02:23:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 70072 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp2342753qgf; Tue, 14 Jun 2016 19:25:02 -0700 (PDT) X-Received: by 10.107.129.18 with SMTP id c18mr25053819iod.102.1465957502212; Tue, 14 Jun 2016 19:25:02 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6si35945545pfj.214.2016.06.14.19.25.01; Tue, 14 Jun 2016 19:25:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932716AbcFOCYv (ORCPT + 30 others); 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 Received: from 172.24.1.60 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.60]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DIR04628; Wed, 15 Jun 2016 10:23:56 +0800 (CST) Received: from euler.hulk-profiling (10.107.193.250) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.235.1; Wed, 15 Jun 2016 10:23:46 +0800 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 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 Precedence: bulk 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(-) -- 1.8.3.4 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);