From patchwork Tue Jul 12 10:00:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 71805 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp384212qga; Tue, 12 Jul 2016 03:01:39 -0700 (PDT) X-Received: by 10.66.235.163 with SMTP id un3mr2358912pac.93.1468317699502; Tue, 12 Jul 2016 03:01:39 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gk9si4467827pac.182.2016.07.12.03.01.39; Tue, 12 Jul 2016 03:01:39 -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 S1753520AbcGLKBg (ORCPT + 30 others); Tue, 12 Jul 2016 06:01:36 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:64076 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932618AbcGLKBA (ORCPT ); Tue, 12 Jul 2016 06:01:00 -0400 Received: from 172.24.1.47 (EHLO szxeml425-hub.china.huawei.com) ([172.24.1.47]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CEQ51178; Tue, 12 Jul 2016 18:00:34 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by szxeml425-hub.china.huawei.com (10.82.67.180) with Microsoft SMTP Server id 14.3.235.1; Tue, 12 Jul 2016 18:00:22 +0800 From: Wang Nan To: , CC: , , , Wang Nan , Arnaldo Carvalho de Melo , He Kuang , Jiri Olsa , Masami Hiramatsu , Namhyung Kim , Nilay Vaish Subject: [PATCH v15 07/12] perf tools: Map backward events to backward_mmap Date: Tue, 12 Jul 2016 10:00:07 +0000 Message-ID: <1468317612-11598-8-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1468317612-11598-1-git-send-email-wangnan0@huawei.com> References: <1468317612-11598-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.5784BFC2.021A, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 05a30477e8984373b5a41fad592ff042 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In perf_evlist__mmap_per_evsel(), select backward_mmap for backward events. Utilize new perf_mmap APIs. Remove useless functions. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: He Kuang Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Zefan Li Cc: Nilay Vaish Cc: pi3orama@163.com --- tools/perf/tests/backward-ring-buffer.c | 4 +-- tools/perf/util/evlist.c | 44 +++++++++++++-------------------- 2 files changed, 19 insertions(+), 29 deletions(-) -- 1.8.3.4 diff --git a/tools/perf/tests/backward-ring-buffer.c b/tools/perf/tests/backward-ring-buffer.c index 1750ef2..3558db7 100644 --- a/tools/perf/tests/backward-ring-buffer.c +++ b/tools/perf/tests/backward-ring-buffer.c @@ -31,8 +31,8 @@ static int count_samples(struct perf_evlist *evlist, int *sample_count, for (i = 0; i < evlist->nr_mmaps; i++) { union perf_event *event; - perf_evlist__mmap_read_catchup(evlist, i); - while ((event = perf_evlist__mmap_read_backward(evlist, i)) != NULL) { + perf_mmap__read_catchup(&evlist->backward_mmap[i]); + while ((event = perf_mmap__read_backward(&evlist->backward_mmap[i], false)) != NULL) { const u32 type = event->header.type; switch (type) { diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 53c25a4..6741ced 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_mmap__munmap(struct perf_mmap *map); static void perf_mmap__put(struct perf_mmap *map); @@ -693,7 +692,7 @@ static int perf_evlist__set_paused(struct perf_evlist *evlist, bool value) int i; for (i = 0; i < evlist->nr_mmaps; i++) { - int fd = evlist->mmap[i].fd; + int fd = evlist->backward_mmap[i].fd; int err; if (fd < 0) @@ -893,16 +892,6 @@ static void perf_mmap__put(struct perf_mmap *md) perf_mmap__munmap(md); } -static void perf_evlist__mmap_get(struct perf_evlist *evlist, int idx) -{ - perf_mmap__get(&evlist->mmap[idx]); -} - -static void perf_evlist__mmap_put(struct perf_evlist *evlist, int idx) -{ - perf_mmap__put(&evlist->mmap[idx]); -} - void perf_mmap__consume(struct perf_mmap *md, bool overwrite) { if (!overwrite) { @@ -1038,12 +1027,6 @@ static int perf_mmap__mmap(struct perf_mmap *map, return 0; } -static int __perf_evlist__mmap(struct perf_evlist *evlist, int idx, - struct mmap_params *mp, int fd) -{ - return perf_mmap__mmap(&evlist->mmap[idx], mp, fd); -} - static bool perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused, struct perf_evsel *evsel) @@ -1055,16 +1038,20 @@ perf_evlist__should_poll(struct perf_evlist *evlist __maybe_unused, static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, struct mmap_params *mp, int cpu, - int thread, int *output) + int thread, int *_output, int *_output2) { struct perf_evsel *evsel; int revent; evlist__for_each_entry(evlist, evsel) { + struct perf_mmap *maps = evlist->mmap; + int *output = _output; int fd; - if (!!evsel->attr.write_backward != (evlist->overwrite && evlist->backward)) - continue; + if (evsel->attr.write_backward) { + output = _output2; + maps = evlist->backward_mmap; + } if (evsel->system_wide && thread) continue; @@ -1073,13 +1060,14 @@ static int perf_evlist__mmap_per_evsel(struct perf_evlist *evlist, int idx, if (*output == -1) { *output = fd; - if (__perf_evlist__mmap(evlist, idx, mp, *output) < 0) + + if (perf_mmap__mmap(&maps[idx], mp, *output) < 0) return -1; } else { if (ioctl(fd, PERF_EVENT_IOC_SET_OUTPUT, *output) != 0) return -1; - perf_evlist__mmap_get(evlist, idx); + perf_mmap__get(&maps[idx]); } revent = perf_evlist__should_poll(evlist, evsel) ? POLLIN : 0; @@ -1092,8 +1080,8 @@ 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, &evlist->mmap[idx], revent) < 0) { - perf_evlist__mmap_put(evlist, idx); + __perf_evlist__add_pollfd(evlist, fd, &maps[idx], revent) < 0) { + perf_mmap__put(&maps[idx]); return -1; } @@ -1119,13 +1107,14 @@ static int perf_evlist__mmap_per_cpu(struct perf_evlist *evlist, pr_debug2("perf event ring buffer mmapped per cpu\n"); for (cpu = 0; cpu < nr_cpus; cpu++) { int output = -1; + int output2 = -1; auxtrace_mmap_params__set_idx(&mp->auxtrace_mp, evlist, cpu, true); for (thread = 0; thread < nr_threads; thread++) { if (perf_evlist__mmap_per_evsel(evlist, cpu, mp, cpu, - thread, &output)) + thread, &output, &output2)) goto out_unmap; } } @@ -1146,12 +1135,13 @@ static int perf_evlist__mmap_per_thread(struct perf_evlist *evlist, pr_debug2("perf event ring buffer mmapped per thread\n"); for (thread = 0; thread < nr_threads; thread++) { int output = -1; + int output2 = -1; auxtrace_mmap_params__set_idx(&mp->auxtrace_mp, evlist, thread, false); if (perf_evlist__mmap_per_evsel(evlist, thread, mp, 0, thread, - &output)) + &output, &output2)) goto out_unmap; }