Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934997AbdLRTNL (ORCPT ); Mon, 18 Dec 2017 14:13:11 -0500 Received: from mga02.intel.com ([134.134.136.20]:49434 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934840AbdLRTNJ (ORCPT ); Mon, 18 Dec 2017 14:13:09 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,423,1508828400"; d="scan'208";a="2804925" From: "Liang, Kan" To: "Wangnan (F)" , "acme@kernel.org" , "peterz@infradead.org" , "mingo@redhat.com" , "linux-kernel@vger.kernel.org" CC: "jolsa@kernel.org" , "namhyung@kernel.org" , "ak@linux.intel.com" , "yao.jin@linux.intel.com" Subject: RE: [PATCH V2 6/8] perf top: add overwrite fall back Thread-Topic: [PATCH V2 6/8] perf top: add overwrite fall back Thread-Index: AQHTbuqjrwOg6NqwRkmbLkKWI/WaKKNIX9YAgAEqHOA= Date: Mon, 18 Dec 2017 19:13:06 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F077537F845C@SHSMSX103.ccr.corp.intel.com> References: <1512603183-42754-1-git-send-email-kan.liang@intel.com> <1512603183-42754-7-git-send-email-kan.liang@intel.com> In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTE1NTcxOTUtYjg1NS00MjU5LThiMjMtMWU4MmI3NTJlNzBiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6Im5aNmMwZDlPckNGV1VUSVwvTGV1UjRwY3E0d21UUU94bGlZVUN0TXMyYzZNPSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id vBIJDF5O010783 Content-Length: 2546 Lines: 85 > > On 2017/12/7 7:33, kan.liang@intel.com wrote: > > From: Kan Liang > > > > Switch to non-overwrite mode if kernel doesnot support overwrite > > ringbuffer. > > > > It's only effect when overwrite mode is supported. > > No change to current behavior. > > > > Signed-off-by: Kan Liang > > --- > > tools/perf/builtin-top.c | 35 +++++++++++++++++++++++++++++++++++ > > 1 file changed, 35 insertions(+) > > > > diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c > > index 5e15d27..7c462d6 100644 > > --- a/tools/perf/builtin-top.c > > +++ b/tools/perf/builtin-top.c > > @@ -931,6 +931,27 @@ static int perf_top_overwrite_check(struct > perf_top *top) > > return 0; > > } > > > > +static int perf_top_overwrite_fallback(struct perf_top *top, > > + struct perf_evsel *evsel) > > +{ > > + struct record_opts *opts = &top->record_opts; > > + struct perf_evlist *evlist = top->evlist; > > + struct perf_evsel *counter; > > + > > + if (!opts->overwrite) > > + return 0; > > + > > + /* only fall back when first event fails */ > > + if (evsel != perf_evlist__first(evlist)) > > + return 0; > > + > > + evlist__for_each_entry(evlist, counter) > > + counter->attr.write_backward = false; > > + opts->overwrite = false; > > + ui__warning("fall back to non-overwrite mode\n"); > > + return 1; > > You can check perf_missing_features.write_backward here. Only do the > fallback > when we know the problem is caused by missing of write_backward. > perf_missing_features is only defined in evsel.c I will add an inline function in evsel.c to do the check. Thanks, Kan > > +} > > + > > static int perf_top__start_counters(struct perf_top *top) > > { > > char msg[BUFSIZ]; > > @@ -954,6 +975,20 @@ static int perf_top__start_counters(struct > perf_top *top) > > try_again: > > if (perf_evsel__open(counter, top->evlist->cpus, > > top->evlist->threads) < 0) { > > + > > + /* > > + * Specially handle overwrite fall back. > > + * Because perf top is the only tool which has > > + * overwrite mode by default, support > > + * both overwrite and non-overwrite mode, and > > + * require consistent mode for all events. > > + * > > + * May move it to generic code with more tools > > + * have similar attribute. > > + */ > > + if (perf_top_overwrite_fallback(top, counter)) > > + goto try_again; > > + > > It will unconditionally remove backward bit even if the problem > is caused by other missing feature. > > Thank you.