Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932973AbeAKVaZ convert rfc822-to-8bit (ORCPT + 1 other); Thu, 11 Jan 2018 16:30:25 -0500 Received: from mga02.intel.com ([134.134.136.20]:1252 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932667AbeAKVaY (ORCPT ); Thu, 11 Jan 2018 16:30:24 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,346,1511856000"; d="scan'208";a="10558707" From: "Liang, Kan" To: Jiri Olsa CC: "acme@kernel.org" , "peterz@infradead.org" , "mingo@redhat.com" , "linux-kernel@vger.kernel.org" , "wangnan0@huawei.com" , "jolsa@kernel.org" , "namhyung@kernel.org" , "ak@linux.intel.com" , "yao.jin@linux.intel.com" Subject: RE: [PATCH V3 10/12] perf top: add overwrite fall back Thread-Topic: [PATCH V3 10/12] perf top: add overwrite fall back Thread-Index: AQHTeohYtdbQAv2DjkqxRxS5wzWfDqNuVSYAgAD1GIA= Date: Thu, 11 Jan 2018 21:30:20 +0000 Message-ID: <37D7C6CF3E00A74B8858931C1DB2F077537FFC30@SHSMSX103.ccr.corp.intel.com> References: <1513879734-237492-1-git-send-email-kan.liang@intel.com> <1513879734-237492-11-git-send-email-kan.liang@intel.com> <20180111142626.GH16655@krava> In-Reply-To: <20180111142626.GH16655@krava> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiODdhMTRjZTktNzU5Ni00M2JjLWExMWQtYTRkYzBlMGJkMDU0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6Ikd3SFFhMlprVmZtMW15RUpYSDRLMkEwbXlZZm1WNDJQcGNwOGhkUmxUaWs9In0= 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="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: > On Thu, Dec 21, 2017 at 10:08:52AM -0800, 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 | 36 ++++++++++++++++++++++++++++++++++++ > > 1 file changed, 36 insertions(+) > > > > diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c > > index 4b85e7b..8d19ef7 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; > > +} > > we already do that for evsel in perf_evsel__open.. could we make > this fallback on one place only? > > checking the code, why don't we follow the > perf_missing_features.write_backward > like we do for other features in the perf_evsel__open and set > write_backward accordingly, like in attached patch. > No, the per-event fallback is explicitly disabled in perf_evsel__open. You may refer to commit 32a951b4fd6b ("perf evlist: Drop redundant evsel->overwrite indicator)". Now, only perf top supports the whole fallback. So it is specially handled. Thanks, Kan > jirka > > > --- > diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c > index dbd80268de54..89253f4ff9ee 100644 > --- a/tools/perf/util/evsel.c > +++ b/tools/perf/util/evsel.c > @@ -1683,9 +1683,6 @@ int perf_evsel__open(struct perf_evsel *evsel, > struct cpu_map *cpus, > int pid = -1, err; > enum { NO_CHANGE, SET_TO_MAX, INCREASED_MAX } set_rlimit = > NO_CHANGE; > > - if (perf_missing_features.write_backward && evsel- > >attr.write_backward) > - return -EINVAL; > - > if (cpus == NULL) { > static struct cpu_map *empty_cpu_map; > > @@ -1725,6 +1722,8 @@ int perf_evsel__open(struct perf_evsel *evsel, > struct cpu_map *cpus, > } > > fallback_missing_features: > + if (perf_missing_features.write_backward) > + evsel->attr.write_backward = false; > if (perf_missing_features.clockid_wrong) > evsel->attr.clockid = CLOCK_MONOTONIC; /* should always > work */ > if (perf_missing_features.clockid) {