Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2386241lqp; Sun, 24 Mar 2024 17:07:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUSPSQqwCHNkcFxYREkJ1DDHIw7xxYsaZuxRZ2GOM6Ubk/C5Cf+yY/9SzDnaIEnVaavChCfU6cOozm9d0fcCvMcK0sMscU6Z9W5HV7VRA== X-Google-Smtp-Source: AGHT+IGRtW7JT3QUEg3mY3fi05otSEcbCSiG0tg/MBi5l5ke/sLcoO49PZeZ48eV8mOOrHHoI01G X-Received: by 2002:a50:8d05:0:b0:566:fbf5:a279 with SMTP id s5-20020a508d05000000b00566fbf5a279mr3544669eds.20.1711325278228; 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=jEDRaL4eQF0U6Rdjjpq+iOkxwDKhaFhVFipjJZzTfS4JswS0NdjfJQNGY/K4JMvfTT THrNmOXVsKTTpR1eUUEsI5cYGTRdMhBWHZVGG7t/GMLGc5pXnHDDso7FaHuQvAqzV/eS pXmkZgyATzq90zXgRXOEJEqlQqfHWeTovMLFTsjzgBPDSzM7GS9F0nRx4YLf+Ie0I6lQ a66SPAEBYz/uab8+6wvBeZj4rXiRFWa1H3QrgOp1OY8kWyZPOYVsdwKgx+sdQqhi1cy/ wWIO/7/AoicjKgNwSP08t6tggjsJ/hswhAxFaXezx0EA4jwyNBkqROvDzpSAH2eWajFV c7HQ== 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=kHR1ltAedo/8Sf8DypfSMdu9WX47ylYIew3qjk0aJjo=; fh=mgT1heFYpQXkbTjhyoNB7yaE6bjjEaPZ7Q9eZBoIQQE=; b=hFi5PqZD2yZQD7RfpB5x1Ku09El4hYcMNeFYdZz6XPKWUuOp0+EVXZIt6sZw9AirHQ sfGxAeFtjjc2jckpm+WmX7lobKErRTUCfjOIvnI2NNPffjjgDr0VFmfAMokrur5sEYjr v/+c61gbehYcJbuAINSuj8nDL+dvSB7V9Fwq7QXnwZNFd5a6+6WmlqKC99IPbHUIO4q7 9M7Ay1SeYNo87audMZb4VHCdebkZDuuQLcLzBNYQJaGCisSh+Wk7CgrLwWB3GaRPIs7d xJZpTXoHsfJ8fKvOWxlLFCMAhyfLI/frZ21h+fXf0XvRP9JJAu2pufcORVVwOuMeSCmU M3tg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eJ0a3hUy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113270-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113270-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l16-20020a056402255000b0056bce212581si2062284edb.97.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-113270-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eJ0a3hUy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113270-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113270-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 7632C1F238F9 for ; Sun, 24 Mar 2024 23:58:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7C00667A0A; Sun, 24 Mar 2024 22:41:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eJ0a3hUy" 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 90F2E18A709; Sun, 24 Mar 2024 22:41:10 +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=1711320070; cv=none; b=CWrO0v++ODsNvA/cz+IPWzPm2N1luWrfqy49w6pGHNS46rT8mCXt0GaX7pDeAKcAlvU5bRo7tqDcNErTYk7EO87kM7PNLd53lnJS6iFjczGM8ru3guFqxaMC5qN2hbG0cVmizotQeqHH7IN9f0oSFgC5xLPkDhYJSl1SID4q1kY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320070; c=relaxed/simple; bh=MqLeLz/RiB5JWBEgcZw3fmstetrs49NWUuOfQE+Oe1E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GokntsAQ0RUiW07v7RdHelCLdH6Ge4s7HSfW3pzD2bWQkKt9N8HqYPVrzjX9p+h6V2pCuLD0muk4IFss0M+z330kpADpizdf1Yl3LzULc/x+F7ty82v1tT6JXQpqbThFA6eYr8E9vnS2tHonwY3b643EmRuERi4zz3VD9n+QIKk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eJ0a3hUy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21FFAC433F1; Sun, 24 Mar 2024 22:41:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320070; bh=MqLeLz/RiB5JWBEgcZw3fmstetrs49NWUuOfQE+Oe1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eJ0a3hUy4o4eBUBbjSw6YY2FE+sQh7ZcLTEzlTNPdP5LGqQtCk8NKJo8GG1rBkXup 0Eyb3zYT80YTtVVg3ExARVWHUXHCvprn1hJVKo00vj6YH9mfxKrWUq0pnJGzkscTo6 UWOgyigyfuvO1jGZQYY1HH5BoWS9AW/Vn5iGHhFbsXH9vj4EYM7ru7bgDphJ5xC92q Xn48nFt9DYYhT1f2Sw7dl17w3qfwDrI+5c2dkbjiv8wbh/o2xlUw9WCmCO/XnSkWrG qPG5qSc3abiLYq8XWS0y7u1nyLXATJpMDYJENje9aZOIp8lZDL7NPrJgJ9HsobCyWB z3HGUlrJUPDKA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ian Rogers , Kan Liang , James Clark , Caleb Biggers , Edward Baker , Perry Taylor , Samantha Alt , Weilin Wang , Namhyung Kim , Sasha Levin Subject: [PATCH 6.8 379/715] perf pmu: Treat the msr pmu as software Date: Sun, 24 Mar 2024 18:29:18 -0400 Message-ID: <20240324223455.1342824-380-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 24852ef2e2d5c555c2da05baff112ea414b6e0f5 ] The msr PMU is a software one, meaning msr events may be grouped with events in a hardware context. As the msr PMU isn't marked as a software PMU by perf_pmu__is_software, groups with the msr PMU in are broken and the msr events placed in a different group. This may lead to multiplexing errors where a hardware event isn't counted while the msr event, such as tsc, is. Fix all of this by marking the msr PMU as software, which agrees with the driver. Before: ``` $ perf stat -e '{slots,tsc}' -a true WARNING: events were regrouped to match PMUs Performance counter stats for 'system wide': 1,750,335 slots 4,243,557 tsc 0.001456717 seconds time elapsed ``` After: ``` $ perf stat -e '{slots,tsc}' -a true Performance counter stats for 'system wide': 12,526,380 slots 3,415,163 tsc 0.001488360 seconds time elapsed ``` Fixes: 251aa040244a ("perf parse-events: Wildcard most "numeric" events") Signed-off-by: Ian Rogers Reviewed-by: Kan Liang Cc: James Clark Cc: Caleb Biggers Cc: Edward Baker Cc: Perry Taylor Cc: Samantha Alt Cc: Weilin Wang Link: https://lore.kernel.org/r/20240124234200.1510417-1-irogers@google.com Signed-off-by: Namhyung Kim Signed-off-by: Sasha Levin --- tools/perf/util/pmu.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 3c9609944a2f3..88b9aa7d3a27a 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -1760,6 +1760,12 @@ bool pmu__name_match(const struct perf_pmu *pmu, const char *pmu_name) bool perf_pmu__is_software(const struct perf_pmu *pmu) { + const char *known_sw_pmus[] = { + "kprobe", + "msr", + "uprobe", + }; + if (pmu->is_core || pmu->is_uncore || pmu->auxtrace) return false; switch (pmu->type) { @@ -1771,7 +1777,11 @@ bool perf_pmu__is_software(const struct perf_pmu *pmu) case PERF_TYPE_BREAKPOINT: return true; default: break; } - return !strcmp(pmu->name, "kprobe") || !strcmp(pmu->name, "uprobe"); + for (size_t i = 0; i < ARRAY_SIZE(known_sw_pmus); i++) { + if (!strcmp(pmu->name, known_sw_pmus[i])) + return true; + } + return false; } FILE *perf_pmu__open_file(const struct perf_pmu *pmu, const char *name) -- 2.43.0