Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1444958rdb; Fri, 16 Feb 2024 17:05:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXB3Ltkn9YLgPqwA+YvSEOo+QH1oHKkNMrGyjkv8eyn1rbbru8D4jxfyr90PaFEXTLumuZfMvAwptgEfotYU9Jtn2Nk5X1onTw2JfgpSw== X-Google-Smtp-Source: AGHT+IFoLFlZS6XDqXnOb3H7KCOe+zKUUK/5q2nSnXHypJl2i5KUpcQ+ITYXF4CPdj0ErMWbV5DB X-Received: by 2002:a50:9e05:0:b0:563:eda5:2201 with SMTP id z5-20020a509e05000000b00563eda52201mr2619727ede.13.1708131906727; Fri, 16 Feb 2024 17:05:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708131906; cv=pass; d=google.com; s=arc-20160816; b=MBxS8eLOFzno1kZ+OWqZk8vfLbHcRSGM7PctdhNmTA0Xc23pg9iY4TU5aX2O9pZtjE qVXpJvVEjWb9r+4aPoBAcw3ch7mIv792P5/rDYYxs6trYx2nplz0p56l9thsWaqnBgaw iGzAG8v3kJX25YfnzU/vuZDQcKNa+FcCKBogeAsUxYHF9vRyApuZqwr9Id0gEZhPTBMJ BGXkmdCg3gT4WJJ0yY26Pi7EPGehWYUleb0hC1m1d0y3GCwylDfJvb0vwSBdJwudzpGZ 8zflh3/ZAVBXjPDKUxMjgARu7MbzgZ7f3L7Z0mAS27jNTdCGmGeezDt2VVo2sxLAsGTU CIWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=UM8zssVewnxKekt4u8gJqVdaJ7ofC8o/V7nPW8x9v/k=; fh=VCn6lt55QOKjzv0Hbz5VO3vbW0BxeXx0oGBGk4MoX4I=; b=GWO6yD9ZHP5yYwam7m8bwzUPatYUrJHObM94Vgitgdz3aNCpfc6Ur+sKV1fNJmAONk 46/DyvL8xfzRpo79yAbqPqv8d0bMjiUoArFJaoaNdN54IM0gQA4Z/xjJDiPZYy8vcTKl lU6wF2+30VkR4uTJ2O+vuBSpcJBUiTFLotoQrRZGZ5eEaFku8zhnh4bcNWD2vfBVwttv ZG9m0X0uJqJz+1hIu4317bKWloYhflRduwhDsVUFZwNpoYaEkwR2KdH/wUJSjMLfPjV5 p+KIA0RdBxIwDsy7jw5j8KVOiRQu/dULAWxx6FsEWkk998VDfS1TUYN8C1nIj4nBy8SA u4lQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=IgB1jEAv; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-69613-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69613-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id w9-20020aa7d289000000b00563e5c0848bsi424266edq.160.2024.02.16.17.05.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 17:05:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69613-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b=IgB1jEAv; arc=pass (i=1 spf=pass spfdomain=rivosinc.com dkim=pass dkdomain=rivosinc-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-69613-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69613-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4C38A1F22760 for ; Sat, 17 Feb 2024 01:05:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA8193589C; Sat, 17 Feb 2024 00:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="IgB1jEAv" Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA0742E827 for ; Sat, 17 Feb 2024 00:58:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708131539; cv=none; b=p5aXMP1Mq4mCbVXEzZP/GwW3TueJn0Rwv8Lx5BUZ4jh0Cx2jPCV2nb2rWTl8kkhH+S7NgnDvkia6TauspDMiJDcJfgR2VfZpYn6BeJW17vT1vONRIowkJAE+Y3r1NL7k8B+fg7P4VcnVyeiL10U5OfW8zoW3Bo4LA19aOoU9Ia8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708131539; c=relaxed/simple; bh=54qScfthhEAuE+eosMKvOHGN/ixxPgbOd6VfF3jL3Tw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Gg/9aVk4xxqiWWZWP7qe2yo+PZtsGmRhtqPBxFAv0T2QOArxZAKOMUgPbwlp8KzruX3kFS8R+VdyClB5uM4bn4jOi1r2+Qho90gWHxmCLHTSAGkBAXFlYhVCmnSsctBzCsYtRZU2rhLXFsBUCzd5deHQ4xSFshvnKeY33+gwJUE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=IgB1jEAv; arc=none smtp.client-ip=209.85.160.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-204235d0913so985170fac.1 for ; Fri, 16 Feb 2024 16:58:57 -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=vger.kernel.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=IgB1jEAvE7iziKe+kiL4G5rklZhg3WbbRBBwz4ZZG025TosNvCatOhacEuCwYZbbDv 1/OIZ0YFWVO7/uytWcDkABOvZeIpc47ewmvGP51nsbyn5RcQteoyW3DPeETQr+BmZJ4/ h1RKcwHZEs2mEyB/rpYav+dk/Qv7CN43JjuOwG+5lRD9PEhuqTwoPZxzXz3oNbu1Whnb Ao7T+RPeGC3Z/WDky5jnm8Qz7MdD9y78/JnrqYQgYkXMBZE/oav16ct1GHza/lJyVeJF ZmCFbxTAEKMyt111fBvI4dS1xyrutETKjgC/h7vZ492YLeysf0CJ+edkROLAe8e1t3KP XMcA== 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=vAmgpyI1zJ+EYnCtqyVtzxShh6KlqufXQAuoR4PIhVSNZhOA+/vhqCGL1/FYSA4NEU cwuujrLVE5EYkUA3/T0UAU9mVHelwAhvxj0O0YBLl1hKpaor2Mr2ktAjq1JTfytHD5mz 3XFoJyyIZcI+bQz6NG9JhY7rmxr4cN0A/ebEX3EjTKJHNFX6TgYqw2QtsBIAuk/Nfy4W M+7XSkE8cBxRoL8KbOvtaNLnrSeIYl/3tjzrq9jzXWWfC15LtcCHu1VxdIvPFVTs/Ed5 3BPH5UKRq/CFhZ8oYyMe+y1+LpS0D7xcggQEo+JASJEDiukCFjmmEYmj0KOBBvIwiojs sorg== X-Gm-Message-State: AOJu0Yz9FTfu9uChXxF/OZv7CtYAEbQhYj9fuinuqY/U4B84/ae/mt6h LOdstd5BPTwIGYNbn7Yu1HGgwdDydUK5RIl0BU5Dqa/VktrB2PM17FlphU/izS7XOi2fywQyg1P Y 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?q?Cl=C3=A9ment=20L=C3=A9ger?= , 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: -- 2.34.1