From patchwork Mon Jan 11 13:48:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wangnan (F)" X-Patchwork-Id: 565851 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id CF4721402D9 for ; Tue, 12 Jan 2016 00:59:09 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760208AbcAKNyq (ORCPT ); Mon, 11 Jan 2016 08:54:46 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:41440 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760086AbcAKNtx (ORCPT ); Mon, 11 Jan 2016 08:49:53 -0500 Received: from 172.24.1.51 (EHLO szxeml422-hub.china.huawei.com) ([172.24.1.51]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BUI71837; Mon, 11 Jan 2016 21:49:37 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by szxeml422-hub.china.huawei.com (10.82.67.152) with Microsoft SMTP Server id 14.3.235.1; Mon, 11 Jan 2016 21:49:30 +0800 From: Wang Nan To: CC: , , , , , Wang Nan , He Kuang , "Arnaldo Carvalho de Melo" , Jiri Olsa , Masami Hiramatsu , Namhyung Kim Subject: [PATCH 50/53] perf tools: Set tailsize attribut bit for overwrite events Date: Mon, 11 Jan 2016 13:48:41 +0000 Message-ID: <1452520124-2073-51-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1452520124-2073-1-git-send-email-wangnan0@huawei.com> References: <1452520124-2073-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.0A090201.5693B2F2.00B5, 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: 3b48d0948f40ae78be01706a31d284ed Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org PERF_SAMPLE_TAILSIZE pad the size of an event at the end of it in the ring buffer, makes reading from overwrite ring buffer possible. This patch set that bit if evsel->overwrite is selected explicitly by user. Overwrite and tailsize are still controled separatly for legacy readonly mmap users (most of them are in perf/tests). 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/util/evlist.c | 2 ++ tools/perf/util/evlist.h | 1 + tools/perf/util/evsel.c | 28 ++++++++++++++++++++++++++++ tools/perf/util/evsel.h | 1 + 4 files changed, 32 insertions(+) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 0511fd2..510e960 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -973,6 +973,8 @@ perf_evlist__channel_for_evsel(struct perf_evsel *evsel) if (evsel->overwrite) flag |= PERF_EVLIST__CHANNEL_RDONLY; + if (evsel->tailsize) + flag |= PERF_EVLIST__CHANNEL_TAILSIZE; return flag; } diff --git a/tools/perf/util/evlist.h b/tools/perf/util/evlist.h index 21a8b85..4dfcd67 100644 --- a/tools/perf/util/evlist.h +++ b/tools/perf/util/evlist.h @@ -24,6 +24,7 @@ struct record_opts; enum perf_evlist_mmap_flag { PERF_EVLIST__CHANNEL_ENABLED = 1, PERF_EVLIST__CHANNEL_RDONLY = 2, + PERF_EVLIST__CHANNEL_TAILSIZE = 4, }; /** diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index c59ea34..ae69a85 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -671,13 +671,33 @@ static void apply_config_terms(struct perf_evsel *evsel, attr->inherit = term->val.inherit ? 1 : 0; break; case PERF_EVSEL__CONFIG_TERM_OVERWRITE: + /* + * Let tailsize and overwrite controled by /overwrite/ + * semultaneously because /overwrite/ can only be + * passed by user explicitly, in this case user should + * be able to read from that event so tailsize must + * set. + * + * (overwrite && !tailsize) can happen only when + * perf_evlist__mmap() is called with overwrite == true. + * In that case there's no chance to pass /overwrite/. + */ evsel->overwrite = term->val.overwrite ? 1 : 0; + evsel->tailsize = term->val.overwrite ? 1 : 0; break; default: break; } } + /* + * Set tailsize sample bit after config term processing because + * it is possible to set overwrite globally, without config + * terms. + */ + if (evsel->tailsize) + perf_evsel__set_sample_bit(evsel, TAILSIZE); + /* User explicitly set per-event callgraph, clear the old setting and reset. */ if ((callgraph_buf != NULL) || (dump_size > 0)) { @@ -748,7 +768,15 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts) attr->sample_id_all = perf_missing_features.sample_id_all ? 0 : 1; attr->inherit = !opts->no_inherit; + + /* + * opts->overwrite can be set by user only. + * Always keeps evsel->overwrite == evsel->tailsize. + * (evsel->overwrite && !evsel->tailsize) can only happen + * when calling perf_evlist__mmap() with overwrite == true. + */ evsel->overwrite = opts->overwrite; + evsel->tailsize = opts->overwrite; perf_evsel__set_sample_bit(evsel, IP); perf_evsel__set_sample_bit(evsel, TID); diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index c76e385..d93ee02 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -118,6 +118,7 @@ struct perf_evsel { bool per_pkg; bool precise_max; bool overwrite; + bool tailsize; /* parse modifier helper */ int exclude_GH; int nr_members;