Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp637892lqg; Fri, 1 Mar 2024 17:00:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWTCvqL0rHpaL09B0RKZBaTOh6SQi4UcCjP0jpmz1hSL84xgox1gpXSroG6uVstpogCHxtpPPIsypckZDUXX/Vyu7bXwuxk5sUZdvJzYQ== X-Google-Smtp-Source: AGHT+IHTcsLJKqS3dKJJaizDCIjX72UME2liDYUgBA+6HjdtalPs1MFDXW8noUp6Vm5lIkvvIbEe X-Received: by 2002:a05:6a20:144c:b0:1a0:f3f4:3b1a with SMTP id a12-20020a056a20144c00b001a0f3f43b1amr4123318pzi.10.1709341251301; Fri, 01 Mar 2024 17:00:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341251; cv=pass; d=google.com; s=arc-20160816; b=qt93GlxUzuu1VczZPKlr4/VKUThcS4SbqSylRsfPaCKy9mFU2onR2ROK4E0Zb6D8PY OVxNLtuJNXaebyncmCoMdzZzYyj4pKlmLbkQAoM8APbVQu+nkQrlaJIPWspad1gytQao TQfENrGRemoQATL2QdydPJGyv3mMNl/kQ3MaKqFZlF40Sl+jayzlYyHqRWQCXYRbRaDi hlgXXYN6WrJT4jtlaEGISksSnwLW3Jbu40tS0AszPp7LDRALXpI9L8CpcOkUO7WB2taB 8LzL+DeEcqS/CfC56T0ilOCPSfxpvjvXj72I/TjJI6Fu1S5GEql1qLFp2cPeEX5a8BAz 7lMg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:from:subject:references:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:in-reply-to:date :dkim-signature; bh=cnw+7frKkpFIuv39tcYmSQZnvJ8fkaJfcm6LBjLqiJc=; fh=BMkRC0jL7DfKo9K2fBApyx3uFWPSFYbLM1A1WRxdjVM=; b=m4v3+vNXwb7+YhcyZPf9mHCYL720PHO7+WQhW7d7DeVRVZHc4xZLwqQBPnqxOaV3vL KIwNfjBgVQM/mCjqCjZdUwvu8HBqvuUqLsuffRtRrdLPEAX/rXV0NlURfpy0JrDNjq6t rE8O8b9bCX0yiCsdTHci8Ogx/QqbcmJVP7Kb+UHoQTi6bXZ1FjAbWf1aIgUG49p47H6K IuqShcBH8tJvdnfsV5Sl9gzHPYsyOA5zoheQdw3Zrrilv5PmmKvvhcopmaGYAp6YpOwM vPJEFgsVlKBDcnGCvXSHyg5jW8zghgCQChSkp8Pmi4vfkHLxF9Wtc8JVaiueCBL8h1Z8 dzOA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lqMq4sXT; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89277-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89277-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h187-20020a636cc4000000b005e43cb6847bsi4569781pgc.877.2024.03.01.17.00.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:00:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89277-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=lqMq4sXT; arc=pass (i=1 spf=pass spfdomain=flex--irogers.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-89277-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89277-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0233A286C0F for ; Sat, 2 Mar 2024 01:00:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 48EB110A0A; Sat, 2 Mar 2024 01:00:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lqMq4sXT" Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (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 F17BC79F6 for ; Sat, 2 Mar 2024 01:00:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341207; cv=none; b=sFoftPHEolxbaFZGIcAMIAXFrkgQbmiEMsAlvFmriD7Byux6FhtWSR9Qxtxw7HdPOh8XOGsWM9WqaLLd+3tCerl1DxDUdNEcUTlPkj66Zl7GnkN34BrfZsRNkAVPetCDVmOTlk5tP31V//ml4M9ZmJYeRgwqx2pFxEWZLf4pb3k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341207; c=relaxed/simple; bh=GN4Y68feIoyK84NORTnkVtG7K1dAvlvEPxB9mo8klN0=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=WY/jtcctyEPAm7969p/rS8WGtoHZAhJJPY6xN6LL7+kqR+WOhA6R33ow8x37mWeXdqYXWgxObU4nmHPwVvlTzQdx4xvO6JUhSCFED3bJKn3YUqzT0XmFutqRo2p4DqsyEZ36zc3CwKjyz9EuSK5Bf1oljpQ9XVHU+9pjmSEuAd4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lqMq4sXT; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-dcc58cddb50so4696377276.0 for ; Fri, 01 Mar 2024 17:00:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341205; x=1709946005; darn=vger.kernel.org; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=cnw+7frKkpFIuv39tcYmSQZnvJ8fkaJfcm6LBjLqiJc=; b=lqMq4sXTlul76pp7I2oLoCW6U/v5uVo6CEQD4cpCawLPRu5lJlYZuqybKp+AQmLDnD jzTwNCgCke0KYsGqOlh25zFNKJDWjSbE+IPa2t3LMXjAcm/EAvQiKM1ofM4WwJINFBMZ LOs6NvatFNkFFHYQS8GQQDbN6+9zPaNNt75s76eoiZHXLXrxxRI+PeQOolQ+JjaI3sRm E0yxTt4tcA1cUPliGxbNqOfv6GghntCHwSIDBRJj4QY5/jdiA7DA0V0PjxB0L5XBvFIe 6pPdr6LweaA3CrTkxDUq6i/91bBTdJWEh6lYfVZN+WJaVBMjYScUUcUW6vGEwENrOm37 zmyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341205; x=1709946005; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cnw+7frKkpFIuv39tcYmSQZnvJ8fkaJfcm6LBjLqiJc=; b=qw70wLIrDayENU0CYcE4PosFSO7PzGeqPmEmDTG3BKwKG8EARHFBPntS2iSfwsVkjB n1RZtNssxYmhQIAfSZ0hBWZEgSTP91ubIo6pvMbqvt3gmDCOy3WZl4RQbSrD5K14/yIH M/AnIreTPy5OoUaeYuP0NFhwis9PZOnAltxQ6WtgC7GMcq9J8rckH0dxqHY6WgYXAOZM 1wAVtmIHnYJTZaIJJy6ESdLH4eFMg72w6eHv5DWn3VNM59opC4Q8pAAJbkP1ldlYul9x 9c3bzSjX2Pd1A/fGbLzeCtGFCOt5QBBLhqqkj0ft3wAik/Toua/J/EJCyIV5IVuA/6md pXYw== X-Forwarded-Encrypted: i=1; AJvYcCX1ueAror3Y2UuTzNPwUDpJcQ1aopBp7Y1u9n9kV11JojoxibCpe+7rzhQaS/P/rOX5dSOBsUcMoPIdtm+WOpIk5xTZ5uKxvBkfLBUL X-Gm-Message-State: AOJu0YzjmyU0E1IlQ/QU1+/fxbsy+Vnjb6FFbqH+j3FtIHzApQh/HG0F ZDqTTolBj/62m5/KmYsB+8Sgr0uKEX6lxs0TepbZvCKRA8a3wmWXTXq6LmwS8MZ0wdrx2WLW8jq BMYSIRw== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a05:6902:1004:b0:dc2:3441:897f with SMTP id w4-20020a056902100400b00dc23441897fmr721544ybt.6.1709341205149; Fri, 01 Mar 2024 17:00:05 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:41 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-4-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 03/12] perf jevents: Add descriptions to metricgroup abstraction From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , John Garry , Kan Liang , Jing Zhang , Thomas Richter , James Clark , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Andi Kleen , Kajol Jain , Sandipan Das , Ravi Bangoria , Perry Taylor , Samantha Alt , Caleb Biggers , Weilin Wang , Edward Baker , Stephane Eranian Content-Type: text/plain; charset="UTF-8" Add a function to recursively generate metric group descriptions. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py index 8a718dd4b1fe..1de4fb72c75e 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -475,6 +475,8 @@ class Metric: return result + def ToMetricGroupDescriptions(self, root: bool = True) -> Dict[str, str]: + return {} class _MetricJsonEncoder(json.JSONEncoder): """Special handling for Metric objects.""" @@ -493,10 +495,12 @@ class MetricGroup: which can facilitate arrangements similar to trees. """ - def __init__(self, name: str, metric_list: List[Union[Metric, - 'MetricGroup']]): + def __init__(self, name: str, + metric_list: List[Union[Metric, 'MetricGroup']], + description: Optional[str] = None): self.name = name self.metric_list = metric_list + self.description = description for metric in metric_list: metric.AddToMetricGroup(self) @@ -516,6 +520,12 @@ class MetricGroup: def ToPerfJson(self) -> str: return json.dumps(sorted(self.Flatten()), indent=2, cls=_MetricJsonEncoder) + def ToMetricGroupDescriptions(self, root: bool = True) -> Dict[str, str]: + result = {self.name: self.description} if self.description else {} + for x in self.metric_list: + result.update(x.ToMetricGroupDescriptions(False)) + return result + def __str__(self) -> str: return self.ToPerfJson() -- 2.44.0.278.ge034bb2e1d-goog