Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2475770lqp; Sun, 24 Mar 2024 22:28:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXMgXKtRAnDV+Ov6/AAmuIzf3DgVvBwTvkXLpxzISCLe48SH8+vpr5SAL1/KsTusC0a1htqj0kHwvI5ta+AVi3UpYCFrGSDTuj0oxqJuA== X-Google-Smtp-Source: AGHT+IGw5UTGgf3U780kAqIk6v/THSl9eNmuzmxChu0bJ5mvFED4i66Xc9PfxtpjBN+UIIdkKyVs X-Received: by 2002:a05:6a20:3d07:b0:1a3:4203:d518 with SMTP id y7-20020a056a203d0700b001a34203d518mr6242177pzi.7.1711344497205; Sun, 24 Mar 2024 22:28:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711344497; cv=pass; d=google.com; s=arc-20160816; b=ruO8w3cqF1TUQ54biEqN7AMmYrIkASDE985qBF9W+bha76waL4JeS6wVk+qJZllmV+ fD39T4J9RBrhkQBPRl/KIT3HlG9hYbFurMoCGDr/Q/iGLNCpn0X33eEohb/b7arCschw 778nc06XJMDYWKI4iV4aYohwpPcYtAxqkKQeXmrSLGKSoeBpsSlIZuzs4ljJ/JktVFw5 YiQo9yEX1V/To2mjHO559e7YbBFiHfipsPDcp2T2d34sCAG62s5i2UKmzIxbuK5G69bj 1qau5HzD4RUSywxWd1bt0idMMLbtfj++xb9xH+Y6Ix2atacVcABp/9wpP5funofPiBZS rygg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=cunw+dcIw7GGQg4q/iBcTGlwiv6m1cc/0mvbIHDOZ6Y=; fh=Fc1ZoZ1vTp7JxUZvOdwuMH0+wZ16tuMxS8CO2DXLMx0=; b=w4CyRfuiTZp2OLE4pGucg9NJtDjzmdcQ0dx55ECaYDTBVr2SWzU8zOb+WZn0H3cuMn +Bvsrf9ZLL++RCN1wM8jtM1AIsFbDGZxWnMbv+dWFEMD2j2XymK4E3NqqEwOepv6XIf0 1ncW7fdyjbwzkXujx3hojEUAFl5XeJrfnJFOo0E6k51gCjPnoCFmFq6r4AzdMNyt84ah bh3f1OR2wwV1qBitau1fy3gZsDXonyFPPijHNdqILxJ3lu7KtOJtIwsZFMpYkTWh0CmN dg1bAINrrXy1EhzmTn5/uAoCaqJVO/qybzAUECsjVDS54J7MCQ6YJC8pT8EIFBKTaTwy LUmw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mQuUhfXK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113853-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113853-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. [139.178.88.99]) by mx.google.com with ESMTPS id s8-20020a170902ea0800b001e083472790si4762390plg.459.2024.03.24.22.28.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 22:28:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113853-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mQuUhfXK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113853-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113853-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 622F828E779 for ; Mon, 25 Mar 2024 05:26:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 119AC1369AC; Sun, 24 Mar 2024 23:05:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mQuUhfXK" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 533A31E8E58; Sun, 24 Mar 2024 22:54:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320893; cv=none; b=eCkUO6nyFP3wrg6nkJeNngaROwGrnZO99oajUBi0vXTBjVZlMFWJGm74MNnG+NxfgT7ZuUkYgZ/FCN8br1lHWu00P3QRcGHGzL3ciDMRPj31tCeDVMpbYdDixMb1xnEG5CyrcGSgkgGVv0WIlHOfoNPJTH3bagtQ6RRv7Q1i2+g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320893; c=relaxed/simple; bh=V4NVh05WyemHL5wZcJ0nlItQbZj2IaY9CQKDxk9qkGg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AAKIUpj3gi1xGc81HSqIoKfkXN7x6K7dgX1jbe2HuEd+O/ZmBhSwb0yKIiYKccVxJuVOOd3ANwEYs9JC3UdWFLc6rxs8FAAhAfJOXGeNJjhwsFUYVzOroudX7MFt3G/T9TiMPPhC4q4Ly0FlpTZ04cQq80Snl6guHxwShl+pzkQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mQuUhfXK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0555AC43399; Sun, 24 Mar 2024 22:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320892; bh=V4NVh05WyemHL5wZcJ0nlItQbZj2IaY9CQKDxk9qkGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mQuUhfXKlk9cX9FuU/puVWBAuw6WLSNeD9u5M4SKPO8C8TgHafQ2/w3khGTX81Eny JFMTclhj39GAnnOybZ+5HZwwEX3vgPefDMjlUBtPfS+AA5mR3PWXqI67sih2FZz5ha mjEmM5EaTKShHx2xBDrbw+APr6AW5baayN2dubjZajzpE4oVZ9qOYrARQEvNmgMx4/ TioKlVS4qHHnHsj+b81lnPmqhUMtAajwZVRNdRW5UuLnK8eExUIOI552XBB+BFDC8O o4JHoxLbilJwjj2rL+fdxzCf/HlQ12JvBa9dsyyMIZ6UkL3MAhQX5CcgyWuX58uIhk 12NQ/dC0bOlNA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ian Rogers , Kan Liang , K Prateek Nayak , James Clark , Kaige Ye , John Garry , Namhyung Kim , Sasha Levin Subject: [PATCH 6.7 456/713] perf expr: Fix "has_event" function for metric style events Date: Sun, 24 Mar 2024 18:43:02 -0400 Message-ID: <20240324224720.1345309-457-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324224720.1345309-1-sashal@kernel.org> References: <20240324224720.1345309-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Ian Rogers [ Upstream commit 6dd76680b925228312756c13b9b983661b552a64 ] Events in metrics cannot use '/' as a separator, it would be recognized as a divide, so they use '@'. The '@' is recognized in the metricgroups code and changed to '/', do the same in the has_event function so that the parsing is only tried without the @s. Fixes: 4a4a9bf9075f ("perf expr: Add has_event function") Signed-off-by: Ian Rogers Reviewed-by: Kan Liang Cc: K Prateek Nayak Cc: James Clark Cc: Kaige Ye Cc: John Garry Signed-off-by: Namhyung Kim Link: https://lore.kernel.org/r/20240209204947.3873294-3-irogers@google.com Signed-off-by: Sasha Levin --- tools/perf/util/expr.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/expr.c b/tools/perf/util/expr.c index 7be23b3ac0821..b8875aac8f870 100644 --- a/tools/perf/util/expr.c +++ b/tools/perf/util/expr.c @@ -500,7 +500,25 @@ double expr__has_event(const struct expr_parse_ctx *ctx, bool compute_ids, const tmp = evlist__new(); if (!tmp) return NAN; - ret = parse_event(tmp, id) ? 0 : 1; + + if (strchr(id, '@')) { + char *tmp_id, *p; + + tmp_id = strdup(id); + if (!tmp_id) { + ret = NAN; + goto out; + } + p = strchr(tmp_id, '@'); + *p = '/'; + p = strrchr(tmp_id, '@'); + *p = '/'; + ret = parse_event(tmp, tmp_id) ? 0 : 1; + free(tmp_id); + } else { + ret = parse_event(tmp, id) ? 0 : 1; + } +out: evlist__delete(tmp); return ret; } -- 2.43.0