Message ID | 1691394685-61240-4-git-send-email-renyu.zj@linux.alibaba.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp1308200vqr; Mon, 7 Aug 2023 01:43:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHH9GVp1Jz7oq5tbyiZFB8c+iUiUEfHRwS0b6Uq/pMy7b7Hdo1yFa3ll8tDKiNpRdSKP2zo X-Received: by 2002:a17:907:2cce:b0:96a:63d4:24c5 with SMTP id hg14-20020a1709072cce00b0096a63d424c5mr6983848ejc.77.1691397785738; Mon, 07 Aug 2023 01:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691397785; cv=none; d=google.com; s=arc-20160816; b=CLoOoGmpVLlYZPtJ0WZoulfkeGezuSLGYwG7bZfimnVyyPZMEIob31s6tVWavz3Nl4 BDNGlkJVoc+dOB92Kvh3LP10QvywKYweJt48WS/fPTowIql6manqHUKhT+FRvdJfUlvC dVSSAm5CZukx4FurA0WoMD4wKBlibWAEXdp91CVDt2WeRvVGvdSOFaxohnHwhhpUh9cG r2Rh6B4jkGetUvC2e/HbYoST2UPQV0wTeoSTZ+yQicQAJcwv7R407DoQW0qtITMMz4qY XyDHH7C6GkdY9++rj+cUWwbZTfll+E474Na6GCxbpI+yqKRr4mhifDs7d9dcMhbyZzEM j6Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=yB2vdpGxMK6B5kG62AU/YzIuE5xW0g9xoTVTHKGypyA=; fh=7pF9AUGuuVLtftwWy2EJKaooMcBit4LAHr6bHM40jlQ=; b=anmze111v12aKZ0Sfl13Hot6SKVIRpF4eYTfeTjAcATVmGmeQUXFc8lkJua8ChEwdb 0sDqnTT4CFDohi/F7gfDc9cCl6lmKsOomfQbjEueYwSN00Sz6G7OxF3PxN2Wk5Qj7EsX jelP7EvJthddrQ5cjBaidkeivNVvAhboYp0+l/Pfqx4i3sAMqrRvSPym1kTm6rCUoVNf tCLO41nJprEN6xKibTG+uZKxCfQ6qEA8f6ztmR07jmo0IsKb6110pV1UOo3dwbX97Y9X s+eVwrC647Wgwfx7tBQR5+sS2XdYBD376xbPIj3YMahKyjJCayb8QS5h2Pyp/zSmBXvq L1mA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ss10-20020a170907038a00b0098947f89083si5274871ejb.390.2023.08.07.01.42.41; Mon, 07 Aug 2023 01:43:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231320AbjHGHvt (ORCPT <rfc822;aaronkmseo@gmail.com> + 99 others); Mon, 7 Aug 2023 03:51:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231140AbjHGHvo (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 7 Aug 2023 03:51:44 -0400 Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8497510F4; Mon, 7 Aug 2023 00:51:42 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;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=21;SR=0;TI=SMTPD_---0VpC-045_1691394696; Received: from srmbuffer011165236051.sqa.net(mailfrom:renyu.zj@linux.alibaba.com fp:SMTPD_---0VpC-045_1691394696) by smtp.aliyun-inc.com; Mon, 07 Aug 2023 15:51:37 +0800 From: Jing Zhang <renyu.zj@linux.alibaba.com> To: John Garry <john.g.garry@oracle.com>, Ian Rogers <irogers@google.com> Cc: Will Deacon <will@kernel.org>, James Clark <james.clark@arm.com>, Arnaldo Carvalho de Melo <acme@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Mike Leach <mike.leach@linaro.org>, Leo Yan <leo.yan@linaro.org>, Namhyung Kim <namhyung@kernel.org>, Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@redhat.com>, Alexander Shishkin <alexander.shishkin@linux.intel.com>, Jiri Olsa <jolsa@kernel.org>, Adrian Hunter <adrian.hunter@intel.com>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, Zhuo Song <zhuo.song@linux.alibaba.com>, Jing Zhang <renyu.zj@linux.alibaba.com>, Shuai Xue <xueshuai@linux.alibaba.com> Subject: [PATCH v6 3/7] perf jevents: Support more event fields Date: Mon, 7 Aug 2023 15:51:21 +0800 Message-Id: <1691394685-61240-4-git-send-email-renyu.zj@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1691394685-61240-1-git-send-email-renyu.zj@linux.alibaba.com> References: <1691394685-61240-1-git-send-email-renyu.zj@linux.alibaba.com> X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773559124784558133 X-GMAIL-MSGID: 1773559124784558133 |
Series |
Add aliases and metrics for Arm CMN
|
|
Commit Message
Jing Zhang
Aug. 7, 2023, 7:51 a.m. UTC
The usual event descriptions are "event=xxx" or "config=xxx", while the
event descriptions of CMN are "type=xxx, eventid=xxx" or more complex.
$cat /sys/bus/event_source/devices/arm_cmn_0/events/hnf_cache_fill
type=0x5,eventid=0x3
When adding aliases for events described as "event=xxx" or "config=xxx",
EventCode or ConfigCode can be used in the JSON files to describe the
events. But "eventid=xxx, type=xxx" cannot be supported at present.
If EventCode and ConfigCode is not added in the alias JSON file, the
event description will add "event=0" by default. So, even if the event
field is added to supplement "eventid=xxx" and "type=xxx", the final
parsing result will be "event=0, eventid=xxx, type=xxx".
Therefore, when EventCode and ConfigCode are missing in JSON, "event=0" is
no longer added by default. EventIdCode and Type are added to the event
field, and ConfigCode is moved into the event_field array which can also
guarantee its original function.
Signed-off-by: Jing Zhang <renyu.zj@linux.alibaba.com>
---
tools/perf/pmu-events/jevents.py | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
Comments
On 07/08/2023 08:51, Jing Zhang wrote: > The usual event descriptions are "event=xxx" or "config=xxx", while the > event descriptions of CMN are "type=xxx, eventid=xxx" or more complex. > > $cat /sys/bus/event_source/devices/arm_cmn_0/events/hnf_cache_fill > type=0x5,eventid=0x3 > > When adding aliases for events described as "event=xxx" or "config=xxx", > EventCode or ConfigCode can be used in the JSON files to describe the > events. But "eventid=xxx, type=xxx" cannot be supported at present. > > If EventCode and ConfigCode is not added in the alias JSON file, the > event description will add "event=0" by default. So, even if the event > field is added to supplement "eventid=xxx" and "type=xxx", the final > parsing result will be "event=0, eventid=xxx, type=xxx". > > Therefore, when EventCode and ConfigCode are missing in JSON, "event=0" is > no longer added by default. EventIdCode and Type are added to the event > field, and ConfigCode is moved into the event_field array which can also > guarantee its original function. > > Signed-off-by: Jing Zhang <renyu.zj@linux.alibaba.com> I'll let Ian check this change as he is more familiar with this code. Thanks
在 2023/8/7 下午5:24, John Garry 写道: > On 07/08/2023 08:51, Jing Zhang wrote: >> The usual event descriptions are "event=xxx" or "config=xxx", while the >> event descriptions of CMN are "type=xxx, eventid=xxx" or more complex. >> >> $cat /sys/bus/event_source/devices/arm_cmn_0/events/hnf_cache_fill >> type=0x5,eventid=0x3 >> >> When adding aliases for events described as "event=xxx" or "config=xxx", >> EventCode or ConfigCode can be used in the JSON files to describe the >> events. But "eventid=xxx, type=xxx" cannot be supported at present. >> >> If EventCode and ConfigCode is not added in the alias JSON file, the >> event description will add "event=0" by default. So, even if the event >> field is added to supplement "eventid=xxx" and "type=xxx", the final >> parsing result will be "event=0, eventid=xxx, type=xxx". >> >> Therefore, when EventCode and ConfigCode are missing in JSON, "event=0" is >> no longer added by default. EventIdCode and Type are added to the event >> field, and ConfigCode is moved into the event_field array which can also >> guarantee its original function. >> >> Signed-off-by: Jing Zhang <renyu.zj@linux.alibaba.com> > > I'll let Ian check this change as he is more familiar with this code. > Ok, thanks!
在 2023/8/7 下午5:24, John Garry 写道: > On 07/08/2023 08:51, Jing Zhang wrote: >> The usual event descriptions are "event=xxx" or "config=xxx", while the >> event descriptions of CMN are "type=xxx, eventid=xxx" or more complex. >> >> $cat /sys/bus/event_source/devices/arm_cmn_0/events/hnf_cache_fill >> type=0x5,eventid=0x3 >> >> When adding aliases for events described as "event=xxx" or "config=xxx", >> EventCode or ConfigCode can be used in the JSON files to describe the >> events. But "eventid=xxx, type=xxx" cannot be supported at present. >> >> If EventCode and ConfigCode is not added in the alias JSON file, the >> event description will add "event=0" by default. So, even if the event >> field is added to supplement "eventid=xxx" and "type=xxx", the final >> parsing result will be "event=0, eventid=xxx, type=xxx". >> >> Therefore, when EventCode and ConfigCode are missing in JSON, "event=0" is >> no longer added by default. EventIdCode and Type are added to the event >> field, and ConfigCode is moved into the event_field array which can also >> guarantee its original function. >> >> Signed-off-by: Jing Zhang <renyu.zj@linux.alibaba.com> > > I'll let Ian check this change as he is more familiar with this code. > Hi Ian, Could you please help to review this change?:) Thanks, Jing
在 2023/8/15 上午6:31, Ian Rogers 写道: > On Mon, Aug 7, 2023 at 12:51 AM Jing Zhang <renyu.zj@linux.alibaba.com> wrote: >> >> The usual event descriptions are "event=xxx" or "config=xxx", while the >> event descriptions of CMN are "type=xxx, eventid=xxx" or more complex. > > I found this difficult to read in relation to the code. Perhaps: > > The previous code assumes an event has either an "event=" or "config" > field at the beginning. For CMN neither of these may be present, as an > event is typically "type=xx,eventid=xxx". > Thank you for providing a more accurate and readable description. I was indeed struggling with how to describe the problem more accurately before. > I think the use of the name "type" here is unfortunate. It conflicts > with the PMU's type as defined in perf_event_attr. > I agree, but it would require modifying the driver, which is not currently being considered. In the meantime, I can describe the event_field as ('NodeType', 'type='). > In general I think the jevents.py code needs improving, the > event_fields dictionary is convoluted, we shouldn't be afraid to > change the event json for example to get rid of things like ExtSel, we > should really ensure the formats in the events are valid for the PMU > they are for. > >> $cat /sys/bus/event_source/devices/arm_cmn_0/events/hnf_cache_fill >> type=0x5,eventid=0x3 >> >> When adding aliases for events described as "event=xxx" or "config=xxx", >> EventCode or ConfigCode can be used in the JSON files to describe the >> events. But "eventid=xxx, type=xxx" cannot be supported at present. >> >> If EventCode and ConfigCode is not added in the alias JSON file, the >> event description will add "event=0" by default. So, even if the event >> field is added to supplement "eventid=xxx" and "type=xxx", the final >> parsing result will be "event=0, eventid=xxx, type=xxx". >> >> Therefore, when EventCode and ConfigCode are missing in JSON, "event=0" is >> no longer added by default. EventIdCode and Type are added to the event >> field, and ConfigCode is moved into the event_field array which can also >> guarantee its original function. > > A useful test can be to build with JEVENTS_ARCH=all and confirm the > before and after change generated pmu-events.c is the same. > Okay, I will test it right away. >> Signed-off-by: Jing Zhang <renyu.zj@linux.alibaba.com> >> --- >> tools/perf/pmu-events/jevents.py | 21 +++++++++++++-------- >> 1 file changed, 13 insertions(+), 8 deletions(-) >> >> diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py >> index f57a8f2..9c0f63a 100755 >> --- a/tools/perf/pmu-events/jevents.py >> +++ b/tools/perf/pmu-events/jevents.py >> @@ -275,12 +275,6 @@ class JsonEvent: >> } >> return table[unit] if unit in table else f'uncore_{unit.lower()}' >> >> - eventcode = 0 >> - if 'EventCode' in jd: >> - eventcode = int(jd['EventCode'].split(',', 1)[0], 0) >> - if 'ExtSel' in jd: >> - eventcode |= int(jd['ExtSel']) << 8 >> - configcode = int(jd['ConfigCode'], 0) if 'ConfigCode' in jd else None >> self.name = jd['EventName'].lower() if 'EventName' in jd else None >> self.topic = '' >> self.compat = jd.get('Compat') >> @@ -317,7 +311,15 @@ class JsonEvent: >> if precise and self.desc and '(Precise Event)' not in self.desc: >> extra_desc += ' (Must be precise)' if precise == '2' else (' (Precise ' >> 'event)') >> - event = f'config={llx(configcode)}' if configcode is not None else f'event={llx(eventcode)}' >> + eventcode = None >> + if 'EventCode' in jd: >> + eventcode = int(jd['EventCode'].split(',', 1)[0], 0) >> + if 'ExtSel' in jd: >> + if eventcode is None: >> + eventcode = int(jd['ExtSel']) << 8 >> + else: >> + eventcode |= int(jd['ExtSel']) << 8 >> + event = f'event={llx(eventcode)}' if eventcode is not None else None >> event_fields = [ >> ('AnyThread', 'any='), >> ('PortMask', 'ch_mask='), >> @@ -327,10 +329,13 @@ class JsonEvent: >> ('Invert', 'inv='), >> ('SampleAfterValue', 'period='), >> ('UMask', 'umask='), >> + ('ConfigCode', 'config='), > > This loses the int and potential base conversion of ConfigCode. > Clearly the code was taking care to maintain this behavior so I > suspect this change has broken something. JEVENTS_ARCH=all should > reveal the answer. > You are correct, I compared the generated pmu-events.c files before and after, and they are indeed different, with before:config=0x5 vs after:config=0x05. I will keep the original way of handling ConfigCode in the next version. >> + ('Type', 'type='), >> + ('EventIdCode', 'eventid='), >> ] >> for key, value in event_fields: >> if key in jd and jd[key] != '0': >> - event += ',' + value + jd[key] >> + event = event + ',' + value + jd[key] if event is not None else value + jd[key] > > Perhaps initialize event above to the empty string then: > > if key in jd and jd[key] != '0': > if event: > event += ',' > event += value + jd[key] > If the event is None, the statement event += value + jd[key] would result in an error. So, maybe I can use the following way: if event: event += ',' + value + jd[key] else: event = value + jd[key] Thanks, Jing
diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index f57a8f2..9c0f63a 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -275,12 +275,6 @@ class JsonEvent: } return table[unit] if unit in table else f'uncore_{unit.lower()}' - eventcode = 0 - if 'EventCode' in jd: - eventcode = int(jd['EventCode'].split(',', 1)[0], 0) - if 'ExtSel' in jd: - eventcode |= int(jd['ExtSel']) << 8 - configcode = int(jd['ConfigCode'], 0) if 'ConfigCode' in jd else None self.name = jd['EventName'].lower() if 'EventName' in jd else None self.topic = '' self.compat = jd.get('Compat') @@ -317,7 +311,15 @@ class JsonEvent: if precise and self.desc and '(Precise Event)' not in self.desc: extra_desc += ' (Must be precise)' if precise == '2' else (' (Precise ' 'event)') - event = f'config={llx(configcode)}' if configcode is not None else f'event={llx(eventcode)}' + eventcode = None + if 'EventCode' in jd: + eventcode = int(jd['EventCode'].split(',', 1)[0], 0) + if 'ExtSel' in jd: + if eventcode is None: + eventcode = int(jd['ExtSel']) << 8 + else: + eventcode |= int(jd['ExtSel']) << 8 + event = f'event={llx(eventcode)}' if eventcode is not None else None event_fields = [ ('AnyThread', 'any='), ('PortMask', 'ch_mask='), @@ -327,10 +329,13 @@ class JsonEvent: ('Invert', 'inv='), ('SampleAfterValue', 'period='), ('UMask', 'umask='), + ('ConfigCode', 'config='), + ('Type', 'type='), + ('EventIdCode', 'eventid='), ] for key, value in event_fields: if key in jd and jd[key] != '0': - event += ',' + value + jd[key] + event = event + ',' + value + jd[key] if event is not None else value + jd[key] if filter: event += f',{filter}' if msr: