From patchwork Thu Sep 7 11:58:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jing Zhang X-Patchwork-Id: 13376390 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D95F1EB8FD8 for ; Thu, 7 Sep 2023 11:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rSQcWFYJwBg0aTl4SCH3DYwXxXPsw9brCnGzhyTCxEU=; b=c9qeI+Pfjxj7Bs NAjVDNbT5XqpDyFGZpAVcZvExsOJExvX5WmhlFwN1LjFxIJ3pDoA7QhECDFCT2v5hWBTsraPiNQEi aBY4fVaoIuf+oFZabVCfu1ynW+8d+gzy57/O9Ovl0baQCBZLEYE8l1jW4bRIt7QGRsInHLg8j5FrS lxMv2iNE/eXoAy4Xh3pW3TjDG/aSr+wRshQjLkUZ56O2PID5mmQWzXrHm7L+CDcv9/n2GT+iiWYyI uPXZMcO+gh6w6d4I1D8Kjv8htd4Hy+jSZsEqZTtd4ck1shmYn7BaOjUYhYfJmbZobrmHSjZAbSX7J Ay1nJLWqASX79l1X8B6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qeDex-00C39M-21; Thu, 07 Sep 2023 11:58:55 +0000 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qeDes-00C35Y-1g for linux-arm-kernel@lists.infradead.org; Thu, 07 Sep 2023 11:58:53 +0000 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=renyu.zj@linux.alibaba.com;NM=1;PH=DS;RN=21;SR=0;TI=SMTPD_---0VrYpebz_1694087927; Received: from srmbuffer011165236051.sqa.net(mailfrom:renyu.zj@linux.alibaba.com fp:SMTPD_---0VrYpebz_1694087927) by smtp.aliyun-inc.com; Thu, 07 Sep 2023 19:58:47 +0800 From: Jing Zhang To: John Garry , Ian Rogers Cc: Will Deacon , James Clark , Arnaldo Carvalho de Melo , Mark Rutland , Mike Leach , Leo Yan , Namhyung Kim , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Adrian Hunter , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-doc@vger.kernel.org, Zhuo Song , Jing Zhang , Shuai Xue Subject: [PATCH v8 4/8] perf jevents: Support more event fields Date: Thu, 7 Sep 2023 19:58:29 +0800 Message-Id: <1694087913-46144-5-git-send-email-renyu.zj@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1694087913-46144-1-git-send-email-renyu.zj@linux.alibaba.com> References: <1694087913-46144-1-git-send-email-renyu.zj@linux.alibaba.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230907_045850_767006_CC463BFD X-CRM114-Status: GOOD ( 13.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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". 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 "eventid=xxx" and "type=xxx", the CMN events 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. And add EventIdCode and NodeType to the event field. I compared pmu_event.c before and after compiling with JEVENT_ARCH=all, they are consistent. Signed-off-by: Jing Zhang --- tools/perf/pmu-events/jevents.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index a7e8833..a80c7cc 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -292,11 +292,14 @@ class JsonEvent: } return table[unit] if unit in table else f'uncore_{unit.lower()}' - eventcode = 0 + eventcode = None if 'EventCode' in jd: eventcode = int(jd['EventCode'].split(',', 1)[0], 0) if 'ExtSel' in jd: - eventcode |= int(jd['ExtSel']) << 8 + if eventcode is None: + eventcode = int(jd['ExtSel']) << 8 + else: + 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 = '' @@ -335,7 +338,11 @@ 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)}' + event = None + if eventcode is not None: + event = f'event={llx(eventcode)}' + elif configcode is not None: + event = f'config={llx(configcode)}' event_fields = [ ('AnyThread', 'any='), ('PortMask', 'ch_mask='), @@ -345,10 +352,15 @@ class JsonEvent: ('Invert', 'inv='), ('SampleAfterValue', 'period='), ('UMask', 'umask='), + ('NodeType', 'type='), + ('EventIdCode', 'eventid='), ] for key, value in event_fields: if key in jd and jd[key] != '0': - event += ',' + value + jd[key] + if event: + event += ',' + value + jd[key] + else: + event = value + jd[key] if filter: event += f',{filter}' if msr: