Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp638176lqg; Fri, 1 Mar 2024 17:01:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVv5c0M9KBx15kGfimkCwl7XSN8JtEkYW8XL13ih4iGZjAuBTGQwALCmmA4j+ldkcMclMq27F87gyHiYtl/AcT+EFnVpV3c/5QdeW7tCw== X-Google-Smtp-Source: AGHT+IE8AE4rCjtdDiQEyz65kIxZVP4/QfGJeZWXXqLPK11RcSLQ0jEUUWdF83S+MCk0l1IcrO2N X-Received: by 2002:a17:906:a84a:b0:a44:c723:470b with SMTP id dx10-20020a170906a84a00b00a44c723470bmr692448ejb.31.1709341281559; Fri, 01 Mar 2024 17:01:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709341281; cv=pass; d=google.com; s=arc-20160816; b=FosrNiklX5MYyIXQ88ikmzue75s+XaOWIXFw8aw4HP8ebtrkSzw/gXygKKYw4B+ZWE 2v0jC8WMrCwgs0DZp12o4+ZKlQ/wAroo4EB7+Tcs+FVFoITJTAl7KJfDcaThfxa1o/3M iDpF35DZIyJjFIllEGwUzk84J0DmZz54rBZAsvJMy9et+laQENc4H5gFG7KmuRJjRzvW HMyrVZ+a7wP9HXIs4xcxFFA+NKmNYB25ElWIetSqTBLqePHuxQNsC/pyFsbZSlqP2wf7 s4DCNbrWKrhajkjG8Rn/CAIMSQntg94Vbjf4S/tBxrFhxqkQ+TPS1ZNKXgZ6LSRHlWAX PiYg== 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=bBWDWJvSshoSjEVW3Suakt0O9q+vGDdTpywx5NXn+PM=; fh=jwNDYwY46+9SCY1l4rEWRDOKXPomZVmjasCY5hxmh5g=; b=FWI7taHe3p1ND9zKU8EYJ+W14Ee/prruqEig6vDxgNN1P4HXHryYlqHiQvtIw9Fihr fK3ovlXB1JiQttbaNbz0E5eUZY27UWqFm5RK0D9TT/798jCc4RWOqTn2AAVJ8pVJkPzw d9NXiUgTxl5RK44OHX7Sf5kqb9o+k8Bt8oqpxiAHqRO3+J3znMLv3yVsO+HgVE8aH+My S6VHuSh9VG9tCccWGcTHTMAgw7mxCXtwQDszv56w1SolankVVrQQR7Kbg0Op7o3cHz8k j/5DMH6OXmcoDLk5o4cT6tEqknUz20/pSroSkesB27UtVbjaLYEYmgtIJ5kkL66eOBJf 104A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=sao89wZT; 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-89279-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89279-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 l19-20020a056402255300b0056628e3201bsi1862717edb.12.2024.03.01.17.01.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 17:01:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89279-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=sao89wZT; 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-89279-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89279-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 4F9A61F23D16 for ; Sat, 2 Mar 2024 01:01:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0954B12B97; Sat, 2 Mar 2024 01:00:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="sao89wZT" 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 BC8F811724 for ; Sat, 2 Mar 2024 01:00:10 +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=1709341212; cv=none; b=devDlZst1qgJMPPzFobwCagf7o+uG9DbwZchkWt7/oi61+WHfAO3tQ1bKV0cZUSZ2pSmgcJ3PG52HlPmYoD+u37PQUxNz/LCidpa9dpom60C4iJ4LN2aWmm4A0xemutRQzj97IFEXz+VqpeDGuAePKIBanAqQuwPEYQyCi9VDsY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709341212; c=relaxed/simple; bh=j1Uteud1mWr9qwRDjsafkmahAN/I9mDRvh5Ckh8gIQo=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Content-Type; b=QJ5xowguVym3KsardYe4oLkYkHxo5jPnouqQRFcQlhft94rsIFLjcpfeV3yoNWk6Nr/PKmVjIMdgHUltDlFktvfGBzPAi7t92Dw/fmVFCCHSKbbGxKlz27IMUKGo3WRHjLQxX+zRoJujD9ujHu6lqyBMD2zTDCCHNp2Wcg6tFRE= 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=sao89wZT; arc=none smtp.client-ip=209.85.128.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-608ac8c5781so48532217b3.3 for ; Fri, 01 Mar 2024 17:00:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709341210; x=1709946010; 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=bBWDWJvSshoSjEVW3Suakt0O9q+vGDdTpywx5NXn+PM=; b=sao89wZTY/KDVvh69F/w/NIM2DGgIH5hpEanldAlBkfnbUUwcaODWWGmvCAK+oe9oq tqu5ByTR/EGnpwH90MmYHFLKQpYDRwhLDIzOUJXHBQ/4NeCdmO6+9WzhmXY7yHKU0Sh9 o0Qoh7Q7BL+UjYc4+8SNjBRJuagJ+Fk8GEtQk0uokganZTvatbrrwFvP5F+JbIfKkhl3 EI5rPaxnpG7zvW7XfCVu8sLfe0hLjhKVcLU6ps7/W9cdqpeFZLHgR0pkTK/iWYGd2/Lx jobjo9K47qaeD8sVmhHBr7/AwailPdR3pwWA3iavnk8xk0ByoBaD/8IZel0It8809U4+ QJzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709341210; x=1709946010; 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=bBWDWJvSshoSjEVW3Suakt0O9q+vGDdTpywx5NXn+PM=; b=VrIWwZ5ysfTuWj+CJcdc6Yqce4A5qP7KAi1O00Qvau3ejB/YYu5zU3KJBjimeaJ3zK WWqyIJaDr7zXsjVbfrOooyT2hz+PKF7OJ7HLzyJHmIU8QOQVQA1TEBVtg6V1aJ3qdyiS H/FGp88MsT+UGGSpeoPpb9cjICrTuo1c0X7b7sbAssliOT2/eSMAW4LJQVZv7jXwonyT hYyCWnytT/UF0KcPdWMWmWxBPzDWCf8byYYUUBO+6SNCRI5ic6e+W9+I/h2TeVNulj0x alCvEbCpN3G+h5e1q13u4Jn8HB0cikmLqhS+tQrNClDKMkRobtBC+CVQSzHkJqODQi4K sRNw== X-Forwarded-Encrypted: i=1; AJvYcCUzfRF4EEaOTCHtXFBWZmAz+SYRw4f0SJduESd5PgYfNmEvfeROprH3e38JP6tgEB+8Lds0uWlqRVaGUNKh+QFbrZECeGO2sD1m6/eP X-Gm-Message-State: AOJu0YwQhpb8VwUXgiG6wxvOZ1w65ngFhDB20SVUeWwbCHwZHxDC7Mc0 lTyFxibLunMHhZLw/euLU6qfWYR0W7u4ePnyDaSxl2eGxp40fXuwPVA4wXIrQ6lRrO3h/VpLys9 aigelAg== X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:aba7:66c5:3365:7114]) (user=irogers job=sendgmr) by 2002:a25:dbc9:0:b0:dc6:dfc6:4207 with SMTP id g192-20020a25dbc9000000b00dc6dfc64207mr714766ybf.10.1709341209852; Fri, 01 Mar 2024 17:00:09 -0800 (PST) Date: Fri, 1 Mar 2024 16:59:43 -0800 In-Reply-To: <20240302005950.2847058-1-irogers@google.com> Message-Id: <20240302005950.2847058-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: <20240302005950.2847058-1-irogers@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Subject: [PATCH v2 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 , 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" 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 = re.sub(r'0Event\(r"[xX]([0-9a-fA-F]*)"\)', r'Event("0x\1")', py) # Convert accidentally converted scientific notation constants back - py = re.sub(r'([0-9]+)Event\(r"(e[0-9]+)"\)', r'\1\2', py) + py = 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 = ['if', 'else', 'min', 'max', 'd_ratio', 'source_count', 'has_event', 'strcmp_cpuid_str'] for kw in keywords: diff --git a/tools/perf/pmu-events/metric_test.py b/tools/perf/pmu-events/metric_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 = before self.assertEqual(ParsePerfJson(before).ToPerfJson(), after) + before = r'a + 3e-12 + b' + after = before + self.assertEqual(ParsePerfJson(before).ToPerfJson(), after) + def test_IfElseTests(self): # if-else needs rewriting to Select and back. before = r'Event1 if #smt_on else Event2' -- 2.44.0.278.ge034bb2e1d-goog