From patchwork Fri Feb 5 14:02:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 61289 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1113378lbl; Fri, 5 Feb 2016 06:09:11 -0800 (PST) X-Received: by 10.66.156.134 with SMTP id we6mr20036655pab.92.1454681346586; Fri, 05 Feb 2016 06:09:06 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mk9si24170205pab.101.2016.02.05.06.09.06; Fri, 05 Feb 2016 06:09:06 -0800 (PST) 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 S1754710AbcBEOI6 (ORCPT + 30 others); Fri, 5 Feb 2016 09:08:58 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:8017 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754286AbcBEOFH (ORCPT ); Fri, 5 Feb 2016 09:05:07 -0500 Received: from 172.24.1.49 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.1.49]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DAZ55307; Fri, 05 Feb 2016 22:03:41 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by SZXEML429-HUB.china.huawei.com (10.82.67.184) with Microsoft SMTP Server id 14.3.235.1; Fri, 5 Feb 2016 22:03:34 +0800 From: Wang Nan To: Alexei Starovoitov , Arnaldo Carvalho de Melo , Arnaldo Carvalho de Melo , Brendan Gregg CC: Adrian Hunter , Cody P Schafer , "David S. Miller" , He Kuang , =?UTF-8?q?J=C3=A9r=C3=A9mie=20Galarneau?= , Jiri Olsa , Kirill Smelkov , Li Zefan , Masami Hiramatsu , Namhyung Kim , Peter Zijlstra , , Wang Nan , Subject: [PATCH 45/54] perf tools: Detect avalibility of write_backward Date: Fri, 5 Feb 2016 14:02:10 +0000 Message-ID: <1454680939-24963-46-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1454680939-24963-1-git-send-email-wangnan0@huawei.com> References: <1454680939-24963-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.0A020202.56B4ABBD.0156, 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: 389ba94704571cc1055aee608dfa3d57 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Detect avalibility of write_backward and save the result into record_opts. With write_backward the start pointer of a ring buffer mapped read only can be found reliably. Signed-off-by: Wang Nan Signed-off-by: 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/perf.h | 1 + tools/perf/util/record.c | 11 +++++++++++ 2 files changed, 12 insertions(+) -- 1.8.3.4 diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 90129ac..00c25b1 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -71,6 +71,7 @@ struct record_opts { bool sample_transaction; unsigned initial_delay; bool use_clockid; + bool has_write_backward; clockid_t clockid; unsigned int proc_map_timeout; }; diff --git a/tools/perf/util/record.c b/tools/perf/util/record.c index 0467367..d01f155 100644 --- a/tools/perf/util/record.c +++ b/tools/perf/util/record.c @@ -85,6 +85,11 @@ static void perf_probe_comm_exec(struct perf_evsel *evsel) evsel->attr.comm_exec = 1; } +static void perf_probe_write_backward(struct perf_evsel *evsel) +{ + evsel->attr.write_backward = 1; +} + static void perf_probe_context_switch(struct perf_evsel *evsel) { evsel->attr.context_switch = 1; @@ -105,6 +110,11 @@ bool perf_can_record_switch_events(void) return perf_probe_api(perf_probe_context_switch); } +static bool perf_can_write_backward(void) +{ + return perf_probe_api(perf_probe_write_backward); +} + bool perf_can_record_cpu_wide(void) { struct perf_event_attr attr = { @@ -235,6 +245,7 @@ static int record_opts__config_freq(struct record_opts *opts) int record_opts__config(struct record_opts *opts) { + opts->has_write_backward = perf_can_write_backward(); return record_opts__config_freq(opts); }