Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933515AbdLRJZu (ORCPT ); Mon, 18 Dec 2017 04:25:50 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:11952 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933487AbdLRJZp (ORCPT ); Mon, 18 Dec 2017 04:25:45 -0500 Subject: Re: [PATCH V2 6/8] perf top: add overwrite fall back To: , , , , References: <1512603183-42754-1-git-send-email-kan.liang@intel.com> <1512603183-42754-7-git-send-email-kan.liang@intel.com> CC: , , , From: "Wangnan (F)" Message-ID: Date: Mon, 18 Dec 2017 17:23:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1512603183-42754-7-git-send-email-kan.liang@intel.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.194.139] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.5A378972.003F,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 1580b2417b9ef1f5979796ed04f2538b Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2274 Lines: 76 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. > +} > + > 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.