Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp638763lqg; Fri, 1 Mar 2024 17:02:31 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU4bP7I2dzB+ydlEHTiJAu+f0c8AWCpUE04wNnnj+cOPbvb8z1cDY/kGUy4bh7hy69B5lL7AiE4v1xSs37XNioDC3kAT8WeiKI9Y/nwHQ== X-Google-Smtp-Source: AGHT+IGYcJXHJaLKDg7xCJFULBLK86Oa6PJ7xIA2NHzpfGrRXuSBgQolE3+Ox+JCKWSctdqJKlfp X-Received: by 2002:ad4:5bef:0:b0:68f:b825:9255 with SMTP id k15-20020ad45bef000000b0068fb8259255mr10296783qvc.22.1709341350956; Fri, 01 Mar 2024 17:02:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341350; cv=pass; d=google.com; s=arc-20160816; b=OKcaJcFI2mIT0inSdIMm69ysQzvsaFNINYWCQ211fh8wkt5e05g2HmirqO+nf5phTB ueQRmOffTB++wvIpo8gmvckqZWHvt9dYXb5ogHfeH8Rh7vWnsIPN2FQCKHeEUrWHh+mP jFk7ZoTpS71ehnxC80vt5rg1aNJxoXFlNRJL/vyQu8au50rFc9puOu+6iBhUdoJtS5+g 1rzsKpQb3alosJMWDis4DutzmZEZT6Lc/SP/tu0IP2p0Pj0TDfRMeKIW5ETb70QnOikQ qCuBUYgJ6tyAeNXNqteT3Jke9EWP+79gSonasa169lrmFBEIkB6bNF9ZV1eKz5SxdHHk iJjQ== 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=gGG+6HzWesnJ1eAogyUwc6CZn4obQaKW0ElKvKW4EMk=; fh=4RW0vBTBYNajgfnBpbHPcAtyVkkJviebcNgMI+Y35Vk=; b=kG4GdZsdGFvnI1R6Dk0gqETDQtSRUm/KGOcgXsaPVGOXaHlYx86HQfDXJp9wSMVZd9 RSZNrQPt02ichHcglIwYF9QGpg9rnZz3RU+S/Gmzw9K8RUoMGSfjU3KNtrB/a63174AC /G1wvvjOaAYXYABzsw8Z659tYLVhHgFpapfRko0DHFMbEmjQNJ1CYN5dHEr2ITpjROCJ wxQEJ/p09JWGUHVP4OA7EwIRcEXZJaFc+7DZq9ZGoI9kRLFBNXrC2Srla5w1dJ4h0f71 KpTUrMKHRPSM+W/lQaaD6NXm+ksoyQ338f+B5iNOQO4fpMhcIyvWANgp2tuSDlr73epM 1q0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vAYyEJkI; 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-89284-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89284-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id q13-20020a056214194d00b0068f7fca91c9si4789252qvk.164.2024.03.01.17.02.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:02:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89284-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=vAYyEJkI; 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-89284-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89284-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id AA5891C20D57 for ; Sat, 2 Mar 2024 01:02:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58F8417BAB; Sat, 2 Mar 2024 01:00:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="vAYyEJkI" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.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 0E91C1775C for ; Sat, 2 Mar 2024 01:00:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341224; cv=none; b=rbKvJ9dpjJUPfgbgbvSb49HY3dSCGm0NguksL3e2RcW0wy0hgoXevEjcxNwjg80Nn8IVY1aMPjIOZOiJ33dv2eZYk+RErrY18lmofqllhdJuakwsO11bbDhckUgM9VFUDYinbDNVUv1IQ5bRCU576twbNL/AssVtpJLqnt88968= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341224; c=relaxed/simple; bh=gNv29+h0IhWRsa2qydUVk3E45fI6zH8amlK1YqhsJZ8=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=rXtODrd++4AL7DNBSmU4qB5J80EHDotoMdkjP/1swO7C7NQ67Ncf50Bl1GtoLnazk0UYzy9Yb5TTvajBVLUE5GgGtWEQfH0mVukwT8pu117Mzj+0apSettiedC4mwtYDY2D9y0qWpQYm9lRKtn6Ld3Qlcch5GH9mvsOcAhXxhD8= 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=vAYyEJkI; arc=none smtp.client-ip=209.85.219.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-yb1-f201.google.com with SMTP id 3f1490d57ef6-dbf618042daso4152456276.0 for ; Fri, 01 Mar 2024 17:00:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341222; x=1709946022; 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=gGG+6HzWesnJ1eAogyUwc6CZn4obQaKW0ElKvKW4EMk=; b=vAYyEJkIzKm3wM3sYfkjG86tfhIHfz0zDBxf4hrKBdXdaF8Q3BLphix7jN503LOtUr oRSN1f7cw2v3j3PIL5O6XBCvoVRNLZTGHGsPwq5PKq8MLlRe1xjNgO+FI4iPH0KcEHVX 7ry9JV9SZ1wD/AkGaLxQKEATB9tQ8XA77wKH2YZ8VlTPXLTwwzuFncDvHqCqmjhnmbUT GhEGxGZbkKZ0fTd0BI7xLtTyBqXO/Eg6yKbVCAVFtSOPy+LVlbwt2OEDEHLVvOOQwGNG JeqgjYEwmaBarD2jEuVr74SS6VQk6MYNXnm2V3WwMM/WclQeIaxhNEEV0UXo92nXi77z t2Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341222; x=1709946022; 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=gGG+6HzWesnJ1eAogyUwc6CZn4obQaKW0ElKvKW4EMk=; b=YiULfYhVO8WGZjYJJ+BqaJe5Yfl/dL4RQ8je5u4FOoDAs85FDRkMMStmPhwbUkYYfo JSEa+E95e94kgJRqE4CBHBzUiMr3DExd+Iii2wOUcuu5p5MWbh0aBNCRnnWpyrR+NjZf be2fmQQBA9CZAVgE1rSWrA0YWRQkmXTBFztaw5EzVTY5JNd/N2MA+lHs3BxgDRju3gwG 8Lu0ku4/BSReAvzyXFOFvW5doOPsAM2+EuglaJlTwCeKyD8Szd2aekX7Kc3J3iqM9LRt fitvVdhDKeLU7NCbTMNc4j5BqO/ZDoyNed5Bhb+C58HnV7VtlanYld2r2042VprRf4zU Z63A== X-Forwarded-Encrypted: i=1; AJvYcCUIAFoCftNe4yamqxfudYmzIK+IUPd9V91dBDdZzkVaihA3wkllkmhVSK2kNBIIQFjD86iPWEI+TVUvxKHHgg/7SkR37yOfNMyH+3XG X-Gm-Message-State: AOJu0Ywx76Osleoey9pIQNb5pofKs1Xro5AIygK14IvAb2o7cv2mSGmX GtQSJ2cjqSWeT7ktSiD6sztsTFVCY2Vvy1AnVbmHcG3BpgEONuDB5ZoU32z+hcis5hmkxWp3W/G y5+TK+g== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a05:690c:fce:b0:609:e1f:5a42 with SMTP id dg14-20020a05690c0fce00b006090e1f5a42mr640571ywb.2.1709341222105; Fri, 01 Mar 2024 17:00:22 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:48 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-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: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 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 Content-Type: text/plain; charset="UTF-8" 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 b39189182608..dd8fd06940e6 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -493,13 +493,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.""" -- 2.44.0.278.ge034bb2e1d-goog