From nobody Thu Nov 28 22:40:21 2024 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 3651115C13B for ; Thu, 26 Sep 2024 17:36:09 +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=1727372170; cv=none; b=W39exCPy0uUuzm790uCjSWaOa9juXpN38p7DWKbiF3qW2gdzO/j+6l9UMyJPdgIdnA9s4QVgO68EVN0nM8Icmx3yqi1JyxZvcHSUZWDcSorojwX884tSzzkbYz47i0KGOe0iYmNjOm3/6DgH7IIyWEfKvGiy2yRNFc5YuJFoOmc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372170; c=relaxed/simple; bh=WC+iMj4Hkcm+FHxpM7x5FobAfj0CrGRSr9tKhj1zeMY=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=DXrIwpu3KF0AqQUJkc3cTYasbOOmdWlEJlPOqsUhbgaLTnEjzeQYy0h1rQ2Iw3JWRlJphj9aeXuSbtQBAo2q8S5JTthSM2vXCra3U2r3ge2+OytDKcj3UyNT0tg7JArZW4uOnPHk3JBZ0mV1WF9NcJ8CRuoEllvJgwgIVeRlP1w= 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=qI8TwucJ; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qI8TwucJ" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e0b3d35ccfbso1717301276.3 for ; Thu, 26 Sep 2024 10:36:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727372168; x=1727976968; 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=8TDAxfBNX/3AJTgXvbASWXJd3dX0Wd/7tQQ/sW4xuxc=; b=qI8TwucJyt5MJ6Y2nnWHchLcFYhQSkWBO+f09fSstnyUrz7NPm4aKWGCUjlpN/muv+ kdPVjQkGk44zCeIFMs4ctUoTUenauXQ4qieT+k9heJxVaB9kEC+IkMLT6EjD0zYG9UGg r3lYT01M7wyh3kTrd9gtebF+LNN4S/q5f/B6eB77XrTxAkExeGuas6OvSFxNypiU6vj6 YJybWhOP6YJhuqhcnH/ppbl04WyTr7Af/Ik28Ntv051jRiLYxj9orR4sYzagQD/JMgKN spvAFIkjL1GuWe2h6Hk/E3hRghVStXbqBVwL9y3pmcqHs+FOd/sHG2w2uULwuLYStiCG uIUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727372168; x=1727976968; 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=8TDAxfBNX/3AJTgXvbASWXJd3dX0Wd/7tQQ/sW4xuxc=; b=s7SOlHbTe95nP+zL1TQkm+0qVQOCaSDwPCHENIynWYyD6WtghoHMcBp5F4SmJyUgaa BnVTjPNL4i6fW+kcNDbvbCXTT/0bLntEqNUkXz++He0KcMHlkZgfrG5ixybMmh10Rpso rFbWDQmn7nMNR2g1sck7VyxZLX1L6l/mOdMNeGdB4/62TXlX1tXjCXfj7Dj9VO2j20BO Ujoh7RtRMS8DW/nyYJksZiPU3codIZ3hZzfIh6289M94MHE9akAJNEMQVA7Iwc+rjwvt w51cjE9faBue11GkNlM/ntGrCFYxhn7T7bLlO8inqV9YXiMvpE+2+UELMs+QLBnXq8Xl tJPQ== X-Forwarded-Encrypted: i=1; AJvYcCV9Ejfau2ukhTWsxVxC5irLVzz9j7pbIpdjVuySbSKN6IhB28p12jUL4iYp3CTGNm3YV9FRkUQQK5FYAVc=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/caDoP9FPKhElKBnOiR+cll3wj30otMxlbWMpfUfgmPiFh9kL PENIJ/5TNNDFqG6AklMZKPJoO3OrUatYTBRwQCBM18htaNY8hT7v3BngBmI9c6HNM4ay5rdtPD7 Gq16nMQ== X-Google-Smtp-Source: AGHT+IEEfgHm7cEL7JcDDsu1j/kP71CYUXSYaOtcfIXql4xfJGN8vDdY6YrZOdooF0ZlCwQi3Yhzeyqwd07X X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8872:3585:18ed:a056]) (user=irogers job=sendgmr) by 2002:a5b:b4f:0:b0:e22:5fcb:5e22 with SMTP id 3f1490d57ef6-e2604b28574mr160276.3.1727372168155; Thu, 26 Sep 2024 10:36:08 -0700 (PDT) Date: Thu, 26 Sep 2024 10:35:43 -0700 In-Reply-To: <20240926173554.404411-1-irogers@google.com> Message-Id: <20240926173554.404411-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240926173554.404411-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v4 01/12] perf jevents: Allow multiple metricgroups.json files From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Jing Zhang , Sandipan Das , Benjamin Gray , Xu Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allow multiple metricgroups.json files by handling any file ending with metricgroups.json as a metricgroups file. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/jevents.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jeven= ts.py index bb0a5d92df4a..8d2cecb87e88 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -612,7 +612,7 @@ def preprocess_one_file(parents: Sequence[str], item: o= s.DirEntry) -> None: if not item.is_file() or not item.name.endswith('.json'): return =20 - if item.name =3D=3D 'metricgroups.json': + if item.name.endswith('metricgroups.json'): metricgroup_descriptions =3D json.load(open(item.path)) for mgroup in metricgroup_descriptions: assert len(mgroup) > 1, parents @@ -665,7 +665,7 @@ def process_one_file(parents: Sequence[str], item: os.D= irEntry) -> None: =20 # Ignore other directories. If the file name does not have a .json # extension, ignore it. It could be a readme.txt for instance. - if not item.is_file() or not item.name.endswith('.json') or item.name = =3D=3D 'metricgroups.json': + if not item.is_file() or not item.name.endswith('.json') or item.name.en= dswith('metricgroups.json'): return =20 add_events_table_entries(item, get_topic(item.name)) --=20 2.46.1.824.gd892dcdcdd-goog From nobody Thu Nov 28 22:40:21 2024 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 F1B7E156665 for ; Thu, 26 Sep 2024 17:36:11 +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=1727372173; cv=none; b=Bkjv3ggByDoKFJzIHaenUjbClIw75Ba/zomCVjSLkg+kmcg8qQslTUQHFcGVIA5Uj5QkspsYAEr0BSnteVDHGObjQzvRDT/wzThtSDuRURDe8evpAUsAyLqWEU0JcmbaLysLRHtbwekvvSv0rrrAg1gMvUgUiPfjf5tHxJZlwnk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372173; c=relaxed/simple; bh=Ix3OFhfdr4sDNf1twgqYwbUt/vWWkfx//TF5rxOehQw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=OZ9gGTavqfLOdVIJrGct0EmPmXAzk5Kasva66ySkA0Bap+S+CvSGdoihw3r8yqU/20TZOj78aQxG5ADFpXI9sTNGDcEhICzIRuqIyxOR4KjZNHq3xzUGFOYxtkUQ7Flt+hHdah1ub+mOdm1V2eSDTu5WtP00ZWwvCEIUG0oYAL4= 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=h5L1ubrQ; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="h5L1ubrQ" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e035949cc4eso1915779276.1 for ; Thu, 26 Sep 2024 10:36:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727372171; x=1727976971; 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=BXw26LoZtjF4490TVkyxEfHo6L+w0tQShMM1GlIzvwo=; b=h5L1ubrQzWaBHNuNkLEnAMpkRbeWgCeLVeaIUpoFo++K4sf+0iVmrnIh6OunVkTV9o u7sz4rsg3naToCKxvdSyfUZxjW4vKnDMGh/RLaSIDLKRpUvNqb62gnLWa/difItAzCIL sIPxbh5fPPGcxjjUCx3szdTgofOMHQ99GN4o6sMhmwAFU/1nRLeo00bsDdHUc0mtmn38 MBaLViNvc8zeZTczCfWN5YVkkfwc3hQSOCu2TKKWuaH63mRntCksTtF3RCPf63w1xYgU 0ktFGox472giYLkl3yNvKWtGW0CSSn4mIa2rTj1MpC5aFh8bxnlRMgI1DHHrcQ4xUDVE nMeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727372171; x=1727976971; 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=BXw26LoZtjF4490TVkyxEfHo6L+w0tQShMM1GlIzvwo=; b=EeuKQHz9Fc745wjkkrPy5rmTM2PTux+e3QF1LsJ5MyuCZQs7Zay6MLSxnO0llP2eFt 7nbASdQpCKW0OJBW9Wgx6zONgI22nl5T9WZnjP9Rt3hsAu6Q+zci2QrR/woxUHQc9EQO vaPXp4xuwYljE0HRXvFYp4Md+hzArwyV4PELLR1VfP2Hn+iTovJTHPvZq2egrMcy2UBU pCEiSMoKHWt/AU8FMjN0ioyx9/IyvIYa4+daAiWjmfbHJ5xJparpzxT17pa8DYoPez6r Ocgfpq+UZwoqRXdtBm1a7zshE62d3dwXGOBu9pSpHrefDphEIHEQ6bfaIbZVJ9+u60Nh Ymww== X-Forwarded-Encrypted: i=1; AJvYcCVP4nykwdvjm+K9h7HPkcTwXdQblHb/WuebeBdO6zwXg2Cie4JurNmbMrljyIsk+rPcw6miLL7++JQGiHk=@vger.kernel.org X-Gm-Message-State: AOJu0YyiUrOUnt6P9bpYI9neAoxf1EpSOXl8Cb50cAdz9J8zZJtJLkaO 24V3Gf6ZAz7fmHGaCq2QCRwZXGKH2M88qKAXxsfOcpBs6QPIMCkf7wSplGLF6xg8yhLlDKz7dHq L5DuFzw== X-Google-Smtp-Source: AGHT+IHB8Y0pFHinkxYRhJPZyfPi+ipY1+wne0gkGK2mqD4nHa0eKNeL6IF+NYjzlB9rzqUqXVIq1djWU2cw X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8872:3585:18ed:a056]) (user=irogers job=sendgmr) by 2002:a25:d6c1:0:b0:e16:51f9:59da with SMTP id 3f1490d57ef6-e2604b79520mr172276.6.1727372170691; Thu, 26 Sep 2024 10:36:10 -0700 (PDT) Date: Thu, 26 Sep 2024 10:35:44 -0700 In-Reply-To: <20240926173554.404411-1-irogers@google.com> Message-Id: <20240926173554.404411-3-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240926173554.404411-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v4 02/12] perf jevents: Update metric constraint support From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Jing Zhang , Sandipan Das , Benjamin Gray , Xu Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Previous metric constraints were binary, either none or don't group when the NMI watchdog is present. Update to match the definitions in 'enum metric_event_groups' in pmu-events.h. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric= .py index 92acd89ed97a..8a718dd4b1fe 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -4,8 +4,14 @@ import ast import decimal import json import re +from enum import Enum from typing import Dict, List, Optional, Set, Tuple, Union =20 +class MetricConstraint(Enum): + GROUPED_EVENTS =3D 0 + NO_GROUP_EVENTS =3D 1 + NO_GROUP_EVENTS_NMI =3D 2 + NO_GROUP_EVENTS_SMT =3D 3 =20 class Expression: """Abstract base class of elements in a metric expression.""" @@ -423,14 +429,14 @@ class Metric: groups: Set[str] expr: Expression scale_unit: str - constraint: bool + constraint: MetricConstraint =20 def __init__(self, name: str, description: str, expr: Expression, scale_unit: str, - constraint: bool =3D False): + constraint: MetricConstraint =3D MetricConstraint.GROUPED_E= VENTS): self.name =3D name self.description =3D description self.expr =3D expr.Simplify() @@ -464,8 +470,8 @@ class Metric: 'MetricExpr': self.expr.ToPerfJson(), 'ScaleUnit': self.scale_unit } - if self.constraint: - result['MetricConstraint'] =3D 'NO_NMI_WATCHDOG' + if self.constraint !=3D MetricConstraint.GROUPED_EVENTS: + result['MetricConstraint'] =3D self.constraint.name =20 return result =20 --=20 2.46.1.824.gd892dcdcdd-goog From nobody Thu Nov 28 22:40:21 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 729EA165EFB for ; Thu, 26 Sep 2024 17:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372177; cv=none; b=X5oSRZJh6QReFmRaSgUN1ju46KEbfvxp98n4kITMw0IqEcpYpt8bEPsf84uVChR/jixE6B0co+cCr0HGHY+9P71ehjjmMxqEaREEXTFbn1jl+jBDHK7O1cbLiR0UgmY4D/60RxD1bvNNoCCV1IB6pa7GzLyQk8O8U70uTXDYM+8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372177; c=relaxed/simple; bh=eHwzA5MH9IBoaTTv+LG1bQW6beIMXCSj2nnjaeYUe+M=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=EJqwXXqnQ7qhyYB3bOMmasTWqy4b6wfeJu3+jxjK1yQNlsJ8aOeLuWgw34+2Pi9LTUPw4mMbgvg+lSdBiDKahU6RbrGgBzvKchVqEmr5I9FjNafKNMMOTojacxKz1v71xVEMVMFNcknj2HtTf/Sp4/VhAFp/KqqNXYZKB0maUOw= 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=qE+qxTAf; arc=none smtp.client-ip=209.85.128.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="qE+qxTAf" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6d4bd76f5a8so24370787b3.0 for ; Thu, 26 Sep 2024 10:36:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727372173; x=1727976973; 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=WWFP43NYs/kH9GrC3hN9+SHb163yh6Hop52j6JI/aqA=; b=qE+qxTAfv13cVsc3H9C3oQyTvp0KxzBzDl2dDOZRCpnFG4WB9F+HmgHlP/oPgD3SPj zdIbJNG9KjKSHEyARxBCPAUmHsqDrqMu9QSYiNNQcGBZo5Y5pt+zwgT/2pevvh+kDyxg UXEj/pc0JQSP6hrtBAN+Q3+XXj+lzE+CnPPpob3l9xujDl5V95+8vPGYuGXdEtPXIzEs a95084MOf4icnbk0ckjG/QfVwmIretUrKWH8QjSQDGqk9Q4792mcYVQn8VztDbDX14HO pau6fCR25YImUNcxzKO4n9MF1yYBSkzhCABRu/j2/hMMN4on82z76PKLEe6oYxoA1+kL Jzdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727372173; x=1727976973; 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=WWFP43NYs/kH9GrC3hN9+SHb163yh6Hop52j6JI/aqA=; b=UZ27eJfaT+dAvprUYO6at9FJ4w4nX29KUfgmBEbwjG2Vv9yQZx/k5znA/n7t5jTqmQ qFZd8RuIRB7jGW1daB6xHJ1cRp9P8wDezsZ7XYtBnnd0R/umpSySMjNZe65u4r5fUCHu 9JLNXrCYtXDCudG6y/H4ZVDysJ8G+qz1TNkDFa4hw2dTaS4V+Gztt3yiyL9MGwXVb8ZA egbEhLV5kjiAu1uj3VV7P4u21QfE+X+YKI/+XiD6tURzFk6opWQCnot6x20Lp5jcCm28 vEJiju/t4ueoWxZXC4NVNj10UAwapLUm499iLwm9zmIFQ/e9S+Jbs9JVUJPMv1mWmBUP FmMg== X-Forwarded-Encrypted: i=1; AJvYcCWinDqfrOLjWhLNNS2ytpoH4MTQaBOWuKZA1l2eV8wxtZiV10XomWyYpd9CpF3lcq3GXkHz1DeOfy3niBA=@vger.kernel.org X-Gm-Message-State: AOJu0YxlRkSt+Yvb1Ol8hKd0xfy2DKc2y2aza8jGxo4Oy/xkfe6mVkIK jBHQngF6QOxCcU8K9HA7gO5rADdVOcUY2e3HJCwuRKL63XPM5+H1qr/oePNcJEvhV2C07TiAizX MzMttdw== X-Google-Smtp-Source: AGHT+IGaWYXnORF5dJR+cgf78DHcNovDJSUuCpedznZbnze2G9M/UGqAPYyC12mYh2UOcwlpHVa0iwNORqVz X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8872:3585:18ed:a056]) (user=irogers job=sendgmr) by 2002:a05:690c:2011:b0:6e2:3e17:1838 with SMTP id 00721157ae682-6e247518b3emr9337b3.1.1727372173427; Thu, 26 Sep 2024 10:36:13 -0700 (PDT) Date: Thu, 26 Sep 2024 10:35:45 -0700 In-Reply-To: <20240926173554.404411-1-irogers@google.com> Message-Id: <20240926173554.404411-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: <20240926173554.404411-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v4 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 , Kan Liang , John Garry , Jing Zhang , Sandipan Das , Benjamin Gray , Xu Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable 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: =20 return result =20 + def ToMetricGroupDescriptions(self, root: bool =3D True) -> Dict[str, st= r]: + return {} =20 class _MetricJsonEncoder(json.JSONEncoder): """Special handling for Metric objects.""" @@ -493,10 +495,12 @@ class MetricGroup: which can facilitate arrangements similar to trees. """ =20 - 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] =3D None): self.name =3D name self.metric_list =3D metric_list + self.description =3D description for metric in metric_list: metric.AddToMetricGroup(self) =20 @@ -516,6 +520,12 @@ class MetricGroup: def ToPerfJson(self) -> str: return json.dumps(sorted(self.Flatten()), indent=3D2, cls=3D_MetricJso= nEncoder) =20 + def ToMetricGroupDescriptions(self, root: bool =3D True) -> Dict[str, st= r]: + result =3D {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() =20 --=20 2.46.1.824.gd892dcdcdd-goog From nobody Thu Nov 28 22:40:21 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 C0494156665 for ; Thu, 26 Sep 2024 17:36:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372178; cv=none; b=pkeBZBhAE290rx9c1MY43a4MmXYgg5gXu0D7rjmUCnKY9l6xJPRU4slM/RNUL+45Yz+R2KIUXjTU0R9Qw0hmUXwFrmVFNKDHLafqdtzKoWjG/jPGynwgrnpASFvcePTF2Wm3bgR0OE5B+5rfbsoFCcStEiFzkEMTYgmUVNBcMuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372178; c=relaxed/simple; bh=M99U/TsRjoC4o8Ub8ccQQEiFuk+6w4FbHCS5wDw6B/M=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=EG0A4Ol2mrLVLRfCX1LssN0LV0QgrwxhKIBwtk9JWWAD8It1IWQr3P1nOmj3r5RA18vnxINeUv32Jnm4d5qiMpdfhWchFhcBnUwds/O9msyMAihgAv/Mlv2OJwEd+LGRKAZ6WTWrwwGGHzrNrqlAo6Wz1wR2D6SsotbOTPEcDTM= 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=2ZNDeVfJ; arc=none smtp.client-ip=209.85.128.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="2ZNDeVfJ" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e1fbe2a6b1so26070757b3.2 for ; Thu, 26 Sep 2024 10:36:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727372176; x=1727976976; 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=6d/FOySDNNTFXzgASGTIFb5rx5kn+XWz56YenJ+UerU=; b=2ZNDeVfJf6jPZjfrBnWqehNI/lWI0cS8ilVgYaEWrILsTZAgdTtQuqRg0w24qPssp2 WLB5eSrmacpOpaLvAti7ZjUirwRDKkpB4fK7S68kuYOmMKehPXH1hyL2adtup81W4/wT 25bOCBUmrZghk7XfXMgptgTxoev0lQiHy1JRABr0m1+H++i1QjuFtxztTRBOYgC4CHq9 M3rTafEFKbPcn0gjupsj7BdrTa9jzuFpR9k0ji2BtK0CWDtZl6D8swdpcifva0PtEiVt Kcv1+/4SNPpObVlQ5OgIOy79MnJjfy4TY0VSx1vrw631EpVtmKuRxmkSiY4qbTyntkzR I93Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727372176; x=1727976976; 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=6d/FOySDNNTFXzgASGTIFb5rx5kn+XWz56YenJ+UerU=; b=fsc/AFWvoX6riIKm3EkSaE2uhQPYhHe9ZMg+8VQJOXBRVRj9IRUJH6Ut+9KAbaVD9n Q8ra+y9UHxOkrR9ko/UvWTgF9h39Xhvj94UJGzKBFR63DvQ/8KjT7r2SN2aQUfmoCIb/ B0WU5VqJS4Lp8MUqr/VK5wvhJD+91KeJ6uQIoC4jUCmG6mCIepZev4PqfXXEi00XDqA1 vHuXCXiclmKBDefnBUuOgvAvU5474vezObmTmgt3V7dBSvnM0ZNqKEHmyQx9fu0Z8Jz0 m16TJC8z0I6OXZHd4lpDE5O9iayPfVYfVBm/nW4AyNPBPkN+jUUXeUqq0dis+1sRDhRY RIfg== X-Forwarded-Encrypted: i=1; AJvYcCXC8wN3XVI2UqDV3Nq8Pipza5iEKtD4ADm0mfsTd1BFKi35kkHUndajIFqTiFxGS2Vl+lEo7JsyAGbNIEY=@vger.kernel.org X-Gm-Message-State: AOJu0Yz0rALxcp3LQGf701D9iThrqwKiB9SNlfuJL+SWdE23Qb4BLW14 DzCUwRwD0t8jhWadmk10qgRo3nCM4c3fF2P9QakNkaiX0oEzLr6FtL2/B6cfDnVJnykmnE780wA 1fvv6XQ== X-Google-Smtp-Source: AGHT+IFy5j6b6E61WtCzGHx6ximLIJ6qOIMeGqheO8aFHvdx/oRvCBkswdXue/hoIdyiuvY7LgQbTZtvj2Tt X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8872:3585:18ed:a056]) (user=irogers job=sendgmr) by 2002:a81:e346:0:b0:6dd:bcce:7cd4 with SMTP id 00721157ae682-6e24751a289mr10547b3.2.1727372175765; Thu, 26 Sep 2024 10:36:15 -0700 (PDT) Date: Thu, 26 Sep 2024 10:35:46 -0700 In-Reply-To: <20240926173554.404411-1-irogers@google.com> Message-Id: <20240926173554.404411-5-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240926173554.404411-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v4 04/12] perf jevents: Allow metric groups not to be named From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Jing Zhang , Sandipan Das , Benjamin Gray , Xu Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It can be convenient to have unnamed metric groups for the sake of organizing other metrics and metric groups. An unspecified name shouldn't contribute to the MetricGroup json value, so don't record it. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric= .py index 1de4fb72c75e..847b614d40d5 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -455,7 +455,8 @@ class Metric: =20 def AddToMetricGroup(self, group): """Callback used when being added to a MetricGroup.""" - self.groups.add(group.name) + if group.name: + self.groups.add(group.name) =20 def Flatten(self) -> Set['Metric']: """Return a leaf metric.""" --=20 2.46.1.824.gd892dcdcdd-goog From nobody Thu Nov 28 22:40:21 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 33014170A12 for ; Thu, 26 Sep 2024 17:36:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372180; cv=none; b=OCtDFvNRkUnuePPtjixrdEb69eMikKnXmISCwZGB6Inu2flrDenWB0hnnoJhUhyVbNFOOs2GtvN5On74fmmM0q+Kc2GsWv+Arc+INtcw/xpijq6ckYq4UGeK91y3fPaCUMLwXNUtKNCWTrde3OW+XzTwlnIpNPDnya7HRn/PUjQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372180; c=relaxed/simple; bh=Ic2gzA/bbOWr8+GudHHWFur7h6xRAQmb3Pn9q49UzKw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=CGISZJPmOpZL3wghQcqjghGSssNRwq6fsowoJscAYGDNV9mjKQ1h+tosOfZ9N4hjP/mhpH9ctnvldLjtGM5VHdFeSHcNr48fVjXudxVlUHY6BEShHgbP5Vz4gW/12YtZeRSVfyIEXPk+KaVO0pRDjlcxiQG8arfMYa0sYyvj1TA= 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=cyKTtAIW; arc=none smtp.client-ip=209.85.128.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cyKTtAIW" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e230808464so23652427b3.3 for ; Thu, 26 Sep 2024 10:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727372178; x=1727976978; 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=h0HaGZwNUfFDFp9ShWHIUFE2GLz8humaPEHhJilF6vs=; b=cyKTtAIWUK3sP7j6wiQm7PdWlRoMKwwi+qqP88Lb/cM/jv1ISOj5+umuecZEyoyXG2 eRof0wEbFTjsh4c8W0lDLIfMyLWHNDguN1q5OPoSyI85s5ZGD3T92fB7J44fQJwy6574 f+bARq9Ai/lnbbO9JkNfqCoH7AJ+/YJrEM9jH1zS//nFGe6m3wgLYMmMNWTJwo55jGdg HDkDEqtPhN2R/+myW5GuNc89haU45rU7lsrdyLIZLAVQ3jQsKRs4t92CZyzJZoxCrsZS WdlxyTyGfq6ZJV/SZcC2BiRW1rLnzs8UbYnDI7i/2PeSR2knLzTDrYp3exXkDAeIhMlC MHag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727372178; x=1727976978; 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=h0HaGZwNUfFDFp9ShWHIUFE2GLz8humaPEHhJilF6vs=; b=lAzfyjbjAMNw0W+9W1QdfsR54kqb9CnE646/QNj7tyQDCazabv4E8l1m6wvq9BZ7TA 93PTawZdY4Nz0kMDpsyttRpQC7rA6gsEjgtOEBo+0pteYcjrf9yqS8yLs37egEAWu8rz vZP7lcTyTit5zI8YlNa2h0wXgJZ5ERxTHAm4YW3qRi6HAIeLgh6U0kkwvvUvSw3teJjr 1Vx9x4Z5HmlX9ggflaQ+MY3f82L0n5xzLWZG9FXZfd5WkQabnXSfsZRu4KQ70BSYYp14 EXweeIwuRYHYmk+QNhybo1vn1RGscwOKAj2JKh6OaSecEdtINQ7WpKTkrO3CVH6i+uty xDIw== X-Forwarded-Encrypted: i=1; AJvYcCW8e56mGeCXj3ETGqST9ZwDI5DuGKOAiRHaCvNrJ/Jl0ZVcrwwltA0CwS50jkACFxg98DatKdmyaeGQsfY=@vger.kernel.org X-Gm-Message-State: AOJu0YyMGu9eV0KNekc0Hdw6oJy3ML117AzEmgwkhftvbrkGQZUw27QA /BLnuUWy3MnJQmNFzr6FKE/ibDJOnrQJRpeGzziTm57ElJeUpLbWnMZ5o1vtU5vkzeMnviV3mVQ ozyB/fQ== X-Google-Smtp-Source: AGHT+IExVWVCVrF+zkRsj+feFu2ow2iY7yX8CH096Gn48W9MKPFI96XHvR0wTsbPJJisdUdY5Mudg03gPhPA X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8872:3585:18ed:a056]) (user=irogers job=sendgmr) by 2002:a05:690c:dd4:b0:6db:e228:2e40 with SMTP id 00721157ae682-6e247604e7emr5997b3.8.1727372178311; Thu, 26 Sep 2024 10:36:18 -0700 (PDT) Date: Thu, 26 Sep 2024 10:35:47 -0700 In-Reply-To: <20240926173554.404411-1-irogers@google.com> Message-Id: <20240926173554.404411-6-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240926173554.404411-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v4 05/12] perf jevents: Support parsing negative exponents From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Jing Zhang , Sandipan Das , Benjamin Gray , Xu Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Support negative exponents when parsing from a json metric string by making the numbers after the 'e' optional in the 'Event' insertion fix up. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 2 +- tools/perf/pmu-events/metric_test.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric= .py index 847b614d40d5..31eea2f45152 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -573,7 +573,7 @@ def ParsePerfJson(orig: str) -> Expression: # a double by the Bison parser py =3D re.sub(r'0Event\(r"[xX]([0-9a-fA-F]*)"\)', r'Event("0x\1")', py) # Convert accidentally converted scientific notation constants back - py =3D re.sub(r'([0-9]+)Event\(r"(e[0-9]+)"\)', r'\1\2', py) + py =3D re.sub(r'([0-9]+)Event\(r"(e[0-9]*)"\)', r'\1\2', py) # Convert all the known keywords back from events to just the keyword keywords =3D ['if', 'else', 'min', 'max', 'd_ratio', 'source_count', 'ha= s_event', 'strcmp_cpuid_str'] for kw in keywords: diff --git a/tools/perf/pmu-events/metric_test.py b/tools/perf/pmu-events/m= etric_test.py index ee22ff43ddd7..8acfe4652b55 100755 --- a/tools/perf/pmu-events/metric_test.py +++ b/tools/perf/pmu-events/metric_test.py @@ -61,6 +61,10 @@ class TestMetricExpressions(unittest.TestCase): after =3D before self.assertEqual(ParsePerfJson(before).ToPerfJson(), after) =20 + before =3D r'a + 3e-12 + b' + after =3D before + self.assertEqual(ParsePerfJson(before).ToPerfJson(), after) + def test_IfElseTests(self): # if-else needs rewriting to Select and back. before =3D r'Event1 if #smt_on else Event2' --=20 2.46.1.824.gd892dcdcdd-goog From nobody Thu Nov 28 22:40:21 2024 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 D0C43176FD3 for ; Thu, 26 Sep 2024 17:36:21 +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=1727372183; cv=none; b=Ij1IT7j+ttxfrIxp6UJHBkxCkuw8U6IKU2ekLUFUcqCd00hQ2qzmO/IK2CkYMQptcziu74O1GUmiYin5H9KIX0peuZJaBhQWajOvzshX9AJA6jCq7ThOAbPKfZVzvYOfCqKWH85LZvMdYxx6hb60NADBuiVmp69smSi3wdjVCAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372183; c=relaxed/simple; bh=6wYQLnce4vlSDrSCmK7EkBM7P0b6NutgsCaHsuj/wc0=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=MsWZf30zGcN4ihWxbMWsjtvZkNQXQ7HZU3vEntNDBCraq9slRCuxIZnTeg4MJfQGUglH75kGWNo4TTyq5WcLRm5OqFFeQDYsXVS0eyRMiEIBf0q13wUGIKLrVWTG56y2XO0Ayk9pVG2fTDGhdLqRgP0m5QhM56QtfKkjqnUeRZs= 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=g0LTPjhA; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="g0LTPjhA" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e0b3d35ccfbso1717574276.3 for ; Thu, 26 Sep 2024 10:36:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727372181; x=1727976981; 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=H9lmVPIwGAJgbZqGwUepqlVg7PwPudVkm3v4N6Eoo8Q=; b=g0LTPjhAO1VKAmyQLxvFDOOPcelFwVzDBwPbN3lHf3AEeQecf3u8mI0toSU4XGDF5B r+Y8/sUCvSPSht6a8/9FsmMJknQo5UTkrYeXqcj1Gh6bFX/NxnkfJbFtXKsBjg5Uh5tV 3h8LF0bpQF97+BmwPgtB+dV6gjBB6ypAdJFALJDCNS7slzgemQmA4Cpcy70C4uxJRMiO b1bSkGBAR3VG46G8F3aO+R8+e7DNoA2+Fnx2yUc0T4BNA5kuPCv+rarnZlu3CoHVLHum +0A8k++j8XU3U6DA0tZDxrmILIe4EpBcdfBiKHECxUNCT3Ih+JzGarmiJQmQttPEbMJ5 QDCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727372181; x=1727976981; 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=H9lmVPIwGAJgbZqGwUepqlVg7PwPudVkm3v4N6Eoo8Q=; b=wlP1KWCbZzEy9/X0WRe1H2HTnq5xSB3yrniqK/X73Mi7puAa6UH+evNhdoU3IkOJob F5qxK4XDb/AX+Mym/LBHXZWFUtWuuSTmTpm5xv3I57daDbc0s3pdN3hKIIUG5FYg1tPA HWTE9M5fi3AwuS2AvhcHHlXEmnsTQL5vbqtyYowZpaqdA0SKwI3XGI9mRIWuxoGxBJpn RbEh8jggzB35pyi7QHKv/QSDMAsFABJU7Zo0FQ0zySSeuYoVkk0571MO6UjWxRXfOddD YC2NPcMQPxf2VRbmOzOujbWqIbunRj3LVWxzKmGpatKLAMOiiq3rH/J4IqurPUpmJOeJ +FFw== X-Forwarded-Encrypted: i=1; AJvYcCXWEyK/nly0SzbEaTBO0/2MXHWzIi3/CT//z9TA/p7bETHTKlH/C7BvYvxz1cBRT81lw7hcklXw85c0fso=@vger.kernel.org X-Gm-Message-State: AOJu0YxM4wcU1tZpKLO5auVfTUOBd+prvrj350MG06PSH8wKXlZYlUDi 1XOXZ7l8YRp4rYYPqNpBsX1yBfbzw0TE6cBTgpKy9jmFMMYMb6kVo5ybU9YpqJ6s3Zf6cO6xOvc H7xUaVQ== X-Google-Smtp-Source: AGHT+IE9EeWE6+0RW1hIqycPqZaqeDYi4shJTqvgSeMl0wmZe2+VVEUC52Ho0fKT4gPggEdM9QYHPYHQfjRX X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8872:3585:18ed:a056]) (user=irogers job=sendgmr) by 2002:a05:6902:1343:b0:e25:17cb:352e with SMTP id 3f1490d57ef6-e2604b7f6b9mr121276.9.1727372180804; Thu, 26 Sep 2024 10:36:20 -0700 (PDT) Date: Thu, 26 Sep 2024 10:35:48 -0700 In-Reply-To: <20240926173554.404411-1-irogers@google.com> Message-Id: <20240926173554.404411-7-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240926173554.404411-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v4 06/12] perf jevents: Term list fix in event parsing From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Jing Zhang , Sandipan Das , Benjamin Gray , Xu Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Fix events seemingly broken apart at a comma. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric= .py index 31eea2f45152..0f4e67e5cfea 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -568,6 +568,12 @@ def ParsePerfJson(orig: str) -> Expression: r'Event(r"\1")', py) # If it started with a # it should have been a literal, rather than an e= vent name py =3D re.sub(r'#Event\(r"([^"]*)"\)', r'Literal("#\1")', py) + # Fix events wrongly broken at a ',' + while True: + prev_py =3D py + py =3D re.sub(r'Event\(r"([^"]*)"\),Event\(r"([^"]*)"\)', r'Event(r"\1= ,\2")', py) + if py =3D=3D prev_py: + break # Convert accidentally converted hex constants ("0Event(r"xDEADBEEF)"") = back to a constant, # but keep it wrapped in Event(), otherwise Python drops the 0x prefix a= nd it gets interpreted as # a double by the Bison parser @@ -586,7 +592,6 @@ def ParsePerfJson(orig: str) -> Expression: parsed =3D ast.fix_missing_locations(parsed) return _Constify(eval(compile(parsed, orig, 'eval'))) =20 - def RewriteMetricsInTermsOfOthers(metrics: List[Tuple[str, str, Expression= ]] )-> Dict[Tuple[str, str], Expression]: """Shorten metrics by rewriting in terms of others. --=20 2.46.1.824.gd892dcdcdd-goog From nobody Thu Nov 28 22:40:21 2024 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 7652417C9B3 for ; Thu, 26 Sep 2024 17:36:24 +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=1727372187; cv=none; b=CN8ESv+g/HbyCpQstIJy1XOSMyeVgPizWFdBSfHg3vquhIyVGokvscZ4ORdVihbDlgIxg2BmYVASW7dC70OeZQyTduOCNuy04SYw7M82sKRTSScN5sq9Nh9snPjd8PFT8bNOGeI+lgq4G8du1xRgOQQcCzF0Vg18AdqcXMGcLcM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372187; c=relaxed/simple; bh=j27L+GXsZRPzyM6oYjhYvobTFCzvOew+QVZrvE5Qf/w=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=IEgKbF0b3iAxqcHiAGxJJGy4M7IstE0KAw4Wn1RlFDX7ywLhty+YH4OHuRNEa7DaI2LSuJLGXpiWXZ2SNLsupTRxKYN5Cs18Uh58/dMufdnS4eY6vI/fRXcKdWrLP7IMXYFOueXRKyABt2ggqFCJkRBpWemOKArhF3ePxzGSXLg= 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=WwTaSzPC; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WwTaSzPC" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e0b8fa94718so1990609276.0 for ; Thu, 26 Sep 2024 10:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727372183; x=1727976983; 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=khk7+EiEpOodwHgWTt1yX5x0DBXiet2yqtmzphl8YmQ=; b=WwTaSzPCy6hsJN38tXzZ1MuPMPo3BpZ6SIMVAAizB5BpNFSryPDYNcFfDkFE5lBt6w CmlT6A9tbFJwIZuGHnV79GpUYRto9R9w6e4PN1z+b0JkjczA5V9tcdAaRcR6TAhMeU/+ NG0qqTYHqD1Qt9h9mzrfW0urD/6VzILu1oPFyBDs2vyVNRBfGY+D/a3zjvUOCZawXYSK nWV1/6zQPfJJUDTi9xa6eW2P6FjesGsWlriZZvBjTVwkR6Tkis7AddOBtpiqEYiPJUmf hsQyhOu7HwhF7ziLpRc2fZlWKGjoWXP71pSVd/8W3pdCvsPr0nGNXo6Vl1hXBFEwFdeM Dy+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727372183; x=1727976983; 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=khk7+EiEpOodwHgWTt1yX5x0DBXiet2yqtmzphl8YmQ=; b=T1TYfFkKSY3tH0qxatCZnGn1SH/opxRV2qnJ81sdXeJqgi52dJc22KD1G6KeGjdyzH 8tuipTCk5SlgPNQN1Kpd9F3vsRorfIh4AdONX7ueIw/vBevasNZC7gLMQVQfJBNjsE7S laUUjjAK42iUSeGtAMu3Evh4aFF8QsgRQyMy+L6If9rWSOivMT4cQeLhJDdNUSyQzpBS doJVaMTQSYiCqsloO9khe0KLN1i4fhdDD7Fu47ofkVyDqCTUhg1GVumuiscFGJkFCime 1FjYfyazMZylKGS3CqmqW+fffIWMrdRyiP4SZkFgxvstbazc97xjj8WBl85DQT92BUVQ CZrw== X-Forwarded-Encrypted: i=1; AJvYcCUAc4H26wzkEupqGGYi9KIGl311UVdvLhzTiFm6D7ZCt2W3gce+2pJ9VYXlNxY3A5H2key1LaCva+enwqU=@vger.kernel.org X-Gm-Message-State: AOJu0Yw0FdlTe5DrbVaapz2dJEKl1rDwj5WC2Dvk0hgWpk2FmA/yo5fA 6kEjn/IVbPxx2lIVIb7gLxlodWWGA+Efk6Hy5DGIstSaSHhVWnuobyoGoZ9NQT2weG2i770QOu9 nwLBQvA== X-Google-Smtp-Source: AGHT+IGKMpzXcgy3KQv4XDI/gMP78suYWexjnA14h0X+xSwR4o+sg1dvELNMVAsvj+AX4H3FE4TfaRTTuSHX X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8872:3585:18ed:a056]) (user=irogers job=sendgmr) by 2002:a05:6902:b25:b0:e0b:d729:ff8d with SMTP id 3f1490d57ef6-e2604b3de26mr103276.5.1727372183273; Thu, 26 Sep 2024 10:36:23 -0700 (PDT) Date: Thu, 26 Sep 2024 10:35:49 -0700 In-Reply-To: <20240926173554.404411-1-irogers@google.com> Message-Id: <20240926173554.404411-8-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240926173554.404411-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v4 07/12] perf jevents: Add threshold expressions to Metric From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Jing Zhang , Sandipan Das , Benjamin Gray , Xu Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allow threshold expressions for metrics to be generated. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric= .py index 0f4e67e5cfea..e81fed2e29b5 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -430,13 +430,15 @@ class Metric: expr: Expression scale_unit: str constraint: MetricConstraint + threshold: Optional[Expression] =20 def __init__(self, name: str, description: str, expr: Expression, scale_unit: str, - constraint: MetricConstraint =3D MetricConstraint.GROUPED_E= VENTS): + constraint: MetricConstraint =3D MetricConstraint.GROUPED_E= VENTS, + threshold: Optional[Expression] =3D None): self.name =3D name self.description =3D description self.expr =3D expr.Simplify() @@ -447,6 +449,7 @@ class Metric: else: self.scale_unit =3D f'1{scale_unit}' self.constraint =3D constraint + self.threshold =3D threshold self.groups =3D set() =20 def __lt__(self, other): @@ -473,6 +476,8 @@ class Metric: } if self.constraint !=3D MetricConstraint.GROUPED_EVENTS: result['MetricConstraint'] =3D self.constraint.name + if self.threshold: + result['MetricThreshold'] =3D self.threshold.ToPerfJson() =20 return result =20 --=20 2.46.1.824.gd892dcdcdd-goog From nobody Thu Nov 28 22:40:21 2024 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 A9B9615ECDF for ; Thu, 26 Sep 2024 17:36:26 +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=1727372188; cv=none; b=s0HyjqAtxw52WaddeimBUqc7pRyZbbWqqICjVyHxAg1kgr9QzUNADAVx91Vzscm0HIEtfPtntpN08Opk3XId97+Nx/ZhnoK0WMsPWpVy6SwPj5yYYlI25zYwph/ozF9OKCHKZKfxtfl3pztIdry4gqj6zqcripBtv81gf6SC5Kk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372188; c=relaxed/simple; bh=LfTLgfo3KHjH2LunPKqfm7zFwrL+OIEXixJxNNTXPLE=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=FbeUbNyUIfhrppK+jy7jFs9vnET1qlZjbsSM2TYWOEh0wCkl8zQO7QbsbDHY+xDVQht6boJSoMSlR3j4BrnwKyBGhMLTElHMFA2JxSuEQokup+n54CWJ8lHqWyMVyfR3NgUb58xeEWxDAjWHhfwr5fnI/3oLne61y01nXjPNr30= 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=ai0xq0xj; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ai0xq0xj" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6e2146737ccso25825147b3.2 for ; Thu, 26 Sep 2024 10:36:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727372186; x=1727976986; 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=YjawVu6SYilvwlXMo1d1xJkVjPzpefbyO0+sOzkc8XI=; b=ai0xq0xjLFJ5I4QdASfQSXYnU4rujcuAHUOBlW9EC25Y8dgY6d1ISbyzNi7JijRUdJ YFHhl3eMyj2wbPBcdpIYLwNUH3nuUhk3xnL7vP8DmC7KtS0VGPOdJqUyPC4Boj4rygcy zCTBvEHe7jytzJY3huWgaflDEfWTE75PbZvzpF7x8bftSFv3yCFVheUfWZjVmM5e0BYC +Xa/De15hqmpwxENGvI29oO98VWv5rWNgBXCNTcSwqckp3ypuIOPDAjYxvK4iwttOwT/ Q1Fv/Oi/LkEYD3Yd3jagiml7kYlRXuNXn+SH0VmVsj0+TF7BCm5VLVCYPcfgxiupsOr0 BBrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727372186; x=1727976986; 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=YjawVu6SYilvwlXMo1d1xJkVjPzpefbyO0+sOzkc8XI=; b=msBTrREvJAkpaDScjyL3bKNiUDYjgqPy36q5JbgSgyUe5zt7+DQyOXzdZJZi2pW9AR rdQK7GadBf1biRRmyVdHi7674q35ZZknZvzCQdC8sv+qaGs0tT/xcC/r4x+FLzWWSU0f +6/SJp/gazXiClQGMraSrgzZlFTywVQ8aU+DEBfJ8usw8ioPd6BR2+4zaCis224dfBFz 7beQWYkmDU4SuMlItOhfG1WxZxZj0vLBpiSPyia2PMAngYQWTYYs3gWgaHeETNOWF9UL okBsDMiJENuKJzwJr0c7ul23R9TREBnmn22+xKkcxeJgDa66AW4VlWERQKSPhj+ZgI0U YdKA== X-Forwarded-Encrypted: i=1; AJvYcCVHqBfuJKNj41sgO7juIZ2iXMrSqSk09cZ9kEP5pAjS+ERAYC0tmk6IfcAUe/gh+zhLeTSiDBr93iA4Oe8=@vger.kernel.org X-Gm-Message-State: AOJu0YyDdUtIJqAG6iaENhfk/QkztCn1VJJz4G6KP0doXUJOrhDcY0oX tkNGvE8aP9STZylaTlQopyKc2PESHFLDi5YsP6GgD1YnFYfnBn2ccvpuT8j+I4Uk8y1DVlV1729 SVKZl1g== X-Google-Smtp-Source: AGHT+IGcJqvC20L0V+paymemjxK4+5rieH/QOLFJ1PlUVqwDGglKVZ4qbYjF0OvDMX7Q9s6A+nqH8IYFGlZG X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8872:3585:18ed:a056]) (user=irogers job=sendgmr) by 2002:a05:690c:2a8c:b0:6db:d257:b98 with SMTP id 00721157ae682-6e2475a592bmr14757b3.3.1727372185710; Thu, 26 Sep 2024 10:36:25 -0700 (PDT) Date: Thu, 26 Sep 2024 10:35:50 -0700 In-Reply-To: <20240926173554.404411-1-irogers@google.com> Message-Id: <20240926173554.404411-9-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240926173554.404411-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v4 08/12] perf jevents: Move json encoding to its own functions From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Jing Zhang , Sandipan Das , Benjamin Gray , Xu Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Have dedicate encode functions rather than having them embedded in MetricGroup. This is to provide some uniformity in the Metric ToXXX routines. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/metric.py | 34 +++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric= .py index e81fed2e29b5..b39189182608 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -484,15 +484,6 @@ class Metric: def ToMetricGroupDescriptions(self, root: bool =3D True) -> Dict[str, st= r]: return {} =20 -class _MetricJsonEncoder(json.JSONEncoder): - """Special handling for Metric objects.""" - - def default(self, o): - if isinstance(o, Metric): - return o.ToPerfJson() - return json.JSONEncoder.default(self, o) - - class MetricGroup: """A group of metrics. =20 @@ -523,8 +514,11 @@ class MetricGroup: =20 return result =20 - def ToPerfJson(self) -> str: - return json.dumps(sorted(self.Flatten()), indent=3D2, cls=3D_MetricJso= nEncoder) + def ToPerfJson(self) -> List[Dict[str, str]]: + result =3D [] + for x in sorted(self.Flatten()): + result.append(x.ToPerfJson()) + return result =20 def ToMetricGroupDescriptions(self, root: bool =3D True) -> Dict[str, st= r]: result =3D {self.name: self.description} if self.description else {} @@ -533,7 +527,23 @@ class MetricGroup: return result =20 def __str__(self) -> str: - return self.ToPerfJson() + return str(self.ToPerfJson()) + + +def JsonEncodeMetric(x: MetricGroup): + class MetricJsonEncoder(json.JSONEncoder): + """Special handling for Metric objects.""" + + def default(self, o): + if isinstance(o, Metric) or isinstance(o, MetricGroup): + return o.ToPerfJson() + return json.JSONEncoder.default(self, o) + + return json.dumps(x, indent=3D2, cls=3DMetricJsonEncoder) + + +def JsonEncodeMetricGroupDescriptions(x: MetricGroup): + return json.dumps(x.ToMetricGroupDescriptions(), indent=3D2) =20 =20 class _RewriteIfExpToSelect(ast.NodeTransformer): --=20 2.46.1.824.gd892dcdcdd-goog From nobody Thu Nov 28 22:40:21 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.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 2E387181310 for ; Thu, 26 Sep 2024 17:36:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372190; cv=none; b=IndtdCWg6DM3G5fzZVRHxbP/bU+dHzNKxSeOHqyohG0oJxGB6xVDfbgzfLMmMdRJb5EwV+kr/R4AllNjX+B0bfaOuVbSiPhdinQsm+oSfHzUOjdqMhUYeeMX6J2TbsiAMVWpqxoR/yM1tux8HS+jHl7jXbQTdWG1QqdZVJYF6bE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372190; c=relaxed/simple; bh=qbqs/VtYLAHCycbx4vi5LsbINYh1rKMwgZIZNf+A82Y=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=mr4SKww19DgyhCWNpQ4e7Q3UIGSkwNb9t7BSxuD9gN4GBflIbqVpX8PH/27Oluw7no8zulORIj2ZYa3bPJ3xjqoOesU/GHD03523XcGmlNd8fw4i4m2BhUSJfh4DGnuNGjPAQQDjPyt6pUuBpaVeLEaj5hbaxCc03uodnCOFHCw= 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=n+SQBwt0; arc=none smtp.client-ip=209.85.128.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="n+SQBwt0" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6e2261adfdeso12979267b3.2 for ; Thu, 26 Sep 2024 10:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727372188; x=1727976988; 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=e3phwsESgNJAD/gtYgEfjCS2iNNfK4v5IWyCQ1BF22U=; b=n+SQBwt0zg2e2EJmWyRJNGTac6GP3aJQPMK+djbEKTsNEl32w8PUjttE6XB03MB52Z v857Q7sWQZwXMkTFLA7fixRIPnBXrCy8Fh8d8uz0pJyUSRnnTsDzlGyBFlft7ZvNK5iz dVxsEU9O7XAeeNSHluDGtmqz/OVEmwrMWtGssprqGlxk64CYRE6utTL9EbjvaRUe8v5t rwnvBwOnEP4rVmMw+pzs/eDrQ5hQUoyY/w48LVXPawn4mkGLWkHHzY3PkRg/EipGlZvK bndllz9DHbeOLm2L6GrxaiACAwn8adqzn85qAw8semMEW4XqusSVxVGylVU3Kqz147I3 9p4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727372188; x=1727976988; 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=e3phwsESgNJAD/gtYgEfjCS2iNNfK4v5IWyCQ1BF22U=; b=s+CxqE/80o/8Fbgnq6yi2tF2K9keyyTsgOMBpC1krJdfZSE/yfY/dy3w8/f0IB3hRV WDxHw8XcKVxHxX2jOJCPQOyr1jPj2DEtLYCCpZLa4VncpP9o5jvE1rCk1gVXODcS/4Tp DllFsnhEdn9nWGf36lYTDTDmrN7wwn5lrPiv9VLd30iVh25q373X1nZ+C+JuRhsiYw+i gUGrl4C/2TfQa3AlDqNuKW0r66+BR2YdzUISiXKucSLrGk+uOraXLhz6h4QzpWSJBQOa gpC4B+EUo/j9dDvMV+xy/ZiQSfhFyc32qMNAvGM8viAFAIhYCyfcwWCXRFxGxcwxyF+I Jh1g== X-Forwarded-Encrypted: i=1; AJvYcCUg88GNZ1cFg+1Lak02V9/Ve73Vg+3qQah6fez8QIIeIRdVV9MGVitnhDl6DSVu1dpQ+vi5TbsmlwLA8ls=@vger.kernel.org X-Gm-Message-State: AOJu0YwQJRAtoCeuXpQPsEcrnKF/7Fsge3OOWHj9W6tTUMKw7fWP26vO bE9QuFiNbNikHgdTc0sWvq02yttYroPA7YreU/hHnXqC/xbEm97Ng7wxp6EWs9RHZIl9JnCTyDx suW5CWQ== X-Google-Smtp-Source: AGHT+IENGkB1Fu9MiFrm2Rau858bJwo6nKsMX5S+m/q2KN3wYJTLbrV0xtxHf15FckIrJ4ISm7FtJs3Q+xml X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8872:3585:18ed:a056]) (user=irogers job=sendgmr) by 2002:a05:6902:504:b0:e17:8e4f:981a with SMTP id 3f1490d57ef6-e2604c8fd7emr141276.11.1727372188130; Thu, 26 Sep 2024 10:36:28 -0700 (PDT) Date: Thu, 26 Sep 2024 10:35:51 -0700 In-Reply-To: <20240926173554.404411-1-irogers@google.com> Message-Id: <20240926173554.404411-10-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240926173554.404411-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v4 09/12] perf jevents: Drop duplicate pending metrics From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Jing Zhang , Sandipan Das , Benjamin Gray , Xu Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Drop adding a pending metric if there is an existing one. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/jevents.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/pmu-events/jevents.py b/tools/perf/pmu-events/jeven= ts.py index 8d2cecb87e88..7b4239e8b08b 100755 --- a/tools/perf/pmu-events/jevents.py +++ b/tools/perf/pmu-events/jevents.py @@ -473,7 +473,7 @@ def add_events_table_entries(item: os.DirEntry, topic: = str) -> None: for e in read_json_events(item.path, topic): if e.name: _pending_events.append(e) - if e.metric_name: + if e.metric_name and not any(e.metric_name =3D=3D x.metric_name for x = in _pending_metrics): _pending_metrics.append(e) =20 =20 --=20 2.46.1.824.gd892dcdcdd-goog From nobody Thu Nov 28 22:40:21 2024 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 97D7B183CCD for ; Thu, 26 Sep 2024 17:36:31 +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=1727372195; cv=none; b=WAijX3sKOhqzWCqY7H6lQYidcSyiqoQrXiuHk5hPazR4S/TZyvtVzWQGHvb5pjihwEIq+XIQa5WgRpFSK3HHtAbuEWS9PhTZlAapzbVRQAVl3FCxTD1ZilRPrMKes3kDCjG+ltPJI6tnLO86biz7rpfRqeHIHHz5CaMIRzK+psY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372195; c=relaxed/simple; bh=fI23lg2vSD0PJe5j7dtsTs9wlvKu/gvHpzMuGdst40w=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=SQhNjkae+y7Zrpv3BSJOBx47P17iVki0EfbR6LoxQAkROIbVWx/OVV43ihnDGh5R5m919Jnrxcix14Ohg66L0Em4yHGB+TyU+O+5QwskZUtRmcevb1aBF+q4KkZBJCbjAKTpS47dzHza0LEsQwkUoSe+8ZkKtwUdFNVwk+bRH4w= 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=gQEx/nho; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="gQEx/nho" Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-e25d494faa4so719447276.0 for ; Thu, 26 Sep 2024 10:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727372190; x=1727976990; 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=a6UDuHGKMWgBm1lEl1cmmS7v6p/aZimzfV7mPrGbWXw=; b=gQEx/nhobTYi7Sbnaur5EvXYZkUe3oLZywROy88coGdMILCqiEhYvrwHh2mH3XuTT7 TNGkR0CwG6hXSfx5TMWgJ0fNLyrBO+AXsmT4lZ7m8fp2tT/nYsq++q0jLwMS+tYSpJsG 0l8+OoazvZNEnDm1WAZhWkPNANnoeI59CLzlJrSlq2Yu/PHIT5Ff1NPuKqD+frMGHVVE nyeuT9QoDbmE/em249CtFSHbYd4dHe3KfXV5+BechpWL1EMBQtxtj5uz/bCWgOaEkv6u urtRi7Q2SSJwPStziiQjRbJrS5KXJdBeMeUQBILzLU979xE4cmc1wCI748LwflGK6ieb BZkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727372190; x=1727976990; 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=a6UDuHGKMWgBm1lEl1cmmS7v6p/aZimzfV7mPrGbWXw=; b=f7OOKLlGlgcjLEdYcAeaLPzMo2CxSlze6DSzisYAzNNL2saWaSmHYyeFwOJbsMo+bs gnMiW4qSzK2zy7GGQc0stm+N7RhDdxwkiLrhyJJ7FEwRF73EnG0CBSyURKrl2JiV0UF9 sHZUFpZMS21DIxz2YUcpK798Pex/C+o2IQudltWa9rJuGSNuVpkD1FrblcRhDiC36X6u DCvmPOZBW0P/R7nsrJ8k8UFkDrmpxExFGqkcMa4MAl9zqJMLhWkloxWM6qq5zdafmCyL HWgKDrdNBpigItc9Y5RW2XXYuZt/DLG0ty8r++MhsbRdIK0qaaAos75O0JLywB5/NAXR 2xsw== X-Forwarded-Encrypted: i=1; AJvYcCVoiG93gSJ8Nw7L585u65+anjxTvoU87vqZD+SE0ocCxHnxa0QhVxlu4AyKpqDUaM13eVv3xHXG5lZZuGM=@vger.kernel.org X-Gm-Message-State: AOJu0Yx8KSw2RAUSPLitnJ4UJXGeS1PI08WVzhAWmJrKbK4aJOum9JY+ 8elCdrRuMIULNne29VSpNpqCu1FI2/R+/S2/k1kWkLh59h+pPR7LNwSJHhdtAFBiyE1HIYwdBTX 2BcAliQ== X-Google-Smtp-Source: AGHT+IEQ1v1udEuCVrnBHWM8Chy/nN8/OC9iN2ju/Bd9VgTTXhMcCxeiRvBecFcpETJs3lIyyiKunBEaUEPh X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8872:3585:18ed:a056]) (user=irogers job=sendgmr) by 2002:a25:d6c1:0:b0:e16:51f9:59da with SMTP id 3f1490d57ef6-e2604b79520mr174276.6.1727372190471; Thu, 26 Sep 2024 10:36:30 -0700 (PDT) Date: Thu, 26 Sep 2024 10:35:52 -0700 In-Reply-To: <20240926173554.404411-1-irogers@google.com> Message-Id: <20240926173554.404411-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: <20240926173554.404411-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v4 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 , Kan Liang , John Garry , Jing Zhang , Sandipan Das , Benjamin Gray , Xu Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable 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: """ =20 def __init__(self, name: str, - metric_list: List[Union[Metric, 'MetricGroup']], + metric_list: List[Union[Optional[Metric], Optional['MetricG= roup']]], description: Optional[str] =3D None): self.name =3D name - self.metric_list =3D metric_list + self.metric_list =3D [] self.description =3D description for metric in metric_list: - metric.AddToMetricGroup(self) + if metric: + self.metric_list.append(metric) + metric.AddToMetricGroup(self) =20 def AddToMetricGroup(self, group): """Callback used when a MetricGroup is added into another.""" --=20 2.46.1.824.gd892dcdcdd-goog From nobody Thu Nov 28 22:40:21 2024 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 31BC7185082 for ; Thu, 26 Sep 2024 17:36:33 +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=1727372195; cv=none; b=dGByd4fcTUjCkqS0ClVRMogQe+95v9pHwWf6bI3fgcK0dU4tXsF5pDtdaEajMj7q94F8QoKSNrg5mTjvUve/iypLxAfnZsOZH2isOQTko9FyZo9rK5SlxDdMLYPccML7YT5h0078ZVt8JMGeNlka3LYt6JJ2qBe4CBDcjzs9Tyo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372195; c=relaxed/simple; bh=blAc9G6OebTxuItqauXCFyKk/ED91E1EMUyf5Yy8yWw=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=YnzQcdTLrMNr4HgBdmvMyegZ9237JMsjctYaZsp3Uwyb1u9pb/JaOfh/y1UqKzEDyflHChwGwMdBUTqmzDAi9wjzy+Ymk4WorCEuc5mI6xcACJBf32glJfhdiN42H3sBLZgrjDJIVb9pTP0Krs86NEhB8vYDS+Iior/p4xw09TA= 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=MeLuJvAc; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="MeLuJvAc" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6d9e31e66eeso30807147b3.1 for ; Thu, 26 Sep 2024 10:36:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727372193; x=1727976993; 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=EJsPdONTfaeiSG4hvXGB1buTusBhDadyMVVcT3k3om0=; b=MeLuJvAcnqAlvxl/TNKjWJJ3dkhzVCqLIZ85DMjVwARRAfD9c/cE5pTUp1GjwuN2rl hvPV0DSng7MrpTz2e7hwfzk5ZJHFXRx/A2FyWpeyxDaupLuV6rIISK26nurzIgcfSPGq 6ewRBPRiGf4gpingWH2BaVgOGkV9366owaDb6GSUNlOhYvZilNwErvGJXbAfLy7YYL9r JaZntzjWTq9edaV+zMg8vCWNulWGupFEHjM1rjMMB9rHyW7UklmIS+ppAoWK7BOsy2dQ gZGOsWihNY5ArZejY1DTM1e/JKecQgfgMkCyjTYNBzBjvy5zGlIcxRkkoOLtRSPGgsGN 6fCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727372193; x=1727976993; 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=EJsPdONTfaeiSG4hvXGB1buTusBhDadyMVVcT3k3om0=; b=K0VdfmoKsE79rLs+07K8+UzaPxLX1oD8iQ3qQvrwDq2AvmvMd9RVRHr7ZCi2adoyoq w3zZuhJKHJwAKzhtLbfF9ROvbkWXId0FFcpDQJgU3uW2l1qL2yTUo8W8POcO0CHtSLXr yuO/4HiFFXUeWHRxPDTM1VNy1WZDZA+Ji8+/2iRDqZGtTekh8WvHO+ShvM+Z4vMxj9/z ta8/Lp0YnkPEXLL9pCEM0Bhcv0zV7i6LQ9XYHnMSstkZJZzHGVo3sSi2Mjq+5oZF5etp LX9x3eF5y3mxNiJOLH0cUoG+wljstazBIokqCbljkc4WlqC+/1IglNcSf8xv66mn3Iho zinQ== X-Forwarded-Encrypted: i=1; AJvYcCWFnibBkM0jRc/ccTeQUzvnR2f0J6BaKfuVSUxgFfwYpxEBQa28OCSjXF2EZK+GNXPLDfMLwN7NLqgRZcQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwayfWI31+es/bB4ymaKqF/LtEyUrlsBvqKqYrqK6s4SdON6hxU VzP0wNg5PaguzVshsOWdMbNHi6OycKG3rfx4pgIKkGOC2LRZWbx1XyFnjh6Ci96XE1pMm6NVVQH b4JZqDw== X-Google-Smtp-Source: AGHT+IHpxdTYHncEHsDg61Q+sSYLnuPuOSiEh1LvRBvpsC4/tju0BMh1GG4g2X8BoXY+xExwarwZnLL9TBUV X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8872:3585:18ed:a056]) (user=irogers job=sendgmr) by 2002:a25:690b:0:b0:e24:f10f:7d99 with SMTP id 3f1490d57ef6-e2604b2dfdcmr119276.4.1727372192970; Thu, 26 Sep 2024 10:36:32 -0700 (PDT) Date: Thu, 26 Sep 2024 10:35:53 -0700 In-Reply-To: <20240926173554.404411-1-irogers@google.com> Message-Id: <20240926173554.404411-12-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240926173554.404411-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v4 11/12] perf jevents: Build support for generating metrics from python From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Jing Zhang , Sandipan Das , Benjamin Gray , Xu Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Generate extra-metrics.json and extra-metricgroups.json from python architecture specific scripts. The metrics themselves will be added in later patches. If a build takes place in tools/perf/ then extra-metrics.json and extra-metricgroups.json are generated in that directory and so added to .gitignore. If there is an OUTPUT directory then the tools/perf/pmu-events/arch files are copied to it so the generated extra-metrics.json and extra-metricgroups.json can be added/generated there. Signed-off-by: Ian Rogers --- tools/perf/.gitignore | 2 + tools/perf/Makefile.perf | 23 +++++++--- tools/perf/pmu-events/Build | 62 ++++++++++++++++++++++++-- tools/perf/pmu-events/amd_metrics.py | 38 ++++++++++++++++ tools/perf/pmu-events/arm64_metrics.py | 39 ++++++++++++++++ tools/perf/pmu-events/intel_metrics.py | 38 ++++++++++++++++ 6 files changed, 193 insertions(+), 9 deletions(-) create mode 100755 tools/perf/pmu-events/amd_metrics.py create mode 100755 tools/perf/pmu-events/arm64_metrics.py create mode 100755 tools/perf/pmu-events/intel_metrics.py diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore index f5b81d439387..c9a8da5bfc56 100644 --- a/tools/perf/.gitignore +++ b/tools/perf/.gitignore @@ -39,6 +39,8 @@ trace/beauty/generated/ pmu-events/pmu-events.c pmu-events/jevents pmu-events/metric_test.log +pmu-events/arch/**/extra-metrics.json +pmu-events/arch/**/extra-metricgroups.json tests/shell/*.shellcheck_log tests/shell/coresight/*.shellcheck_log tests/shell/lib/*.shellcheck_log diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf index 9dd2e8d3f3c9..75b278497526 100644 --- a/tools/perf/Makefile.perf +++ b/tools/perf/Makefile.perf @@ -1265,9 +1265,26 @@ endif # CONFIG_PERF_BPF_SKEL bpf-skel-clean: $(call QUIET_CLEAN, bpf-skel) $(RM) -r $(SKEL_TMP_OUT) $(SKELETONS) $(SKE= L_OUT)/vmlinux.h =20 +pmu-events-clean: +ifeq ($(OUTPUT),) + $(call QUIET_CLEAN, pmu-events) $(RM) \ + pmu-events/pmu-events.c \ + pmu-events/metric_test.log \ + pmu-events/test-empty-pmu-events.c \ + pmu-events/empty-pmu-events.log + $(Q)find pmu-events/arch -name 'extra-metrics.json' -delete -o \ + -name 'extra-metricgroups.json' -delete +else + $(call QUIET_CLEAN, pmu-events) $(RM) -r $(OUTPUT)pmu-events/arch \ + $(OUTPUT)pmu-events/pmu-events.c \ + $(OUTPUT)pmu-events/metric_test.log \ + $(OUTPUT)pmu-events/test-empty-pmu-events.c \ + $(OUTPUT)pmu-events/empty-pmu-events.log +endif + clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clean $(LIBSYMBOL)-cl= ean $(LIBPERF)-clean \ arm64-sysreg-defs-clean fixdep-clean python-clean bpf-skel-clean \ - tests-coresight-targets-clean + tests-coresight-targets-clean pmu-events-clean $(call QUIET_CLEAN, core-objs) $(RM) $(LIBPERF_A) $(OUTPUT)perf-archive \ $(OUTPUT)perf-iostat $(LANG_BINDINGS) $(Q)find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '*.a' -delete -o \ @@ -1280,10 +1297,6 @@ clean:: $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)= -clean $(LIBSYMBOL)-clean $( $(OUTPUT)FEATURE-DUMP $(OUTPUT)util/*-bison* $(OUTPUT)util/*-flex* \ $(OUTPUT)util/intel-pt-decoder/inat-tables.c \ $(OUTPUT)tests/llvm-src-{base,kbuild,prologue,relocation}.c \ - $(OUTPUT)pmu-events/pmu-events.c \ - $(OUTPUT)pmu-events/test-empty-pmu-events.c \ - $(OUTPUT)pmu-events/empty-pmu-events.log \ - $(OUTPUT)pmu-events/metric_test.log \ $(OUTPUT)$(fadvise_advice_array) \ $(OUTPUT)$(fsconfig_arrays) \ $(OUTPUT)$(fsmount_arrays) \ diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build index d941bc9d16e9..d89275c4f485 100644 --- a/tools/perf/pmu-events/Build +++ b/tools/perf/pmu-events/Build @@ -1,7 +1,6 @@ pmu-events-y +=3D pmu-events.o JDIR =3D pmu-events/arch/$(SRCARCH) -JSON =3D $(shell [ -d $(JDIR) ] && \ - find $(JDIR) -name '*.json' -o -name 'mapfile.csv') +JSON =3D $(shell find pmu-events/arch -name *.json -o -name *.csv) JDIR_TEST =3D pmu-events/arch/test JSON_TEST =3D $(shell [ -d $(JDIR_TEST) ] && \ find $(JDIR_TEST) -name '*.json') @@ -29,6 +28,61 @@ $(PMU_EVENTS_C): $(EMPTY_PMU_EVENTS_C) $(call rule_mkdir) $(Q)$(call echo-cmd,gen)cp $< $@ else +# Extract the model from a extra-metrics.json or extra-metricgroups.json p= ath +model_name =3D $(shell echo $(1)|sed -e 's@.\+/\(.*\)/extra-metric.*\.json= @\1@') +vendor_name =3D $(shell echo $(1)|sed -e 's@.\+/\(.*\)/[^/]*/extra-metric.= *\.json@\1@') + +# Copy checked-in json for generation. +$(OUTPUT)pmu-events/arch/%: pmu-events/arch/% + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)cp $< $@ + +GEN_METRIC_DEPS :=3D pmu-events/metric.py + +# Generate AMD Json +ZENS =3D $(shell ls -d pmu-events/arch/x86/amdzen*) +ZEN_METRICS =3D $(foreach x,$(ZENS),$(OUTPUT)$(x)/extra-metrics.json) +ZEN_METRICGROUPS =3D $(foreach x,$(ZENS),$(OUTPUT)$(x)/extra-metricgroups.= json) + +$(ZEN_METRICS): pmu-events/amd_metrics.py $(GEN_METRIC_DEPS) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(PYTHON) $< $(call model_name,$@) arch > $@ + +$(ZEN_METRICGROUPS): pmu-events/amd_metrics.py $(GEN_METRIC_DEPS) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(PYTHON) $< -metricgroups $(call model_name,$@) = arch > $@ + +# Generate ARM Json +ARMS =3D $(shell ls -d pmu-events/arch/arm64/arm/*) +ARM_METRICS =3D $(foreach x,$(ARMS),$(OUTPUT)$(x)/extra-metrics.json) +ARM_METRICGROUPS =3D $(foreach x,$(ARMS),$(OUTPUT)$(x)/extra-metricgroups.= json) + +$(ARM_METRICS): pmu-events/arm64_metrics.py $(GEN_METRIC_DEPS) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(PYTHON) $< $(call vendor_name,$@) $(call model_= name,$@) arch > $@ + +$(ARM_METRICGROUPS): pmu-events/arm64_metrics.py $(GEN_METRIC_DEPS) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(PYTHON) $< -metricgroups $(call vendor_name,$@)= $(call model_name,$@) arch > $@ + +# Generate Intel Json +INTELS =3D $(shell ls -d pmu-events/arch/x86/*|grep -v amdzen|grep -v mapf= ile.csv) +INTEL_METRICS =3D $(foreach x,$(INTELS),$(OUTPUT)$(x)/extra-metrics.json) +INTEL_METRICGROUPS =3D $(foreach x,$(INTELS),$(OUTPUT)$(x)/extra-metricgro= ups.json) + +$(INTEL_METRICS): pmu-events/intel_metrics.py $(GEN_METRIC_DEPS) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(PYTHON) $< $(call model_name,$@) arch > $@ + +$(INTEL_METRICGROUPS): pmu-events/intel_metrics.py $(GEN_METRIC_DEPS) + $(call rule_mkdir) + $(Q)$(call echo-cmd,gen)$(PYTHON) $< -metricgroups $(call model_name,$@) = arch > $@ + +GEN_JSON =3D $(patsubst %,$(OUTPUT)%,$(JSON)) \ + $(ZEN_METRICS) $(ZEN_METRICGROUPS) \ + $(ARM_METRICS) $(ARM_METRICGROUPS) \ + $(INTEL_METRICS) $(INTEL_METRICGROUPS) + $(METRIC_TEST_LOG): $(METRIC_TEST_PY) $(METRIC_PY) $(call rule_mkdir) $(Q)$(call echo-cmd,test)$(PYTHON) $< 2> $@ || (cat $@ && false) @@ -41,9 +95,9 @@ $(EMPTY_PMU_EVENTS_TEST_LOG): $(EMPTY_PMU_EVENTS_C) $(TES= T_EMPTY_PMU_EVENTS_C) $(call rule_mkdir) $(Q)$(call echo-cmd,test)diff -u $^ 2> $@ || (cat $@ && false) =20 -$(PMU_EVENTS_C): $(JSON) $(JSON_TEST) $(JEVENTS_PY) $(METRIC_PY) $(METRIC_= TEST_LOG) $(EMPTY_PMU_EVENTS_TEST_LOG) +$(PMU_EVENTS_C): $(GEN_JSON) $(JSON_TEST) $(JEVENTS_PY) $(METRIC_PY) $(MET= RIC_TEST_LOG) $(EMPTY_PMU_EVENTS_TEST_LOG) $(call rule_mkdir) - $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS= _MODEL) pmu-events/arch $@ + $(Q)$(call echo-cmd,gen)$(PYTHON) $(JEVENTS_PY) $(JEVENTS_ARCH) $(JEVENTS= _MODEL) $(OUTPUT)pmu-events/arch $@ endif =20 # pmu-events.c file is generated in the OUTPUT directory so it needs a diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/a= md_metrics.py new file mode 100755 index 000000000000..7ab2ee4fdb17 --- /dev/null +++ b/tools/perf/pmu-events/amd_metrics.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, M= etricGroup) +import argparse +import json +import os + +# Global command line arguments. +_args =3D None + +def main() -> None: + global _args + + def dir_path(path: str) -> str: + """Validate path is a directory for argparse.""" + if os.path.isdir(path): + return path + raise argparse.ArgumentTypeError(f'\'{path}\' is not a valid directory= ') + + parser =3D argparse.ArgumentParser(description=3D"AMD perf json generato= r") + parser.add_argument("-metricgroups", help=3D"Generate metricgroups data"= , action=3D'store_true') + parser.add_argument("model", help=3D"e.g. amdzen[123]") + parser.add_argument( + 'events_path', + type=3Ddir_path, + help=3D'Root of tree containing architecture directories containing = json files' + ) + _args =3D parser.parse_args() + + all_metrics =3D MetricGroup("",[]) + + if _args.metricgroups: + print(JsonEncodeMetricGroupDescriptions(all_metrics)) + else: + print(JsonEncodeMetric(all_metrics)) + +if __name__ =3D=3D '__main__': + main() diff --git a/tools/perf/pmu-events/arm64_metrics.py b/tools/perf/pmu-events= /arm64_metrics.py new file mode 100755 index 000000000000..a9f0e6bc751b --- /dev/null +++ b/tools/perf/pmu-events/arm64_metrics.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, M= etricGroup) +import argparse +import json +import os + +# Global command line arguments. +_args =3D None + +def main() -> None: + global _args + + def dir_path(path: str) -> str: + """Validate path is a directory for argparse.""" + if os.path.isdir(path): + return path + raise argparse.ArgumentTypeError(f'\'{path}\' is not a valid directory= ') + + parser =3D argparse.ArgumentParser(description=3D"ARM perf json generato= r") + parser.add_argument("-metricgroups", help=3D"Generate metricgroups data"= , action=3D'store_true') + parser.add_argument("vendor", help=3D"e.g. arm") + parser.add_argument("model", help=3D"e.g. neoverse-n1") + parser.add_argument( + 'events_path', + type=3Ddir_path, + help=3D'Root of tree containing architecture directories containing = json files' + ) + _args =3D parser.parse_args() + + all_metrics =3D MetricGroup("",[]) + + if _args.metricgroups: + print(JsonEncodeMetricGroupDescriptions(all_metrics)) + else: + print(JsonEncodeMetric(all_metrics)) + +if __name__ =3D=3D '__main__': + main() diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events= /intel_metrics.py new file mode 100755 index 000000000000..f004c27640d2 --- /dev/null +++ b/tools/perf/pmu-events/intel_metrics.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) +from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, M= etricGroup) +import argparse +import json +import os + +# Global command line arguments. +_args =3D None + +def main() -> None: + global _args + + def dir_path(path: str) -> str: + """Validate path is a directory for argparse.""" + if os.path.isdir(path): + return path + raise argparse.ArgumentTypeError(f'\'{path}\' is not a valid directory= ') + + parser =3D argparse.ArgumentParser(description=3D"Intel perf json genera= tor") + parser.add_argument("-metricgroups", help=3D"Generate metricgroups data"= , action=3D'store_true') + parser.add_argument("model", help=3D"e.g. skylakex") + parser.add_argument( + 'events_path', + type=3Ddir_path, + help=3D'Root of tree containing architecture directories containing = json files' + ) + _args =3D parser.parse_args() + + all_metrics =3D MetricGroup("",[]) + + if _args.metricgroups: + print(JsonEncodeMetricGroupDescriptions(all_metrics)) + else: + print(JsonEncodeMetric(all_metrics)) + +if __name__ =3D=3D '__main__': + main() --=20 2.46.1.824.gd892dcdcdd-goog From nobody Thu Nov 28 22:40:21 2024 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 E513816190C for ; Thu, 26 Sep 2024 17:36:36 +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=1727372198; cv=none; b=ZoUNjIIvJewzraaBnpVny93Xd7sBeD4bQE3abPjDL1ZPUGEeaAGKNXG1fofBBa9pm+pOHnhPL8frUAANNAGfBL43Hl9GCsSb2+5hV9gh903nLYMI1nzu+JkEe08i3Krw4MjcaWQZ8E08kVWKUNMBV3WzpGGJQIZE2Kx0a5KP5e4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727372198; c=relaxed/simple; bh=ds/6QN0N+eX7ozRww2ZlsCUbFrTYWR2Pkujfts4WTag=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=mx/yGGcbzuEeG19agbb13hl2ASRvK3Sp3F4dxp3ywc5oayWY1zBzqsi+c4VEG3UrjL3qZXo+CK4dpUCUNEHkUeUez1hkkoUzXVHGPlYHnvhLMUKFfQlV2hJ5gbTU+iZHeTSTXjPQTxTLrCx5dJV80lI5OE2ofXcI4qqg2TbxkWY= 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=JsIX3bqu; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="JsIX3bqu" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6d4bd76f5a8so24383567b3.0 for ; Thu, 26 Sep 2024 10:36:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727372196; x=1727976996; 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=h1yvFCEwKQ3wd3i4rPKz93fgEiuuae9SHgL1DUf9d6U=; b=JsIX3bqu+Kpvoj/gIONL8vWDX2paS8wZorIokPrYHznG+qPamXcj1Yd9R5XclrPkK8 8d0gkVrqEq4b3CTGnOwyE1btwYwwyVLzMkx79oc/AWtBlzzXyzzBsNC5o2XMsUouVmt/ WbhwiOfq7o7QPQSse7STVuSQQ3gp48WSP77bLriLOXS0KqWHEU2TCMShSwK9jiToVrKa xlOBIOOF5pRWxX7gOVa/VhiymUGMuX61R1Ed9mfQ6VxUMbzeuCQ4M4Qx7lEGYFJnOeHQ 9GXIxQ0NjEf/IEs/uTya0VN6rr+o+aH/nCJ0n6xNO6igIAu/nBY6Iw1+pIFH8Oy0i/Mp +kAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727372196; x=1727976996; 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=h1yvFCEwKQ3wd3i4rPKz93fgEiuuae9SHgL1DUf9d6U=; b=BWzFu7ZNVLV83RObbPqhj7AmYXHyGwmYBjpN4UjoFnRDyboqNkv4fbu+TFFusfR8V+ arWCPnG0AWCsf9mjen+WbzoydaZV2POquYdjvmckNF/1nC5ut505ohVVSpaNxO2MqATz MkBZVZzLD8yLQTeHeUxJvxuDE1wdKNnExJbeSTngraHMgZtG5Jjsq0eLfH71xgXk95iH HaXz3K+8EPagclqOw/syMNGVBfH+Fje3gXZQqNAYG+Xf9tdwjujkrOsX0fK3d0hz3EJb T17o0HsvVhkBlqOFTxM08c2GNVukWXX1sHYtbI2yOMJ6ic5ZQxpFWJi76g+dejqZnr3U 3soA== X-Forwarded-Encrypted: i=1; AJvYcCXRv4GgOYrDWW5JWBKnKXU6j45IbSRYCsOcYQ2C2CBEXMeH7SigEUt7vEqdgM3i3nXd75WK5qwViD31wbs=@vger.kernel.org X-Gm-Message-State: AOJu0YzCsN+p/HYabzBR+X0oSKwPsHTPFBVXUmhxRNsrbC5TXywxBslU HlLfD0+Mh/9yIuwTO3OJffmTTnF2n/nB93Qzy/e9IPAzz4lrIdmagkxEWzpl20/nD4cFDI+E6B6 uAXQ9Xw== X-Google-Smtp-Source: AGHT+IFK0k8Rkerkrh3QirrpvkNRJSdw/gsRuMqQtRFrcu08gzmyE1D8gAexa1TODfbWh22et09fOWTWlqkv X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:8872:3585:18ed:a056]) (user=irogers job=sendgmr) by 2002:a05:690c:2011:b0:6e2:3e17:1838 with SMTP id 00721157ae682-6e247518b3emr9357b3.1.1727372195414; Thu, 26 Sep 2024 10:36:35 -0700 (PDT) Date: Thu, 26 Sep 2024 10:35:54 -0700 In-Reply-To: <20240926173554.404411-1-irogers@google.com> Message-Id: <20240926173554.404411-13-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240926173554.404411-1-irogers@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Subject: [PATCH v4 12/12] perf jevents: Add load event json to verify and allow fallbacks From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , John Garry , Jing Zhang , Sandipan Das , Benjamin Gray , Xu Yang , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a LoadEvents function that loads all event json files in a directory. In the Event constructor ensure all events are defined in the event json except for legacy events like "cycles". If the initial event isn't found then legacy_event1 is used, and if that isn't found legacy_event2 is used. This allows a single Event to have multiple event names as models will often rename the same event over time. If the event doesn't exist an exception is raised. So that references to metrics can be added, add the MetricRef class. This doesn't validate as an event name and so provides an escape hatch for metrics to refer to each other. Signed-off-by: Ian Rogers --- tools/perf/pmu-events/Build | 12 ++-- tools/perf/pmu-events/amd_metrics.py | 6 +- tools/perf/pmu-events/arm64_metrics.py | 6 +- tools/perf/pmu-events/intel_metrics.py | 6 +- tools/perf/pmu-events/metric.py | 77 +++++++++++++++++++++++++- 5 files changed, 95 insertions(+), 12 deletions(-) diff --git a/tools/perf/pmu-events/Build b/tools/perf/pmu-events/Build index d89275c4f485..f3bc6c093360 100644 --- a/tools/perf/pmu-events/Build +++ b/tools/perf/pmu-events/Build @@ -46,11 +46,11 @@ ZEN_METRICGROUPS =3D $(foreach x,$(ZENS),$(OUTPUT)$(x)/= extra-metricgroups.json) =20 $(ZEN_METRICS): pmu-events/amd_metrics.py $(GEN_METRIC_DEPS) $(call rule_mkdir) - $(Q)$(call echo-cmd,gen)$(PYTHON) $< $(call model_name,$@) arch > $@ + $(Q)$(call echo-cmd,gen)$(PYTHON) $< $(call model_name,$@) pmu-events/arc= h > $@ =20 $(ZEN_METRICGROUPS): pmu-events/amd_metrics.py $(GEN_METRIC_DEPS) $(call rule_mkdir) - $(Q)$(call echo-cmd,gen)$(PYTHON) $< -metricgroups $(call model_name,$@) = arch > $@ + $(Q)$(call echo-cmd,gen)$(PYTHON) $< -metricgroups $(call model_name,$@) = pmu-events/arch > $@ =20 # Generate ARM Json ARMS =3D $(shell ls -d pmu-events/arch/arm64/arm/*) @@ -59,11 +59,11 @@ ARM_METRICGROUPS =3D $(foreach x,$(ARMS),$(OUTPUT)$(x)/= extra-metricgroups.json) =20 $(ARM_METRICS): pmu-events/arm64_metrics.py $(GEN_METRIC_DEPS) $(call rule_mkdir) - $(Q)$(call echo-cmd,gen)$(PYTHON) $< $(call vendor_name,$@) $(call model_= name,$@) arch > $@ + $(Q)$(call echo-cmd,gen)$(PYTHON) $< $(call vendor_name,$@) $(call model_= name,$@) pmu-events/arch > $@ =20 $(ARM_METRICGROUPS): pmu-events/arm64_metrics.py $(GEN_METRIC_DEPS) $(call rule_mkdir) - $(Q)$(call echo-cmd,gen)$(PYTHON) $< -metricgroups $(call vendor_name,$@)= $(call model_name,$@) arch > $@ + $(Q)$(call echo-cmd,gen)$(PYTHON) $< -metricgroups $(call vendor_name,$@)= $(call model_name,$@) pmu-events/arch > $@ =20 # Generate Intel Json INTELS =3D $(shell ls -d pmu-events/arch/x86/*|grep -v amdzen|grep -v mapf= ile.csv) @@ -72,11 +72,11 @@ INTEL_METRICGROUPS =3D $(foreach x,$(INTELS),$(OUTPUT)$= (x)/extra-metricgroups.json =20 $(INTEL_METRICS): pmu-events/intel_metrics.py $(GEN_METRIC_DEPS) $(call rule_mkdir) - $(Q)$(call echo-cmd,gen)$(PYTHON) $< $(call model_name,$@) arch > $@ + $(Q)$(call echo-cmd,gen)$(PYTHON) $< $(call model_name,$@) pmu-events/arc= h > $@ =20 $(INTEL_METRICGROUPS): pmu-events/intel_metrics.py $(GEN_METRIC_DEPS) $(call rule_mkdir) - $(Q)$(call echo-cmd,gen)$(PYTHON) $< -metricgroups $(call model_name,$@) = arch > $@ + $(Q)$(call echo-cmd,gen)$(PYTHON) $< -metricgroups $(call model_name,$@) = pmu-events/arch > $@ =20 GEN_JSON =3D $(patsubst %,$(OUTPUT)%,$(JSON)) \ $(ZEN_METRICS) $(ZEN_METRICGROUPS) \ diff --git a/tools/perf/pmu-events/amd_metrics.py b/tools/perf/pmu-events/a= md_metrics.py index 7ab2ee4fdb17..4f728e7aae4a 100755 --- a/tools/perf/pmu-events/amd_metrics.py +++ b/tools/perf/pmu-events/amd_metrics.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, M= etricGroup) +from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, L= oadEvents, + MetricGroup) import argparse import json import os @@ -27,6 +28,9 @@ def main() -> None: ) _args =3D parser.parse_args() =20 + directory =3D f"{_args.events_path}/x86/{_args.model}/" + LoadEvents(directory) + all_metrics =3D MetricGroup("",[]) =20 if _args.metricgroups: diff --git a/tools/perf/pmu-events/arm64_metrics.py b/tools/perf/pmu-events= /arm64_metrics.py index a9f0e6bc751b..c9aa2d827a82 100755 --- a/tools/perf/pmu-events/arm64_metrics.py +++ b/tools/perf/pmu-events/arm64_metrics.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, M= etricGroup) +from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, L= oadEvents, + MetricGroup) import argparse import json import os @@ -30,6 +31,9 @@ def main() -> None: =20 all_metrics =3D MetricGroup("",[]) =20 + directory =3D f"{_args.events_path}/arm64/{_args.vendor}/{_args.model}/" + LoadEvents(directory) + if _args.metricgroups: print(JsonEncodeMetricGroupDescriptions(all_metrics)) else: diff --git a/tools/perf/pmu-events/intel_metrics.py b/tools/perf/pmu-events= /intel_metrics.py index f004c27640d2..04a19d05c6c1 100755 --- a/tools/perf/pmu-events/intel_metrics.py +++ b/tools/perf/pmu-events/intel_metrics.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) -from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, M= etricGroup) +from metric import (JsonEncodeMetric, JsonEncodeMetricGroupDescriptions, L= oadEvents, + MetricGroup) import argparse import json import os @@ -27,6 +28,9 @@ def main() -> None: ) _args =3D parser.parse_args() =20 + directory =3D f"{_args.events_path}/x86/{_args.model}/" + LoadEvents(directory) + all_metrics =3D MetricGroup("",[]) =20 if _args.metricgroups: diff --git a/tools/perf/pmu-events/metric.py b/tools/perf/pmu-events/metric= .py index dd8fd06940e6..03312cd6d491 100644 --- a/tools/perf/pmu-events/metric.py +++ b/tools/perf/pmu-events/metric.py @@ -3,10 +3,50 @@ import ast import decimal import json +import os import re from enum import Enum from typing import Dict, List, Optional, Set, Tuple, Union =20 +all_events =3D set() + +def LoadEvents(directory: str) -> None: + """Populate a global set of all known events for the purpose of validati= ng Event names""" + global all_events + all_events =3D { + "context\-switches", + "cycles", + "duration_time", + "instructions", + "l2_itlb_misses", + } + for file in os.listdir(os.fsencode(directory)): + filename =3D os.fsdecode(file) + if filename.endswith(".json"): + for x in json.load(open(f"{directory}/{filename}")): + if "EventName" in x: + all_events.add(x["EventName"]) + elif "ArchStdEvent" in x: + all_events.add(x["ArchStdEvent"]) + + +def CheckEvent(name: str) -> bool: + """Check the event name exists in the set of all loaded events""" + global all_events + if len(all_events) =3D=3D 0: + # No events loaded so assume any event is good. + return True + + if ':' in name: + # Remove trailing modifier. + name =3D name[:name.find(':')] + elif '/' in name: + # Name could begin with a PMU or an event, for now assume it is good. + return True + + return name in all_events + + class MetricConstraint(Enum): GROUPED_EVENTS =3D 0 NO_GROUP_EVENTS =3D 1 @@ -317,9 +357,18 @@ def _FixEscapes(s: str) -> str: class Event(Expression): """An event in an expression.""" =20 - def __init__(self, name: str, legacy_name: str =3D ''): - self.name =3D _FixEscapes(name) - self.legacy_name =3D _FixEscapes(legacy_name) + def __init__(self, *args: str): + error =3D "" + for name in args: + if CheckEvent(name): + self.name =3D _FixEscapes(name) + return + if error: + error +=3D " or " + name + else: + error =3D name + global all_events + raise Exception(f"No event {error} in:\n{all_events}") =20 def ToPerfJson(self): result =3D re.sub('/', '@', self.name) @@ -338,6 +387,28 @@ class Event(Expression): return self =20 =20 +class MetricRef(Expression): + """A metric reference in an expression.""" + + def __init__(self, name: str): + self.name =3D _FixEscapes(name) + + def ToPerfJson(self): + return self.name + + def ToPython(self): + return f'MetricRef(r"{self.name}")' + + def Simplify(self) -> Expression: + return self + + def Equals(self, other: Expression) -> bool: + return isinstance(other, MetricRef) and self.name =3D=3D other.name + + def Substitute(self, name: str, expression: Expression) -> Expression: + return self + + class Constant(Expression): """A constant within the expression tree.""" =20 --=20 2.46.1.824.gd892dcdcdd-goog