Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp638322lqg; Fri, 1 Mar 2024 17:01:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUrxbyd3uJkTNnYoy7cL/9TMXt7Tv7HDl2yutaCRryXFq60ROgNvOXRI7ZI1ISNxABh2MQqMfsGhkhSJ03o8NTvinWpp4AhAlQbC0Rlrg== X-Google-Smtp-Source: AGHT+IFJX6JxBNdDdNKoE0nZ9i7ShKiJMv7GUP1bUP3yKINA9EeOwocKunpT4RjWawCePMUP2Ocg X-Received: by 2002:a17:906:849:b0:a3e:fb26:fc0f with SMTP id f9-20020a170906084900b00a3efb26fc0fmr2353533ejd.65.1709341297170; Fri, 01 Mar 2024 17:01:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341297; cv=pass; d=google.com; s=arc-20160816; b=Ohk1SvrvGRhVf4tgGUKU6iJ6GmysMOiZbj70bbwC7KsPZMqPrb/51wMuRIKlQdLRsx Tl9Td0opnoupCqiYIPI8SK+naAqTDzckCyFewOsLuu9ttiQ4ZfC/BiWCK1jsfCLmTami zvVdAtxMbQljEBUx4XMZMGTjEMNYh7NbDH2hLw0y9xF1Ol6UT4DiXCLDa+7Q2ssWL8sJ iTL6M41mVMW7lK8jTvkNvtY85rYgxFRe2QAuqHb/HkQcBqZkwtX8Ahe/5DzSz4YMQ079 b66zFGihY9d8YfGK8M56pmYiz/qw4dKoKXu+mGd1DFvgrCm9XsDJTB81V1Kg9I5msvkt rSuw== 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=F9W2L65moWfkRODZWtj1+8FpZZOCQB/UnzNIcvAZEKE=; fh=P1AWSOYOh43WMozk473SoXBQAqABUq1PsGlPSy/dnhM=; b=0QE1axXyHaHOkZHCn6AjXPD/tmnHGUbTHbA37mhWpdfoeHdNuFN9MoHKZ/DNi32oYL NxaiMmo/FEITdYfl4VmL714uC3SzkleFjCotuNCVoy2qt8HSZeElm0v0VlAPgWOevySn vtPU7t2Q5WO3cW1qJVV6KYV8Lb81QGQ9aqPdv7TSAGbYgNsDLygT5U3mlq0nKpserxT3 0bYBB8IgFTHsn+B1DrFhgLiBd78bcQ9wi+ElKZVBnaCHmyly/JTnAz5f4JgqnQUps3r0 mWhunsrqViEwQ9+YN3ox70Penf9KdpP4TvoxUz4G9X77rLf9nwZemOQO3EObu/qMg/Mu dnNw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=fLBljgp6; 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-89280-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89280-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id xj8-20020a170906db0800b00a3f795290f4si1950491ejb.775.2024.03.01.17.01.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:01:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89280-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=fLBljgp6; 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-89280-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89280-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 am.mirrors.kernel.org (Postfix) with ESMTPS id AFF701F23AD0 for ; Sat, 2 Mar 2024 01:01:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42F02134A1; Sat, 2 Mar 2024 01:00:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fLBljgp6" Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.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 0E85312E59 for ; Sat, 2 Mar 2024 01:00:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341215; cv=none; b=KW28C1TOCHZasN7Gbtjh6A/d4TeQOxZ1PpmYXZjk8fjVBrjvndLIJ8kstX6DmMVzURFgZ1DIcT8DOmMdkg3qvyTHkUAu8n16d7rbZrITbeFBwxk2r5nTGGod7RGV9c4fD2+vg2xomNn0jk0qhVcJ9P6FwtyPXAxczXd91wrumK8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341215; c=relaxed/simple; bh=oswX3i20yiaJHjTAeWqAXOG6a2/1Ta4qOMh9xoJeXu4=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=UDsmmMc73ep9RtYOtU5bBXifMzixrgNYLag82meLaeYGN7rDnJdflxDuhDk7F1YbuEKBYQKIfPcTIF7SgVvkLGury6JVEOd6i8YB9uKmyeCEssgccw0V7/VfhcYEtqjLM9a78BRh0EliTdivAkLuynlFHaLZkKmVnClJEnHQ7G4= 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=fLBljgp6; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-5dc91de351fso2164616a12.0 for ; Fri, 01 Mar 2024 17:00:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341213; x=1709946013; 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=F9W2L65moWfkRODZWtj1+8FpZZOCQB/UnzNIcvAZEKE=; b=fLBljgp6qk+iMOADua+20FQ06KrTCkM2VMIShD7IXVBK+bpRtIr0OyKJPlIpwpxfIh Ba2kIFN5C1TQ2qxDixFo1A+hb6VE+oSMK/fDuo3LUmnmMFaK91P/myloqeGodGFqkf3r 8KtNLrR9tSKYUHEx2CIGwGUD+aLEGDWOgywm8kZECGCHdi//yZUOs0w8aq/vO3MEsJbk HDu1/7Wp/2o/b86qloTRUOuIWp7aXvaog6dkGIWdt9x5O7x8tThjCKpmD/tnfHHVuAXE ZnLeKOLbJi7kMozJmAgyeytX6mfOOOf0c82+ytbcph+87E5/FZ/hOgDtL2+R/M4aJKZB sWqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341213; x=1709946013; 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=F9W2L65moWfkRODZWtj1+8FpZZOCQB/UnzNIcvAZEKE=; b=rSrHNG7mt3t6QuywFKImGLaxvJM6e31lnTu8n6SzloJu25s8TCE2nidHuMEDQJIEip xwztREB4jgKm8qhC335NwslPHCTUPMCw+VF+eE/QFRtYYZEedJXKk/im9e4wMarrQ8Td 16+FWJMI8iOGYtlFtflUi4irGsNn9Cne/p5ORbWXBcHaEi+zP81LPzxlJTBxK+JEvgTr wF55WVMoir/acL3qZnm2LoziY1TSkHDiVCIrHX95eEHD9XnGLTgkaO/9pNleSfdg/nyF 0rV7aVPqx95lMguGMwmopnseHuQO46pTHi0ev9d94F+e343djX6ex/sOV+59/rFZB3qL 2PeQ== X-Forwarded-Encrypted: i=1; AJvYcCXZ1xHwLjhQQ3EOPqSIyfMp85zDGvaYZIq29czP0dJx5Iecuk0Pcc0UnK8HX8yB87+kGJIqrAxLzdW5rwW80BTkiaOd4WdI6X1FYljS X-Gm-Message-State: AOJu0Yw6+xj78Qdk9z0UkQIMDyM8zouofDp4gpBJ6aUi7bR1Qoi5DHKi jD/GV7zPE44FvfnaUXPCuK+YFs9rnR1KSqUTd6uXdIwXf5c7AouwFSoPhirQMTr8+BwywMosWrx TwGWSUg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a63:d94a:0:b0:5dc:cee7:9b1b with SMTP id e10-20020a63d94a000000b005dccee79b1bmr7224pgj.5.1709341212230; Fri, 01 Mar 2024 17:00:12 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:44 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-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: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 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 , 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" 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 event name py = re.sub(r'#Event\(r"([^"]*)"\)', r'Literal("#\1")', py) + # Fix events wrongly broken at a ',' + while True: + prev_py = py + py = re.sub(r'Event\(r"([^"]*)"\),Event\(r"([^"]*)"\)', r'Event(r"\1,\2")', py) + if py == 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 and it gets interpreted as # a double by the Bison parser @@ -586,7 +592,6 @@ def ParsePerfJson(orig: str) -> Expression: parsed = ast.fix_missing_locations(parsed) return _Constify(eval(compile(parsed, orig, 'eval'))) - def RewriteMetricsInTermsOfOthers(metrics: List[Tuple[str, str, Expression]] )-> Dict[Tuple[str, str], Expression]: """Shorten metrics by rewriting in terms of others. -- 2.44.0.278.ge034bb2e1d-goog