From nobody Tue Mar 4 22:17:56 2025 Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 2E284228CB5 for ; Tue, 14 Jan 2025 22:58:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736895536; cv=none; b=YiXYLM9CCfIN+atw2ATRKf59MtMQcT+kdeWEBPwDosP4sIv7KkNR0igf2BvdrAWDBrrXvb7O0MjtP0O3uWsvtiKLwWkbkHOEcm1nfw3qVQ5UNp44nIo4eL8h+BwPQSfw/BlvxW8Ad40JV00peqOtG/sHLMH7f6nVvh+LcSqO2CU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736895536; c=relaxed/simple; bh=GjWW1PZeSMVVp/YE0YLQ4xt4IwvJzVvhTdWUcKrLGJ4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qHBt+uIZuwqQipRUTkXyi3DjOhNUgeowq456hIQNwmr/3PBr2Fmw+9CjzTzkl3wm9Dt50g+VoneThOwp+9qy6eaGi7k0FdCnkAt+SjAPzNwkd11OZdfeGqJWl70+gV+ReZgBYQ3vEU78BVLOVRY+90h26YrE4UKJZujnpd7QqSs= 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=sJ/kB4SG; arc=none smtp.client-ip=209.85.214.182 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 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="sJ/kB4SG" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-2166360285dso107554845ad.1 for ; Tue, 14 Jan 2025 14:58:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1736895533; x=1737500333; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Msmauk788mzUDGMUfQ29+G0+6TVWgLFLPWjnpzGrxFY=; b=sJ/kB4SGi8na+gbFnBYd8OP+47A3uEraV7hRXgqe29hgDtc6Erznu4IVKv7n7K8zYL Pkk2kcR6yjJ4Ccb8bmjoEdc2dPr95mW25hlLevoBGRuL1vmdw7KfavKYzfieBEnjyrZy HF0La35wl9X9CjQHimsvbPVBR/Z2lVAhB61WuN+oCwUw1uRvuoi3W1/LDPdLj2PlL0c9 OtzVR4ELGppP7gjS5aulzB0yYsooNotbePH+tOnfHGQIGFW+uRx/ChBgCNnqHJDdUHnV 97m1OpCcJ/P429f1NiXOeTRnsslaEhweIBgFIS3Shj3nG2v2GAdkhfxgbslVyhJ8Y+Iv fggw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736895533; x=1737500333; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Msmauk788mzUDGMUfQ29+G0+6TVWgLFLPWjnpzGrxFY=; b=Sxf6w7q++d/GZHLxr196ge2CnpolqPxBs85fSochQXap+8lJO3K/WYEsXG3f4ptB76 4mjl8q1obBBEqoW4kqIk772Oi7ml3TrzXoUQp15RFtjgqk9jKoUWsifBB9CUTsfNeXFq VXF/aK7S8B0k/05MPwvWXQBbGgmpF6+pNBwfzz9zxG+DAmCGiVyxZuELwCAOikUBRLn3 PVCQLH/8hVeQ9AWKX79mPd+4P0XC25gawtZY0zSNHR+gCYIuNMQplCzowSVpFUZ81Xi8 al2bqxRsxirvJNL+MCWrYlccKNU1YGinNM100hqW8bHtU0oAuN9Gq5Bq1eE4tMRR3s5y Y9+w== X-Forwarded-Encrypted: i=1; AJvYcCWqTmmPpY03ag0NvcgqTxBGW4N4kkn1UlrEp2zk7FDDvxhF6GfixchY/KUqLi4rCjSk55YbIptuB6jhE0Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yzjqiit3Rb1+5semkN5rJSMKyursvhrlOhenhj3oDa6zVE2O1lL W/juhRn+DbjHKcljEbQpYTx1scqzYAQ8IktjO3kJsHUXgue0YXJvkA5LiJ71lwg= X-Gm-Gg: ASbGncspIVS6oWMz2ZnvxbLS8i6EzUqcbPl540mQtxNZ4yJDx9U13OquA3vzMxADBZQ 7phKWQxd9ZkSLa8H9SqEul0PA/U8S6ybKAetQuDhDT+tbjIKyALC62zCXD8ifh9yedKw8GhNwtY oVyeO0d2AgydqbsjTNmUNXVPnGa4Dnn+MHBC9DR3u8/9pMIrWL/o9DnAyC1V1FPBGOzvCmdeItc z7+XHmUOwVVilstUfaJkVi6o4W34a/WWH5PUnLOvGMiX6SAUMi4K6p1jqeSv9XPx9sWwQ== X-Google-Smtp-Source: AGHT+IHVlOGIv+9Uh+Dng9Z5glMQS7vdErpemdoZ1TuQIxVK5mxZMQQK+rAFLrYfNXcGXxNvYIFeiA== X-Received: by 2002:a17:903:1cf:b0:21a:8300:b9d5 with SMTP id d9443c01a7336-21a83f4cd36mr432431955ad.23.1736895533476; Tue, 14 Jan 2025 14:58:53 -0800 (PST) Received: from atishp.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21a9f10df7asm71746105ad.47.2025.01.14.14.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 14:58:53 -0800 (PST) From: Atish Patra Date: Tue, 14 Jan 2025 14:57:45 -0800 Subject: [PATCH v2 20/21] tools/perf: Pass the Counter constraint values in the pmu events Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250114-counter_delegation-v2-20-8ba74cdb851b@rivosinc.com> References: <20250114-counter_delegation-v2-0-8ba74cdb851b@rivosinc.com> In-Reply-To: <20250114-counter_delegation-v2-0-8ba74cdb851b@rivosinc.com> To: Paul Walmsley , Palmer Dabbelt , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Anup Patel , Atish Patra , Will Deacon , Mark Rutland , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , weilin.wang@intel.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Conor Dooley , devicetree@vger.kernel.org, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, Atish Patra X-Mailer: b4 0.15-dev-13183 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/jeven= ts.py index 28acd598dd7c..c21945238469 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -274,6 +274,11 @@ class JsonEvent: return fixed[name.lower()] return event =20 + def counter_list_to_bitmask(counterlist): + counter_ids =3D list(map(int, counterlist.split(','))) + bitmask =3D 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 or unit =3D=3D "core": @@ -427,6 +432,10 @@ class JsonEvent: else: raise argparse.ArgumentTypeError('Cannot find arch std event:', ar= ch_std) =20 + if self.counters['list']: + bitmask =3D counter_list_to_bitmask(self.counters['list']) + event +=3D f',counterid_mask=3D{bitmask:#x}' + self.event =3D real_event(self.name, event) =20 def __repr__(self) -> str: --=20 2.34.1