From patchwork Sat Feb 17 00:57:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Atish Kumar Patra X-Patchwork-Id: 1900383 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Fls/M2/E; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=ceLAXlKF; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=oFh8WNP+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tc9S5467fz23j8 for ; Sat, 17 Feb 2024 11:59:33 +1100 (AEDT) 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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=VIVyabLWdW3QmWY3nba4Q7sXVy9WY347zIHQ3TU/S4E=; b=Fls/M2/ErLNqjl hYmd/bqrZtYyIVhb0U9c0YhfO3MUyPZ1N6aTQRyKsnZaN3X+KfeWnnExGJ6WFsmtLSCNmcR4Ivayn KhrHK3rMvKSXaS6shnrOvpzFAIX5rltU0FiV/AzhgPqp6l+SY98456y0UIaMpfchnjfxzZRzoKsJ3 cVgtUYAwTe0gAROxVmo6AK+UMe17crzxAHt5F70Mn9Gk06oCZbYFI6Qm4xEY701yyUlmLG+EgxqE8 KKqE8U4BIet5MJdotw35dDPkYmpGXPv87HcHFgBMq1MCFozvFP36O1ke2kI9v8NnsF/rDmMbIt0t9 grqZ21zkUXniLgTjdq1A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rb93D-00000004IwK-3Q6H; Sat, 17 Feb 2024 00:59:31 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rb92r-00000004IcI-4Bbg for kvm-riscv@bombadil.infradead.org; Sat, 17 Feb 2024 00:59:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=UM8zssVewnxKekt4u8gJqVdaJ7ofC8o/V7nPW8x9v/k=; b=ceLAXlKFmR4uv2q5M0QRD1+o0f 7ePXaTaMTKotcCSwJKXPAcx3sEcyXi54r0fAUxqxmxe0at4yDkpgyWXdBIDQIROAbaknx3Q+CIpgQ AIgkQbpSLSFLmtXwnYezvuUyo9d9Ni8GFinoJJmzf9YdK1DXyzjKqkGN6xeZGSMAVBP/WmeJ6LE/g 2hglCStlH3xqdLYIir1Z9wmPGJ+1o55vkwgCgYpUIbCPstR6JEibINaPXlhSdb90QMJMyTA5M3F2Y ixPoyc+A/qXB5jGq40aLLLgErP7M/oY05RlkO2bLEdql6kWmM9ASwOv7LS/aZ1ifXVkrkZvpFHte4 otUusyBw==; Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rb92l-000000066Vs-13HD for kvm-riscv@lists.infradead.org; Sat, 17 Feb 2024 00:59:08 +0000 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-204235d0913so985165fac.1 for ; Fri, 16 Feb 2024 16:58:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1708131536; x=1708736336; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UM8zssVewnxKekt4u8gJqVdaJ7ofC8o/V7nPW8x9v/k=; b=oFh8WNP+nVk4dgqXIJ3culYotJRJlclhIhANf6NYu9w+2tmmDRExpYHY7Gg59y6A4P 5+N+kWnR/r7qRLL5CAWXm7MZLGTS33hgK+qAfc6RDhuSYD7MPE7pnPRPqx3DkxLm7ggU uwLFQ1cblMB72m/d1syvtZoVxT35xOfULj43E6JJ0gRtKWPfgH+RJlM67oSOSXXSG4xd IWddN6qcQn+XpB4nTkKCliKuJb1bBUegZm7LCaKDIESYzpAiU7gnIxqHDZranA31Vaet H5FC6UCw97aorzQagZM6g3LyhhhUZIjp1Gg4qM2qTljxetOVS7Fv4eFVME1crJc5JwK2 ng1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708131536; x=1708736336; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UM8zssVewnxKekt4u8gJqVdaJ7ofC8o/V7nPW8x9v/k=; b=JCP01PxkAKc+1lPGHI12+sRO8QJFz6BPVbTC4ypZaSHGZEQah23IGDTsOUPz6HOi6w mnS9qCtyw92IkAl3ykZZKJR/TgSzmI8vlvImEGTKPuXBuaNPiS3UAs/KLq32H5TS0QLp iTDG+j/9EI5K8+rBCmAhiiyz/IazgzvYyh+w/TocFtyn09qEo1EO9fo8ZgiihvSEO4gY dD1Q00Q3F5ZYrdL6fTijg7Rd9+oIrZGVazEHnImSnRBJKyWsmm80i2XXvql0aW3g9ZuK 1t9MCB32iD9LcDZsGq99nizdqpkcxEDPf15oBpcUKb3oDRR0UfyY/QTFxm3RgCKkxeNP bafw== X-Forwarded-Encrypted: i=1; AJvYcCUTX637sxuBJVSXeScfcx/k+/xAN1/K6jYPlHNnyWv9HSK3SoAARsYfRKkfjd+wDf021nO7MyTWLFT7urvSgmsltNJJxIzIKInlqcKcIA== X-Gm-Message-State: AOJu0Yx9z3roU2CXHy38tepNWVCpTKGfmKPQgyLiiYxpTVT9jasJ2r6x jgkIcB4GKfMvatlJkq4mZppbOYyv46ZBzCmA0x0kmGDkkTrvJp95TC7PrEfGwK8= X-Google-Smtp-Source: AGHT+IHxQ/ohabidKPISMfSUq9m2exq/kzmKZJs/ZvDEyG8lUk4zXZLeanKyyRpfmzqm9XJNLg+WQw== X-Received: by 2002:a05:6870:d88d:b0:218:df68:87b2 with SMTP id oe13-20020a056870d88d00b00218df6887b2mr6753520oac.44.1708131536206; Fri, 16 Feb 2024 16:58:56 -0800 (PST) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d188-20020a6336c5000000b005dc89957e06sm487655pga.71.2024.02.16.16.58.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 16:58:55 -0800 (PST) From: Atish Patra To: linux-kernel@vger.kernel.org Cc: Atish Patra , Adrian Hunter , Alexander Shishkin , Alexandre Ghiti , Andrew Jones , Anup Patel , Arnaldo Carvalho de Melo , Atish Patra , Christian Brauner , =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= , Conor Dooley , devicetree@vger.kernel.org, Evan Green , Guo Ren , Heiko Stuebner , Ian Rogers , Ingo Molnar , James Clark , Jing Zhang , Jiri Olsa , Ji Sheng Teoh , John Garry , Jonathan Corbet , Kan Liang , Krzysztof Kozlowski , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, Ley Foon Tan , linux-doc@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Namhyung Kim , Palmer Dabbelt , Paul Walmsley , Peter Zijlstra , Rob Herring , Samuel Holland , Weilin Wang , Will Deacon , kaiwenxue1@gmail.com, Yang Jihong Subject: [PATCH RFC 16/20] tools/perf: Pass the Counter constraint values in the pmu events Date: Fri, 16 Feb 2024 16:57:34 -0800 Message-Id: <20240217005738.3744121-17-atishp@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240217005738.3744121-1-atishp@rivosinc.com> References: <20240217005738.3744121-1-atishp@rivosinc.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240217_005904_877562_421AD1D3 X-CRM114-Status: GOOD ( 11.38 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 4.0.0 on casper.infradead.org summary: Content analysis details: (-1.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2001:4860:4864:20:0:0:0:32 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: kvm-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org RISC-V doesn't have any standard event to counter mapping discovery mechanism in the ISA. The ISA defines 29 programmable counters and platforms can choose to implement any number of them and map any events to any counters. Thus, the perf tool need to inform the driver about the counter mapping of each events. The current perf infrastructure only parses the 'Counter' constraints in metrics. This patch extends that to pass in the pmu events so that any driver can retrieve those values via perf attributes if defined accordingly. Signed-off-by: Atish Patra --- tools/perf/pmu-events/jevents.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jevents.py index 30934a490109..f1e320077695 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -278,6 +278,11 @@ class JsonEvent: return fixed[name.lower()] return event + def counter_list_to_bitmask(counterlist): + counter_ids = list(map(int, counterlist.split(','))) + bitmask = sum(1 << pos for pos in counter_ids) + return bitmask + def unit_to_pmu(unit: str) -> Optional[str]: """Convert a JSON Unit to Linux PMU name.""" if not unit: @@ -401,6 +406,10 @@ class JsonEvent: else: raise argparse.ArgumentTypeError('Cannot find arch std event:', arch_std) + if self.counter: + bitmask = counter_list_to_bitmask(self.counter) + event += f',counterid_mask={bitmask:#x}' + self.event = real_event(self.name, event) def __repr__(self) -> str: