Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp902304lqs; Tue, 5 Mar 2024 23:21:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWs+QYgrv5RvcXdB+gyxIgTLFQKaLJhgPNlXjwKLHZ6qXDGgjl0ZbAAo89JFUo8hDOPPaT6G4hKpuTuw6vWEp+x9EJMVHp19uuOzIrTqw== X-Google-Smtp-Source: AGHT+IEbGSPIGJ8rttn+CsL1/ADt8jLuGKfQAZN8F25gRpUgR/0sdgXpeayGCjFw1jS1V8JTwCW1 X-Received: by 2002:a05:6830:8:b0:6e4:dc5a:48da with SMTP id c8-20020a056830000800b006e4dc5a48damr4704677otp.5.1709709693042; Tue, 05 Mar 2024 23:21:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709709693; cv=pass; d=google.com; s=arc-20160816; b=MGECiVn8vWW/bqQj4rWxRI936dPKOaEoAeZF/QQrBbYuC2ZNT8hFbJrVMr5Qu+66/G NxOrusJllRlFpUSXY6TKqNLHYqFqMoaJXuT6Kr3EyIBu2BGtp1z3ta/4l0YUfotUahzx C0GSntsAcYVuPW6ppfT8NxxccieV1/iAaOvRFgNxDM7+XIZXtv2pVXED3ywYl60/v19+ dRhGcCuOTDqsjta0iOPxQcK2wEp6trGGJPjMGEq2c5usyilpgsBdYuQvMmRdryrTT3qJ paB+tci3vZgvxMbLT04OVDRe0X8UNb+KIbZnJROh0rvFExSOmbSwQtlT+2lv8fthS5ee JrFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=tQuWM38UhwK25qNu10dyRUtuaAMUFqlAh3c+JZ+R14g=; fh=0KwnZKSW9FlRn84Ymz05mmGaZLwNx+WjlR6tRlcVKVI=; b=Hxz8uf4BYkwCOS4X0QJtsWbDL7hEfCNdW4Ef63nbXCrqtwdOWbVnwNsUIrEgdiQCKz Mpg2E98GUKaTQo/XDUGULP03/7sZlygeOIy4Uv25/IsxKJOqw0aJUK5OlpNuJtd4PSTd VmMSo5fRcH0PnT5LaKPuf0Y1piCcTKrDVcJIBdtv4uQiNF4/FUVUpoTKpYKDHkFXdmeI 5KaDYVKQTY8CiZKqqXCH3yvktgu2Qlmc0PA+vw2rAa64xHI59bmbc1Vqitr6VQza3fVb q77c12EuJBXeu0f474Y/qNrc7whsZsqpqbyJbjTCwurE/FgD7G1o8TQxooNoWMd1JTHa tCFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-93420-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93420-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id b10-20020a631b4a000000b005d8e352afefsi11503829pgm.695.2024.03.05.23.21.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 23:21:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93420-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-93420-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93420-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B0013282F45 for ; Wed, 6 Mar 2024 07:21:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1842C5CDC4; Wed, 6 Mar 2024 07:20:59 +0000 (UTC) Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (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 0BD075C8FB; Wed, 6 Mar 2024 07:20:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709709658; cv=none; b=MVthmyQ0Up3liCWOImwQR6FzvIu21k6NBLJYTueMjJkFMduNw5kzSR6BqNXO7HzevB+I1n/gUVeKJRnaABsh4yulozzTZeoPajA/Skt7CROm2EO7407hfNeGfpDtc51ZuIcV8qv+4gPKNgo0iiWHmQkYLaYKlPH0UC3YL/PraB4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709709658; c=relaxed/simple; bh=L5mJ15rIwi4rFnSttjgMuyaksPH2SXNe2fdObsvQezc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=lyEvd4Onu92Mr/wiZf/6JIVNmc/aPe4J4GswSVJbCnp3VRfLBWCLj5hJpTib+wgLFoQj8NGKaVpFu6X2QqM6yls+voqcnAZAOf7icPLpPXguUMT1+XhP7lSYMC2EPWe3wFHKOQiTKwNaKq0fudhwPVndct5aQAXqUgKupG5xP9Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.167.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-3c1e6c32a55so2141047b6e.2; Tue, 05 Mar 2024 23:20:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709709656; x=1710314456; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tQuWM38UhwK25qNu10dyRUtuaAMUFqlAh3c+JZ+R14g=; b=suhcAnIDXoZR8kRqFKLz2CqYpRKuP1td9+nQBDhhNsAUda3e5yCxoFnNu6X6ZvJgnA Mcn5ErsoYP833Orxs4shxao6zZ6XfjQ9qxnapE5ZIbyjit5zkRXmTB5VvMCD/RRRZcId fav8IqqD6EzSrT0b62nfKOYgl2wOJRqpJ5jnGvSuaJj0Ne78Z9V8FuoJmUWBSwUB1x0k RBmgO9FEtqQuVEAHsrbPq3nbyoohQW4XeCcMjFyJLwDbI188aWDNNJn6fTzxS9HQKqQa WXRx4Osjrfp+8q+Vn5tAWa277pn3n8wVEhKmFs6QZEHZpz5aqbieRIBwMumdS7LtFZLE /Mdg== X-Forwarded-Encrypted: i=1; AJvYcCXAVvH2/1oAc33bXJtgdXYDowV2Tb/RUxgZCr8OLsoBM4AP6t7r7SYW+I1bcJGEZsdOwV9ngY8TqfQypJppD7+FoXBrLFOmR42DaIPUSJhMF2sr3Ey6Nq6VkPn2J2njVC887/spyaa4aYR9sQj3Iw== X-Gm-Message-State: AOJu0Yx6DIbsUsFIusCGWsKK0SbLmJ2RJYYlkIFhCuneEHuu5PGIFfb0 Bvma0dx4xfnGPq/r7nC0bav9NWp16l8dsaZz8LeXPhHPb0PjsWgrr9Q+Z6U3n3rsJSG9D1q0fcb NMUuP57tQ5sAuyIf59N1Yz+EnOeY= X-Received: by 2002:a05:6808:2817:b0:3c2:1944:e39b with SMTP id et23-20020a056808281700b003c21944e39bmr1579254oib.17.1709709656039; Tue, 05 Mar 2024 23:20:56 -0800 (PST) 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> <20240302005950.2847058-6-irogers@google.com> In-Reply-To: <20240302005950.2847058-6-irogers@google.com> From: Namhyung Kim Date: Tue, 5 Mar 2024 23:20:44 -0800 Message-ID: Subject: Re: [PATCH v2 05/12] perf jevents: Support parsing negative exponents To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , 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" Content-Transfer-Encoding: quoted-printable On Fri, Mar 1, 2024 at 5:00=E2=80=AFPM Ian Rogers wrot= e: > > 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/metr= ic.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) I don't understand how it can handle negative numbers. Why isn't it like Event\(r"(e-?[0-9]+)"\) ? Thanks, Namhyung > # Convert all the known keywords back from events to just the keyword > keywords =3D ['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 =3D before > self.assertEqual(ParsePerfJson(before).ToPerfJson(), after) > > + 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' > -- > 2.44.0.278.ge034bb2e1d-goog >