Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2386248lqp; Sun, 24 Mar 2024 17:07:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXtJLnstevjdzw072B8z4cLPuAj8dBLNUr3OmtJTsCl2r3yqkd89dQz6+I8ETlawCSfgwx4WZkWI9fTzQLapaioz3NZv02/sTEHn39bMg== X-Google-Smtp-Source: AGHT+IF41v96NFL4381Gb+h4MGCbG+cpTpwdVP9UFhUCYvTZIygHxqnLVYA24iduxrCJZp+sD5OQ X-Received: by 2002:a05:620a:22ad:b0:789:faed:fcb4 with SMTP id p13-20020a05620a22ad00b00789faedfcb4mr8270518qkh.21.1711325278770; Sun, 24 Mar 2024 17:07:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711325278; cv=pass; d=google.com; s=arc-20160816; b=KHxK5NlACml5nieqDK+bKgPeaOL6Y8/5/Yr/LD+6U/Qot4bG5rr9WZtvetifAqmEBU rSNHj6HpkrXHz5VXABwGGd8ZC7Or2uvMoXqbRANyht7n9Pr3IQ10zaAFxS5FgEBszC69 U5/ZI4Ib9T1SNcql7zAMmg+SYpswP2XBNJZiAzfdBBh3IJKPH1gytpyaNndbqp9Co9Ci nm9vyp1xDKwuTmvQ0u+6Yt9tdWKKQlxhp/3mTUsFcaVRNWVpkGQZUp2pXh6nTc75Xcug aYhGrPBHeXwRKr6aTtKGKYMgR8tZZkHG16lQix3yqzsIbn8Cvj+0/0UrSlKxOTmg7RLk uLlQ== 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=wr42a1YMoFXKg8cDEEs68irJBTINp2cnRMZTl20CcyN4PBruRe4bSP3+S9XofTN30U OWuxMfILtMWr4FjDj7VsSSePOg4w/uU+auupLsNlI364fIwpQZDvwe26dGjj3tWXYqFj 8B7fcUQxSgy/Z6q0kuxziQU/VUYWRgAZw7eLNgCzC3dZSxnFX+Kcm/M9zinIQv1dNQ9e 8Gx1UaLAGhzGqt3+cYTk+uDayYUxeX3ynpMsxD5enSKFp88A5nFRH614eQZ00FP+c9p2 hflWIlubyYcaMhnUQkg15cFtIHKYhhNa/sr+f7pxVSM9JiizkHd2rsJnIQ5P1b7O4Hqi XBig==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gugv2NKf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113315-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113315-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m16-20020ae9f210000000b00789f10fc736si4384626qkg.135.2024.03.24.17.07.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:07:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113315-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gugv2NKf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113315-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113315-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 7D6DC1C236D2 for ; Mon, 25 Mar 2024 00:07:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30F6C193878; Sun, 24 Mar 2024 22:41:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gugv2NKf" 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 4EA6319386B; Sun, 24 Mar 2024 22:41:56 +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=1711320116; cv=none; b=ZFLbcgw82RgjnA1TgbgnDN+Pko391Fg5uNAWn96cgtRrcXgjI3T+nD9SxPYqYLJKfcAw+7atibCygW88EyH3E7pv6hKpw3o2XQyLXCX4vFG7Vyybosk7OdJbZmr+vek7rNP4Q5Cv8vmuYHh3FeuMHDUIVa/p8AtCNahJSoaROdU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320116; c=relaxed/simple; bh=V4NVh05WyemHL5wZcJ0nlItQbZj2IaY9CQKDxk9qkGg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nBO2rwy9D9zRbVVoJAsxTcpxCH8VjvLXhaM1RtnL/VXt3Oon700gHSvr9BUtmPpU4X81efF3WrJXw3iXTAQ2bgzI0j32W+VY6oSaId2z7v1c4W3tlAaMvOs+tTgHc5jQ1Wkpu+TjdadJbzSnVuKsybidVClYsTi8qn0q0Yu+7d0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gugv2NKf; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0534BC43390; Sun, 24 Mar 2024 22:41:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320116; bh=V4NVh05WyemHL5wZcJ0nlItQbZj2IaY9CQKDxk9qkGg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gugv2NKfq/P3OVxFqv7xVDC27l057Lgh1Kkm8jfdKBRiGpT5ASC0mPfVOYki+fTgK gZ4wTN4YeI6hS7DvDoM/fVn0gEvdhPz9a3xt3JbsNyFh5+iTBNvjBMNxe4Xbovh/lT jmSYDx24I2iT0vwC050pLd2BJsUHciUZTJ1w7nPWNnyRzosKmh3VWMorAb5JR9b3Kq uH2jTdO1CE+h/f2rdXCGmvoYE6G+8wPEGWLWMfHMWS+L9H5gHJzIPqllM7m++/W/PA PUy4YHxKIGjpgxPNnuRJ/XwcWDXzW6/sHBVIZhx+mqaK7gEe4PXRUZz0LEXxpDz3rE Bva3zx1iHMAbw== 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.8 424/715] perf expr: Fix "has_event" function for metric style events Date: Sun, 24 Mar 2024 18:30:03 -0400 Message-ID: <20240324223455.1342824-425-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-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