From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5337CC4332F for ; Mon, 21 Nov 2022 09:54:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230522AbiKUJyS (ORCPT ); Mon, 21 Nov 2022 04:54:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231152AbiKUJxr (ORCPT ); Mon, 21 Nov 2022 04:53:47 -0500 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7C7FF59B; Mon, 21 Nov 2022 01:53:32 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R691e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046051;MF=renyu.zj@linux.alibaba.com;NM=1;PH=DS;RN=20;SR=0;TI=SMTPD_---0VVKH0rx_1669024405; Received: from 30.221.147.226(mailfrom:renyu.zj@linux.alibaba.com fp:SMTPD_---0VVKH0rx_1669024405) by smtp.aliyun-inc.com; Mon, 21 Nov 2022 17:53:28 +0800 Message-ID: Date: Mon, 21 Nov 2022 17:53:25 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Subject: Re: [External] : [RFC PATCH v2 1/6] perf vendor events arm64: Add topdown L1 metrics for neoverse-n2 To: John Garry , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Andrew Kilroy , Shuai Xue , Zhuo Song References: <1667214694-89839-1-git-send-email-renyu.zj@linux.alibaba.com> <1668411720-3581-2-git-send-email-renyu.zj@linux.alibaba.com> <590ff032-d271-48ee-a4d8-141cc070c335@oracle.com> From: Jing Zhang In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2022/11/15 下午7:19, John Garry 写道: > On 15/11/2022 08:43, Jing Zhang wrote: >> I didn't find out how to put the metric as an arch std event, it would be best if you could provide me with an example in the upstream code, >> thank you very much. > > As things stand, I don't think it's supported. We only support regular events for std arch events (and not metrics). > > However we could expand support for metrics. > > For the example of hip08 and FRONTEND_BOUND, we would have: > > --->8--- > > diff --git a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json > index 6443a061e22a..5b1ca45224de 100644 > --- a/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json > +++ b/tools/perf/pmu-events/arch/arm64/hisilicon/hip08/metrics.json > @@ -1,10 +1,6 @@ >  [ >      { > -        "MetricExpr": "FETCH_BUBBLE / (4 * CPU_CYCLES)", > -        "PublicDescription": "Frontend bound L1 topdown metric", > -        "BriefDescription": "Frontend bound L1 topdown metric", > -        "MetricGroup": "TopDownL1", > -        "MetricName": "frontend_bound" > +        "ArchStdEvent": "FRONTEND_BOUND" >      }, >      { >          "MetricExpr": "(INST_SPEC - INST_RETIRED) / (4 * CPU_CYCLES)", > diff --git a/tools/perf/pmu-events/arch/arm64/sbsa.json b/tools/perf/pmu-events/arch/arm64/sbsa.json > new file mode 100644 > index 000000000000..10b9c0cccc40 > --- /dev/null > +++ b/tools/perf/pmu-events/arch/arm64/sbsa.json > @@ -0,0 +1,9 @@ > +[ > +    { > +        "MetricExpr": "FETCH_BUBBLE / (4 * CPU_CYCLES)", > +        "PublicDescription": "Frontend bound L1 topdown metric", > +        "BriefDescription": "Frontend bound L1 topdown metric", > +        "MetricGroup": "TopDownL1", > +        "MetricName": "FRONTEND_BOUND" > +    } > +] > diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py > index 0daa3e007528..77049853c0bf 100755 > --- a/tools/perf/pmu-events/jevents.py > +++ b/tools/perf/pmu-events/jevents.py > @@ -352,6 +352,8 @@ def preprocess_arch_std_files(archpath: str) -> None: >        for event in read_json_events(item.path, topic=''): >          if event.name: >            _arch_std_events[event.name.lower()] = event > +        if event.metric_name: > +          _arch_std_events[event.metric_name.lower()] = event > > >  def print_events_table_prefix(tblname: str) -> None: Sorry for slow response. I tried the method you provided, but it didn't work, is there any other steps I am missing? Or is this method not currently supported? diff --git a/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/metrics.json b/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/metrics index 8ff1dfe..2ad30ec 100644 --- a/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/metrics.json +++ b/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/metrics.json @@ -1,10 +1,6 @@ [ { - "MetricExpr": "(stall_slot_frontend - cpu_cycles) / (5 * cpu_cycles)", - "PublicDescription": "Frontend bound L1 topdown metric", - "BriefDescription": "Frontend bound L1 topdown metric", - "MetricGroup": "TopDownL1", - "MetricName": "frontend_bound" + "ArchStdEvent": "FRONTEND_BOUND" }, diff --git a/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeline.json b/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeli index f9fae15..e8536e2 100644 --- a/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeline.json +++ b/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeline.json @@ -6,9 +6,6 @@ { "ArchStdEvent": "STALL_BACKEND_MEM" - } + }, + { + "MetricExpr": "(stall_slot_frontend - cpu_cycles) / (5 * cpu_cycles)", + "PublicDescription": "Frontend bound L1 topdown metric", + "BriefDescription": "Frontend bound L1 topdown metric", + "MetricGroup": "TopDownL1", + "MetricName": "FRONTEND_BOUND" + } ] diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 0daa3e0..7704985 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -352,6 +352,8 @@ def preprocess_arch_std_files(archpath: str) -> None: for event in read_json_events(item.path, topic=''): if event.name: _arch_std_events[event.name.lower()] = event + if event.metric_name: + _arch_std_events[event.metric_name.lower()] = event #./perf stat -e FRONTEND_BOUND sleep 1 event syntax error: 'FRONTEND_BOUND' \___ parser error Run 'perf list' for a list of valid events Usage: perf stat [] [] -e, --event event selector. use 'perf list' to list available events diff --git a/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeline.json b/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeli index f9fae15..1089ca0 100644 --- a/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeline.json +++ b/tools/perf/pmu-events/arch/arm64/arm/neoverse-n2/pipeline.json @@ -6,18 +6,24 @@ "ArchStdEvent": "STALL_BACKEND" }, { - "ArchStdEvent": "STALL_SLOT_FRONTEND" + "ArchStdEvent": "STALL_SLOT_FRONTEND", + "MetricExpr": "STALL_SLOT_FRONTEND - CPU_CYCLES" }, { #./perf stat -e stall_slot_frontend sleep 1 Add CPU_CYCLES event to groups to get metric expression for stall_slot_frontend Performance counter stats for 'sleep 1': 5,125,457 stall_slot_frontend //it's still the original value. 1.001017680 seconds time elapsed 0.001162000 seconds user 0.000000000 seconds sys Thanks, Jing