From patchwork Wed Feb 28 17:56:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 207948 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3511059dyb; Wed, 28 Feb 2024 09:59:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWUC789AJMGXxAo2IUhJQrOoj4X3QSAHEfm0kD6Xd8usZFpdKndPy1hWTjLUq/LzrKJ4LsygpOTn3HhjxjSdFCSRXh0Bg== X-Google-Smtp-Source: AGHT+IEh5XBB9TxWm3V8DUKVNEGk0pjz3JTMU8/mIezrgav1ufPy08RjfbLgXHJO2t9pxbSsprkH X-Received: by 2002:a17:906:130f:b0:a43:86f3:af37 with SMTP id w15-20020a170906130f00b00a4386f3af37mr319906ejb.53.1709143150578; Wed, 28 Feb 2024 09:59:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709143150; cv=pass; d=google.com; s=arc-20160816; b=aBjEEAmN6AKt9/oOt8EoJvA4E2BAPd3iu1qTTybddmRA+hQ4RSrWrrxMDyd52JlRGI s394Ey1IzuEQNLSVxsgFvW3vNd6tJDVDFV69t5R4LIFhmo2VPuNjO3hXMHPf1C2EFPaj +A97Uf0y6PtZQaDsp2pzKqGfWBpGjOz2hCapH1FteYXlE8pFVfcOmCClaw+dB6BVM1Ch GametN4lUR+4XI0HtG4fQxrnlSIAQkafR2m+UrRv6RCEWKU65Bgu4jxhDk3ZQlFDpz4i ZC2Qqxvrnaq2YDD5lH+5xGBxVpajObepyDWBxQH7/mya+Sfx1puDtDcr+IocteDLhykt k8Dw== 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=n8Zy/5k2whAdLtuhk9uJVeAHCzZsg+vx3YKGl8xR8NQ=; fh=RB2hY1dEhxKvflUSVr3kweQfnj3Ks6WrRT/ygnr4dlY=; b=M2YqJrO5dV/eaj9OQlS/HXQ267IAxRtw9lTVDcWkoAxdueKu8MrjXD3DXfMi5R8qbe fvcnYbx1+/3Vnvsh5O/f16AOLDr7x9BoUi3Hio8vI0eohK9pN+vG+4XsET/Se3sU5wgn Us5/3N0JTbDCRb2zCqAPsEwLggtC3Ld1D8hDfWrTknu5fXTIQ3Fpb/80+/r+mpE1Fw3S GwW7VcyX4BhX35aHJR8tjRCc08YsDxQb6cHoEmoWu+vZDJ1m424mI80gPrYBjoIEp9BE EuId4t1JIqSxxHRvNNckgb7v3MdmVSCsFzWfABgrc7x4FfkuycmwzjlZe07w11H7M1ot sAmQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=f9F7X2ms; 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-85485-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85485-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id h9-20020a1709062dc900b00a443094cb2dsi14713eji.193.2024.02.28.09.59.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 09:59:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85485-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=f9F7X2ms; 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-85485-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85485-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3589D1F2475E for ; Wed, 28 Feb 2024 17:59:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87A6F7442E; Wed, 28 Feb 2024 17:57:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="f9F7X2ms" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) (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 3330515E5DE for ; Wed, 28 Feb 2024 17:57:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709143022; cv=none; b=Omre/PwPZghkMUT+UQpq4AAVsazF0qtvl5TQw0CYdD0rh0zeRtSHthtHCcm6MeI+98OlNx/g2uyE3Pg0iVveYQQFVS3g0RKjZzX2RqtRhD4WtxdtY7yQpAURuox/mnlBMhqgymLWEvUu5fPYt83Ywp9sLnv4dGMBGn7RJbqBJE8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709143022; c=relaxed/simple; bh=YRU8U8+xDv3At1J+LdyKbbC3IhjldoIrvcOvRSvL8Lc=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=SUxHxuungUOsYYZM2aPQ8l34RWQ0c00EUOOiGDAmd/YWLncaXMUaN5PrIYAkc7S5wu1uyeOnQKAFxmHZ9JtyYE4w2dEEky+H+O7kt+Dimb297lQKbjkVpM+MUGv5nW6ktTOKo8bdkrqv9FlSrKyizw4hWSrxF4RjCzcIncyI5vk= 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=f9F7X2ms; arc=none smtp.client-ip=209.85.128.201 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-yw1-f201.google.com with SMTP id 00721157ae682-6094c745eb7so229337b3.2 for ; Wed, 28 Feb 2024 09:57:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709143020; x=1709747820; 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=n8Zy/5k2whAdLtuhk9uJVeAHCzZsg+vx3YKGl8xR8NQ=; b=f9F7X2msOY1NVT21sluW2WqEQpkqjyDTXXm/JcKw71RLTJhTUwAXnaJ7EUo8g6csX8 Z+4OQBkSfcjeCIcyF/qEfQB6eFTLtGZufxDNi3JSmGwTyPuQqX+SPmoxHm60X4AIOrjf mO+WkQHnA+gE/f0dqvvv2sGd/xOA2stnvdIOFiXB/QAjMLnQn3thIlFSgUHq3lNYWPpW J7DzGig8oWnkHGropKNWn6+k7Af0lWOP7+NW38kYF7vjv5HVbjzU4G2aUpxKev3I+EPy Cp9Bpp+zjVovLF430B7DqwGHRmX8I6rlJGlIkoHX7QfdYRlvP6cKSaThGFYMPkpJ8JEJ TCEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709143020; x=1709747820; 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=n8Zy/5k2whAdLtuhk9uJVeAHCzZsg+vx3YKGl8xR8NQ=; b=XXAGihN6D+sr/xOWcIIaTHtLnFAsEHIDC2DkKNtwU0HCcM9wRFrFYYQpXVtn3MMtPV 717OtuHebrLn0yiwi0HnECuaE4ZuhVXfhn1rQqvok5X5Bu5UN0qD3EutceQtJo6c6eyq IaeB06pJuRylk3s59f85BqL5pqwIkp9GxmQlEkE7zZKL5zMUllOAF6aMXBLERQfpVGka zY9FG8nTeOgOHWX2rCw+txFmPsU6ydybkor9FHOqUuVO5OsE/vlOcaoPNZmvpzus1KiX bFhAKXYkhLN2JcbLJy5HnqRPAS56MlPTRObqIb7Ytx4vqEMvzwI3gilY6IOTLkZLxLST qzxg== X-Forwarded-Encrypted: i=1; AJvYcCVzuYZ4ajW1NpsoLJJtuAtrFpqQkY6kapOoZj9MDjcVu369tqpFiZrJUpn4ASFPxCg23cW+wTUS2Ghs8E4BzVeIhUTzkfoUefl9Vskk X-Gm-Message-State: AOJu0YyTE0rWXrLPTWjkAucHV+q71GGRF+MMljlwgtu/sKl8T7VdQ7CM E7PbHw2XLoPGDPn6hRgdelS8zsscyva5n30wzYcOPKdzJbRHnOSfBteTNi76mqpjjTUtg5aOLX7 icbaZcQ== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:77dc:144c:334e:e2dd]) (user=irogers job=sendgmr) by 2002:a05:6902:1004:b0:dbe:387d:a8ef with SMTP id w4-20020a056902100400b00dbe387da8efmr157ybt.1.1709143019661; Wed, 28 Feb 2024 09:56:59 -0800 (PST) Date: Wed, 28 Feb 2024 09:56:15 -0800 In-Reply-To: <20240228175617.4049201-1-irogers@google.com> Message-Id: <20240228175617.4049201-11-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240228175617.4049201-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v1 10/12] perf jevents: Skip optional metrics in metric group list 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792166487753015851 X-GMAIL-MSGID: 1792166487753015851 For metric groups, skip metrics in the list that are None. This allows functions to better optionally return metrics. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric.py index 8b37cef0256a..0326050f1e0f 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -492,13 +492,15 @@ class MetricGroup: """ def __init__(self, name: str, - metric_list: List[Union[Metric, 'MetricGroup']], + metric_list: List[Union[Optional[Metric], Optional['MetricGroup']]], description: Optional[str] = None): self.name = name - self.metric_list = metric_list + self.metric_list = [] self.description = description for metric in metric_list: - metric.AddToMetricGroup(self) + if metric: + self.metric_list.append(metric) + metric.AddToMetricGroup(self) def AddToMetricGroup(self, group): """Callback used when a MetricGroup is added into another."""