From nobody Wed Jan 15 08:03:46 2025 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 48D8819DFB8; Thu, 5 Sep 2024 20:24:28 +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=1725567869; cv=none; b=iemo3NvtKe95YKB9cgInw0+DkB5ORI/BfOzfxMCewPYpSP60IPIQ3WrPBx9/pPTmtVWM3H4q4nnc+weHrLezBKOiw6ZNqsiwpBHpmbbI3w94G8wsszYwd2J55WS5rCBjgAqo5ceM9YezXgkerGO/86FQc50N+R8r8FPFJ9gngcc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567869; c=relaxed/simple; bh=zz+ySZgl+pIeh+EpjXnttIluXk7iAW08LlNQv9LsfNw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=czfF+t35PRfYVR8RwALsVRtSLlhfwh7uED8ZWAD0wRwLsop+wBJeJqyywE5tSkp/KBnEHtu7zUtrHETGl/RzKVluyx7ySyIzHQod4Xt3mTN2VNBTYAynszIixuWdHuuGbN2QYmjJwG8jFCiAmSiB5q/NHFZYPNMAdKIs7OXjGDo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=F7Gpo4aL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="F7Gpo4aL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C129C4CEC4; Thu, 5 Sep 2024 20:24:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725567868; bh=zz+ySZgl+pIeh+EpjXnttIluXk7iAW08LlNQv9LsfNw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F7Gpo4aLn3769GgnX8et58GnBGuZ6WfzEOm+74jViYooOaJxVBT7PgDAzzbo6fG/K NHpTUy3huuVq7lU/JCfXYfCECuFT0dq73It92V4AEV8/mV7Xa1Z7qLFd2DrdwcatU3 SSplkOggu2NEtNuw2G0jpMbzr1YYBpbSMN7T5fc4US6o2BLKLV9IXca+rtNdk1U3Dp lAVjB49AGRtFqPIVVJwKr9eehkHJzaiBHLAm2L39GBElJr6wat4+iGuiyUwA9j7btX IRbVbpB4HVNSr0JLhR876n0XqR2iEGXbyMV/BOv8GO2ickFWreEUyAw41vmTs+oQIT VA4/ng3Cx/1Gg== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Ravi Bangoria , Mark Rutland , James Clark , Kajol Jain , Thomas Richter , Atish Patra , Palmer Dabbelt , Mingwei Zhang , James Clark Subject: [PATCH 01/10] perf tools: Add fallback for exclude_guest Date: Thu, 5 Sep 2024 13:24:17 -0700 Message-ID: <20240905202426.2690105-2-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240905202426.2690105-1-namhyung@kernel.org> References: <20240905202426.2690105-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit 7b100989b4f6bce70 ("perf evlist: Remove __evlist__add_default") changed to parse "cycles:P" event instead of creating a new cycles event for perf record. But it also changed the way how modifiers are handled so it doesn't set the exclude_guest bit by default. It seems Apple M1 PMU requires exclude_guest set and returns EOPNOTSUPP if not. Let's add a fallback so that it can work with default events. Fixes: 7b100989b4f6bce70 ("perf evlist: Remove __evlist__add_default") Cc: Mark Rutland Cc: James Clark Signed-off-by: Namhyung Kim --- tools/perf/builtin-stat.c | 3 +-- tools/perf/util/evsel.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index cf985cdb9a6ee588..d8315dae930184ba 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -639,8 +639,7 @@ static enum counter_recovery stat_handle_error(struct e= vsel *counter) * (behavior changed with commit b0a873e). */ if (errno =3D=3D EINVAL || errno =3D=3D ENOSYS || - errno =3D=3D ENOENT || errno =3D=3D EOPNOTSUPP || - errno =3D=3D ENXIO) { + errno =3D=3D ENOENT || errno =3D=3D ENXIO) { if (verbose > 0) ui__warning("%s event is not supported by the kernel.\n", evsel__name(counter)); diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 49cc71511c0c8ce8..d59ad76b28758906 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -3244,6 +3244,27 @@ bool evsel__fallback(struct evsel *evsel, struct tar= get *target, int err, evsel->core.attr.exclude_kernel =3D 1; evsel->core.attr.exclude_hv =3D 1; =20 + return true; + } else if (err =3D=3D EOPNOTSUPP && !evsel->core.attr.exclude_guest && + !evsel->exclude_GH) { + const char *name =3D evsel__name(evsel); + char *new_name; + const char *sep =3D ":"; + + /* Is there already the separator in the name. */ + if (strchr(name, '/') || + (strchr(name, ':') && !evsel->is_libpfm_event)) + sep =3D ""; + + if (asprintf(&new_name, "%s%sH", name, sep) < 0) + return false; + + free(evsel->name); + evsel->name =3D new_name; + /* Apple M1 requires exclude_guest */ + scnprintf(msg, msgsize, "trying to fall back to excluding guest samples"= ); + evsel->core.attr.exclude_guest =3D 1; + return true; } =20 --=20 2.46.0.469.g59c65b2a67-goog From nobody Wed Jan 15 08:03:46 2025 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 C95CD1A2566; Thu, 5 Sep 2024 20:24:29 +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=1725567869; cv=none; b=KM6l31Isr1ZHt/n5WM1akveNZBcH/j4iMBtikCn8LNj04ZgX+KE6mDEYdKBigGNYBxcGwR6B3sNKTio1T3NHVF+yBDe9XSLdGOeTduJM18yP65DNl7ewdk49+TD0QWiJUO/IAJYERBUOnOyvnU8i/bHPPmgdASmwyxABXcy1PbE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567869; c=relaxed/simple; bh=gSUbaLQ7uvgo7tFBAaelNB7YgocEIT2lbiYgEKyd2wI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C7BuDYmyd+Itd5ecmnalHVy+Z17Sr6d9wicII0TkHzp8TQiI5KDM+h/iIOlD/GCd1YJsOYPtCp3H/EgjKGh3Ojn2SKFkDuS97DmBKp+03PznK5JtV0wQqSOIED06IJivy+IeDHNg6rz41TLYzc8w3/DesZREgEnaMYIldBZVTwc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OL8IWHSN; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OL8IWHSN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04BA3C4CECD; Thu, 5 Sep 2024 20:24:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725567869; bh=gSUbaLQ7uvgo7tFBAaelNB7YgocEIT2lbiYgEKyd2wI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OL8IWHSNmKRZzwHZFD/pjH7zFKKZvDW+FI8hdAVXnF8sEcECBMtSy3IQAXIWQrFPC 91JhU6USByAGMJRYKU+qJtt2D6CkYLZURkfqJO3EVITrzJeyyQ8Eyk0BRSpktW45v+ CFmpU2GwqPAJ2xNzbcofdsUKh4OQRrQYxMI7nvsq+Q2A2NfWmgWbCeqyqRQ78PRRzP 8+uosM3bsVHhfy8No20OJFa+tkRCnR+f/qJeMO0fZsvzYrlJA+8+lABH+eAt35lpwN JYeAeydXtbtTJfrp5BosW53ZRfqgPPY64JifwjzCI2J6X228RvDRyPsBo2mTrNVcyV 1j7AKpRfT6rxQ== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Ravi Bangoria , Mark Rutland , James Clark , Kajol Jain , Thomas Richter , Atish Patra , Palmer Dabbelt , Mingwei Zhang , James Clark Subject: [PATCH 02/10] perf tools: Don't set attr.exclude_guest by default Date: Thu, 5 Sep 2024 13:24:18 -0700 Message-ID: <20240905202426.2690105-3-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240905202426.2690105-1-namhyung@kernel.org> References: <20240905202426.2690105-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The exclude_guest in the event attribute is to limit profiling in the host environment. But I'm not sure why we want to set it by default cause we don't care about it in most cases and I feel like it just makes new PMU implementation complicated. Of course it's useful for perf kvm command so I added the exclude_GH_default variable to preserve the old behavior for perf kvm and other commands like perf record and stat won't set the exclude bit. This is helpful for AMD IBS case since having exclude_guest bit will clear new feature bit due to the missing feature check logic. $ sysctl kernel.perf_event_paranoid kernel.perf_event_paranoid =3D 0 $ perf record -W -e ibs_op// -vv true 2>&1 | grep switching switching off PERF_FORMAT_LOST support switching off weight struct support switching off bpf_event switching off ksymbol switching off cloexec flag switching off mmap2 switching off exclude_guest, exclude_host Intestingly, I found it sets the exclude_bit if "u" modifier is used. I don't know why but it's neither intuitive nor consistent. Let's remove the bit there too. Cc: Mark Rutland Cc: James Clark Cc: Ravi Bangoria Signed-off-by: Namhyung Kim --- tools/perf/builtin-kvm.c | 1 + tools/perf/tests/attr/test-record-dummy-C0 | 2 +- tools/perf/tests/parse-events.c | 18 +++++++++--------- tools/perf/util/parse-events.c | 2 +- tools/perf/util/util.c | 10 ++++++++-- tools/perf/util/util.h | 3 +++ 6 files changed, 23 insertions(+), 13 deletions(-) diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c index 55ea17c5ff02acf7..5e32d4e78fdf2424 100644 --- a/tools/perf/builtin-kvm.c +++ b/tools/perf/builtin-kvm.c @@ -2147,6 +2147,7 @@ int cmd_kvm(int argc, const char **argv) "buildid-list", "stat", NULL }; const char *kvm_usage[] =3D { NULL, NULL }; =20 + exclude_HG_default =3D true; perf_host =3D 0; perf_guest =3D 1; =20 diff --git a/tools/perf/tests/attr/test-record-dummy-C0 b/tools/perf/tests/= attr/test-record-dummy-C0 index 576ec48b3aafaa6a..8ce6f0a5df5b7013 100644 --- a/tools/perf/tests/attr/test-record-dummy-C0 +++ b/tools/perf/tests/attr/test-record-dummy-C0 @@ -37,7 +37,7 @@ precise_ip=3D0 mmap_data=3D0 sample_id_all=3D1 exclude_host=3D0 -exclude_guest=3D1 +exclude_guest=3D0 exclude_callchain_kernel=3D0 exclude_callchain_user=3D0 mmap2=3D1 diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-event= s.c index 639e65a9bf61801a..9077d581c0d05e62 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -933,7 +933,7 @@ static int test__group2(struct evlist *evlist) TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kerne= l); TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); - TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); + TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); @@ -948,7 +948,7 @@ static int test__group2(struct evlist *evlist) TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel= ); TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); - TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); + TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); if (evsel__has_leader(evsel, leader)) @@ -1073,7 +1073,7 @@ static int test__group3(struct evlist *evlist __maybe= _unused) TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); - TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); + TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); @@ -1223,7 +1223,7 @@ static int test__group5(struct evlist *evlist __maybe= _unused) TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel= ); TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); - TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); + TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel)); @@ -1438,7 +1438,7 @@ static int test__leader_sample1(struct evlist *evlist) TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel= ); TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); - TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); + TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); TEST_ASSERT_VAL("wrong group name", !evsel->group_name); @@ -1454,7 +1454,7 @@ static int test__leader_sample1(struct evlist *evlist) TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel= ); TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); - TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); + TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); @@ -1469,7 +1469,7 @@ static int test__leader_sample1(struct evlist *evlist) TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel= ); TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv); - TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); + TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); TEST_ASSERT_VAL("wrong group name", !evsel->group_name); @@ -1498,7 +1498,7 @@ static int test__leader_sample2(struct evlist *evlist= __maybe_unused) TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); - TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); + TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); TEST_ASSERT_VAL("wrong group name", !evsel->group_name); @@ -1514,7 +1514,7 @@ static int test__leader_sample2(struct evlist *evlist= __maybe_unused) TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); - TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); + TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", !evsel->core.attr.precise_ip); TEST_ASSERT_VAL("wrong group name", !evsel->group_name); diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index f5eb1af8302c7bac..8d9e2d4b73822d98 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1761,7 +1761,7 @@ static int parse_events__modifier_list(struct parse_e= vents_state *parse_state, if (mod.user) { if (!exclude) exclude =3D eu =3D ek =3D eh =3D 1; - if (!exclude_GH && !perf_guest) + if (!exclude_GH && !perf_guest && exclude_HG_default) eG =3D 1; eu =3D 0; } diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 9d55a13787ce3c05..7e3159faaa1991df 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -78,17 +78,23 @@ bool sysctl__nmi_watchdog_enabled(void) =20 bool test_attr__enabled; =20 +bool exclude_HG_default; + bool perf_host =3D true; bool perf_guest =3D false; =20 void event_attr_init(struct perf_event_attr *attr) { + /* to capture ABI version */ + attr->size =3D sizeof(*attr); + + if (!exclude_HG_default) + return; + if (!perf_host) attr->exclude_host =3D 1; if (!perf_guest) attr->exclude_guest =3D 1; - /* to capture ABI version */ - attr->size =3D sizeof(*attr); } =20 int mkdir_p(char *path, mode_t mode) diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 9966c21aaf048479..d33ae883a54f2f2f 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -21,6 +21,9 @@ extern const char perf_more_info_string[]; =20 extern const char *input_name; =20 +/* This will control if perf_{host,guest} will set attr.exclude_{host,gues= t}. */ +extern bool exclude_HG_default; + extern bool perf_host; extern bool perf_guest; =20 --=20 2.46.0.469.g59c65b2a67-goog From nobody Wed Jan 15 08:03:46 2025 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 7D51F1A42A7; Thu, 5 Sep 2024 20:24:30 +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=1725567870; cv=none; b=HKoYlEsgf6mxSJRbq7pOZZXnHqT91aaGoPojaqh1yHwffvbnvdKLUQfTSoIOa6Iu12KlTRtkzQ9INQOdklWKoyOnNFdPGFpFaUZcBkT3tIHao8jjxcFMSgUWRNOVP3d1VrQCmFupqK87qSDvjZxowLWqMAzO0Errrll8tW21NZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567870; c=relaxed/simple; bh=wso+JxsY3KSfA1BAeaX6+KdhvT3pN2ZRYs/u5T+ZYlQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mfkyceEFq86Nj4LG1ujbUnKyuHFWC115dW0/eO6Ww5mTSrmYX8ebRYLPHMr85OyedNw6a1p+M+6RyRekkY2jZYO9hT1GJ5wNoo2VVh2HRBclvKL1ie9AUmNKS1wx2AAmPJ7ElLhqvCdGF589ds1M6I1Ioo6vYWKSybAafCGV6kM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bDEpwQ1m; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bDEpwQ1m" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3556C4CED0; Thu, 5 Sep 2024 20:24:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725567870; bh=wso+JxsY3KSfA1BAeaX6+KdhvT3pN2ZRYs/u5T+ZYlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bDEpwQ1mtpoJQJxc9ep66eaRVL4q8eFrTKBe+CBU3Sl/N9DPBJDecvFRPul03+Piq 0BIYguosxu+xjs5LHpdr6XNHfCGn20U3ETSiydTG2L2IqZr8wcjR2yKcbeS56YHefZ ocKmj0EIq48s4xGyqQQNNX3xzLOlEMlnY0viBoelwDfVpCrz+cFaFjbk0VAFzqpamc J8pP31X1665MlH7Nkxsbkz5OkXO6R7pakJBGYx4Ngfs4aRX6L9781Rlj7VwZjvoVZd yqBfTurqFl9cntVkbetV/JChKVuXMYqYkpMzJVUT+YZ+IsTcwfp+7EjLXaoBZ8YbIw 0Zg9eqOvSlJkQ== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Ravi Bangoria , Mark Rutland , James Clark , Kajol Jain , Thomas Richter , Atish Patra , Palmer Dabbelt , Mingwei Zhang Subject: [PATCH 03/10] perf tools: Simplify evsel__add_modifier() Date: Thu, 5 Sep 2024 13:24:19 -0700 Message-ID: <20240905202426.2690105-4-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240905202426.2690105-1-namhyung@kernel.org> References: <20240905202426.2690105-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Since it doesn't set the exclude_guest, no need to special handle the bit and simply show only if one of host or guest bit is set. Now the default event name might not have :H prefix anymore so change the dlfilter test not to compare the ":" at the end. Signed-off-by: Namhyung Kim --- tools/perf/dlfilters/dlfilter-test-api-v0.c | 2 +- tools/perf/dlfilters/dlfilter-test-api-v2.c | 2 +- tools/perf/util/evsel.c | 5 +---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/perf/dlfilters/dlfilter-test-api-v0.c b/tools/perf/dlfil= ters/dlfilter-test-api-v0.c index 4083b1abeaabe605..4ca2d7b2ea6c8200 100644 --- a/tools/perf/dlfilters/dlfilter-test-api-v0.c +++ b/tools/perf/dlfilters/dlfilter-test-api-v0.c @@ -220,7 +220,7 @@ static int check_sample(struct filter_data *d, const st= ruct perf_dlfilter_sample CHECK_SAMPLE(raw_callchain_nr); CHECK(!sample->raw_callchain); =20 -#define EVENT_NAME "branches:" +#define EVENT_NAME "branches" CHECK(!strncmp(sample->event, EVENT_NAME, strlen(EVENT_NAME))); =20 return 0; diff --git a/tools/perf/dlfilters/dlfilter-test-api-v2.c b/tools/perf/dlfil= ters/dlfilter-test-api-v2.c index 32ff619e881caa50..00d73a16c4fdaece 100644 --- a/tools/perf/dlfilters/dlfilter-test-api-v2.c +++ b/tools/perf/dlfilters/dlfilter-test-api-v2.c @@ -235,7 +235,7 @@ static int check_sample(struct filter_data *d, const st= ruct perf_dlfilter_sample CHECK_SAMPLE(raw_callchain_nr); CHECK(!sample->raw_callchain); =20 -#define EVENT_NAME "branches:" +#define EVENT_NAME "branches" CHECK(!strncmp(sample->event, EVENT_NAME, strlen(EVENT_NAME))); =20 return 0; diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index d59ad76b28758906..dadcaf6e37063dfa 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -548,7 +548,6 @@ static int evsel__add_modifiers(struct evsel *evsel, ch= ar *bf, size_t size) { int colon =3D 0, r =3D 0; struct perf_event_attr *attr =3D &evsel->core.attr; - bool exclude_guest_default =3D false; =20 #define MOD_PRINT(context, mod) do { \ if (!attr->exclude_##context) { \ @@ -560,17 +559,15 @@ static int evsel__add_modifiers(struct evsel *evsel, = char *bf, size_t size) MOD_PRINT(kernel, 'k'); MOD_PRINT(user, 'u'); MOD_PRINT(hv, 'h'); - exclude_guest_default =3D true; } =20 if (attr->precise_ip) { if (!colon) colon =3D ++r; r +=3D scnprintf(bf + r, size - r, "%.*s", attr->precise_ip, "ppp"); - exclude_guest_default =3D true; } =20 - if (attr->exclude_host || attr->exclude_guest =3D=3D exclude_guest_defaul= t) { + if (attr->exclude_host || attr->exclude_guest) { MOD_PRINT(host, 'H'); MOD_PRINT(guest, 'G'); } --=20 2.46.0.469.g59c65b2a67-goog From nobody Wed Jan 15 08:03:46 2025 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 861441A7266; Thu, 5 Sep 2024 20:24:31 +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=1725567871; cv=none; b=R8Wkmrw8xqzFg6GyjKGoLvXQLFNa9+F8PAYKdVJe+7Bn8qzkzB5TNRlOAhio0qTwZSFDStj33UD1tIAhoh9kRUkVxrxHK9o+9NTrPWcSVVExOYl7bbaFp3OblL4+/aP6lcs/h1jUNnLouJNtGQBL3JAvonc89rcmRFZacfCOMNg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567871; c=relaxed/simple; bh=9Ms+lwy/AoTEkUwRqoIFXzIsIMdu/VLl0Aily7ML1NY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ExQMnSRa2Nwcw2kN/ExSGI8HUeEMjTO+uxfo+Bd5kVzjKzafGItYgb2Fqa+fVEUnTMNAfWNEn3tA8kgTkOBj3kGVqVoOKROGZ5MfII51ekUZFLx7lWgksuY/u6gncJ+Bh32c3jmBATePPU50OalcarNokG11fVohU6amJPv16mc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YmjGGF33; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YmjGGF33" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86131C4CEC9; Thu, 5 Sep 2024 20:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725567871; bh=9Ms+lwy/AoTEkUwRqoIFXzIsIMdu/VLl0Aily7ML1NY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YmjGGF33rZ+0id+gB4hUmvn0eGXmMsF0E4CgsiuAsGeK6EfoEqsE74pFM3qnBrA2D DFlExUWKJqlwR2Gy/lV31GjG17X1gJQWP2j9rzo09uNdwCsp//i6cEHs7wUj/2/aPp stPKqZMh8e9qseMHbJigR2Xp8JP/XHi0CEH9pLTVLQw8udTno0qYcLBRUwT20E+DIC FO4omCSJiU6CEre/i1u9txBQRO65D6y8VPqTRymBdWGONeXbLiJlWPdkQccsnyZ0Da CkkqFGk2VkuaKilx3ROyXzhEaF/2wLaJMDiGf2+auBhti4qoMLJZykX0HO9Mb7IL0l 9+GWTGTMCt2Eg== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Ravi Bangoria , Mark Rutland , James Clark , Kajol Jain , Thomas Richter , Atish Patra , Palmer Dabbelt , Mingwei Zhang Subject: [PATCH 04/10] perf stat: Add --exclude-guest option Date: Thu, 5 Sep 2024 13:24:20 -0700 Message-ID: <20240905202426.2690105-5-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240905202426.2690105-1-namhyung@kernel.org> References: <20240905202426.2690105-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This option is to support the old behavior of setting exclude_guest by default. Now it doesn't set the bit so users want the old behavior can use this option. $ perf stat true Performance counter stats for 'true': 0.86 msec task-clock:u # 0.443 CPUs = utilized 0 context-switches:u # 0.000 /sec 0 cpu-migrations:u # 0.000 /sec 49 page-faults:u # 56.889 K/sec ... $ perf stat --exclude-guest true Performance counter stats for 'true': 0.79 msec task-clock:Hu # 0.490 CPUs = utilized 0 context-switches:Hu # 0.000 /sec 0 cpu-migrations:Hu # 0.000 /sec 49 page-faults:Hu # 62.078 K/sec ... Signed-off-by: Namhyung Kim --- tools/perf/Documentation/perf-stat.txt | 7 +++++++ tools/perf/builtin-stat.c | 2 ++ 2 files changed, 9 insertions(+) diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentat= ion/perf-stat.txt index 2bc06367248691dd..d28d8370a856598f 100644 --- a/tools/perf/Documentation/perf-stat.txt +++ b/tools/perf/Documentation/perf-stat.txt @@ -382,6 +382,13 @@ color the metric's computed value. Don't print output, warnings or messages. This is useful with perf stat record below to only write data to the perf.data file. =20 +--exclude-guest:: +Don't count event in the guest mode. It was the old behavior but the +default is changed to count guest events also. Use this option if you +want the old behavior (host only). Note that this option needs to be +before other events in case you added -e/--event option in the command +line. + STAT RECORD ----------- Stores stat data into perf data file. diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index d8315dae930184ba..4d47675af5cc3094 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2491,6 +2491,8 @@ int cmd_stat(int argc, const char **argv) OPT_BOOLEAN_FLAG(0, "all-user", &stat_config.all_user, "Configure all used events to run in user space.", PARSE_OPT_EXCLUSIVE), + OPT_BOOLEAN(0, "exclude-guest", &exclude_HG_default, + "Don't count events in the guest mode"), OPT_BOOLEAN(0, "percore-show-thread", &stat_config.percore_show_thread, "Use with 'percore' event qualifier to show the event " "counts of one hardware thread by sum up total hardware " --=20 2.46.0.469.g59c65b2a67-goog From nobody Wed Jan 15 08:03:46 2025 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 559A91AD246; Thu, 5 Sep 2024 20:24:32 +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=1725567872; cv=none; b=rQDzctDqFs8Xak7oKL6ug8mfK/4ObGUrcTyEcbR0/4YuXzDAfJR5ESY9FpkIZjw1uwNO/51zOk74Gt2ne4VRaA7jaO4VQ0QWIu7NzsKWCge+HQwkN25Vx6G3j2wtFpN1XbGMoB9RVSmQiWdcmF90vX0g4Bgm1KJcGtWgm7MDqOY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567872; c=relaxed/simple; bh=MtYLb5A+8uJvivYlMM8ukhzWCi5W1+o29XW+kTdEgfE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WM39aLAcw1h2PPpaay563RfPf4zA3yn5xNuC0kFBIeJwDC1PVk4HD7Q3iZ2vOJ7d848USzOjcZaCBgV72cRZECac3x6FvVB9as1X4IlPSEfNkOVbjCHikUDwGscopTDVg5fTSi5WTKgAVPUfRkLfKZO9CV9EL6sMd3cuTdoSBrc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gAg0MMAx; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gAg0MMAx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E8C3C4CEC7; Thu, 5 Sep 2024 20:24:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725567871; bh=MtYLb5A+8uJvivYlMM8ukhzWCi5W1+o29XW+kTdEgfE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gAg0MMAxpjbZ14wKNRw/mHVM4634L4Xt8/o6o9vycfZ/FCaPeoWExymPANb2Rb4R/ pmX+XF2ELvPknyGPjo7TRHMRn3qKA4A++HRW8g+8+hoBrAwY5Aa8vQ0KUaJ+yGrl+j jV2Nw4XSRoUx8yI3CHMa+aS18PfIlpUhIKk2j4YhRJJnoEktT7eZC3WAOEXQhalcCF eFN7oCxjaunNuG2x4tTtItYRnNIpMjSD67OR2bsKwPqSbbiKROG5PceHDO5Vz+9fiK hMRJ+HHL5pjclcaJtnsFYznHPL5dXEx7x5aB2qxblAciocjxyzO97Ph2qfIRyrp86o /WzjfNpdmC3ng== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Ravi Bangoria , Mark Rutland , James Clark , Kajol Jain , Thomas Richter , Atish Patra , Palmer Dabbelt , Mingwei Zhang Subject: [PATCH 05/10] perf tools: Do not set exclude_guest for precise_ip Date: Thu, 5 Sep 2024 13:24:21 -0700 Message-ID: <20240905202426.2690105-6-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240905202426.2690105-1-namhyung@kernel.org> References: <20240905202426.2690105-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It seems perf sets the exclude_guest bit because of Intel PEBS implementation which uses a virtual address. IIUC now kernel disables PEBS when it goes to the guest mode regardless of this bit so we don't need to set it explicitly. At least for the other archs/vendors. I found the commit 1342798cc13e set the exclude_guest for precise_ip in the tool and the commit 20b279ddb38c added kernel side enforcement which was reverted by commit a706d965dcfd later. Actually it doesn't set the exclude_guest for the default event (cycles:P) already. $ grep -m1 vendor /proc/cpuinfo vendor_id : GenuineIntel $ perf record -e cycles:P true [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.002 MB perf.data (9 samples) ] $ perf evlist -v | tr ',' '\n' | grep -e exclude -e precise precise_ip: 3 But having lower 'p' modifier set the bit for some reason. $ perf record -e cycles:pp true [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.002 MB perf.data (9 samples) ] $ perf evlist -v | tr ',' '\n' | grep -e exclude -e precise precise_ip: 2 exclude_guest: 1 Actually AMD IBS suffers from this because it doesn't support excludes and having this bit effectively disables new features in the current implementation (due to the missing feature check). $ grep -m1 vendor /proc/cpuinfo vendor_id : AuthenticAMD $ perf record -W -e cycles:p -vv true 2>&1 | grep switching switching off PERF_FORMAT_LOST support switching off weight struct support switching off bpf_event switching off ksymbol switching off cloexec flag switching off mmap2 switching off exclude_guest, exclude_host By not setting exclude_guest, we can fix this inconsistency and the troubles. Signed-off-by: Namhyung Kim --- tools/perf/tests/parse-events.c | 12 ++++-------- tools/perf/util/parse-events.c | 4 ---- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-event= s.c index 9077d581c0d05e62..087bb13ed76ba7c5 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -899,8 +899,7 @@ static int test__group1(struct evlist *evlist) TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); - /* use of precise requires exclude_guest */ - TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); + TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip =3D=3D 2= ); TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); @@ -1017,9 +1016,8 @@ static int test__group3(struct evlist *evlist __maybe= _unused) TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel); TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); - /* use of precise requires exclude_guest */ TEST_ASSERT_VAL("wrong exclude guest", - evsel->core.attr.exclude_guest); + !evsel->core.attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", @@ -1104,8 +1102,7 @@ static int test__group4(struct evlist *evlist __maybe= _unused) TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel); TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); - /* use of precise requires exclude_guest */ - TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); + TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip =3D=3D 1= ); TEST_ASSERT_VAL("wrong group name", !evsel->group_name); @@ -1123,8 +1120,7 @@ static int test__group4(struct evlist *evlist __maybe= _unused) TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user); TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel= ); TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv); - /* use of precise requires exclude_guest */ - TEST_ASSERT_VAL("wrong exclude guest", evsel->core.attr.exclude_guest); + TEST_ASSERT_VAL("wrong exclude guest", !evsel->core.attr.exclude_guest); TEST_ASSERT_VAL("wrong exclude host", !evsel->core.attr.exclude_host); TEST_ASSERT_VAL("wrong precise_ip", evsel->core.attr.precise_ip =3D=3D 2= ); TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader)); diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index 8d9e2d4b73822d98..d5dcd47ce0b18c13 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1754,10 +1754,6 @@ static int parse_events__modifier_list(struct parse_= events_state *parse_state, int exclude =3D eu | ek | eh; int exclude_GH =3D group ? evsel->exclude_GH : 0; =20 - if (mod.precise) { - /* use of precise requires exclude_guest */ - eG =3D 1; - } if (mod.user) { if (!exclude) exclude =3D eu =3D ek =3D eh =3D 1; --=20 2.46.0.469.g59c65b2a67-goog From nobody Wed Jan 15 08:03:46 2025 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 0DB301AE033; Thu, 5 Sep 2024 20:24:33 +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=1725567873; cv=none; b=HLArucHyjEax6ENRQD538Or2abV7Y/C0uVIeizFkObYUJLC174VF8d/MKk6OMsdViOoCiUbxCcrLI6t575PDamjzhEbEpBSqJMRYsZveimkzzHk95Q+gx9Yh3wauStUnEZN0Fe6Uya+L6pXFai1jAqo9FT7AHl6ZjPZjTveqvMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567873; c=relaxed/simple; bh=BVHHJA32EsSCrCynuzEZjwkgkDNLuRSSjqK47fwl3Vk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RYjTLgYETye8eVqF1HmPLNkfTmlGJxMkS0fktsj7RTcRf9H2MFglHapLXk3SmvtSj9lG0a+sZ3spZulBneKe7eCxGMBknbpqQVyEs4MB2XH8QkeqxdOTIb+odwR3MCY5RUr0CA2nes2t/x7tCFOJ8V4ivNDX/jhSmDOAWTqgXp8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cn0Yu6aY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cn0Yu6aY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11144C4CECF; Thu, 5 Sep 2024 20:24:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725567872; bh=BVHHJA32EsSCrCynuzEZjwkgkDNLuRSSjqK47fwl3Vk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cn0Yu6aYxhhJRSFqZH5LN9/P9jbMz0pxJ9PLxVxo8XRRYSYRO49PTLEUKriLAStKY L8vdcoiZKvD5d9azkbwuYvD+P6yCkjPRdZTHLimh3bv4UXJvOA6tTz9Ddc8FsxobqX JdxvZS+nO9aYaO8OrVgYSGpbOMuwopF+mahRoRknkHhUzYarqQdQkd0mThkGnBTp4K 5IAF9ldMW7Dh21AZiKTfATk5kGfOvEafHlFQDK/QaZooBiocNX79MPsddMSASoMOIT MGlbgjBQSg94MPLWkJ96pmKW5HnhHta8BBUTkswHnUD1/ERiuLO8ykaqwZDv3FEwPf 6VwOs8foh49Fg== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Ravi Bangoria , Mark Rutland , James Clark , Kajol Jain , Thomas Richter , Atish Patra , Palmer Dabbelt , Mingwei Zhang Subject: [PATCH 06/10] perf tools: Detect missing kernel features properly Date: Thu, 5 Sep 2024 13:24:22 -0700 Message-ID: <20240905202426.2690105-7-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240905202426.2690105-1-namhyung@kernel.org> References: <20240905202426.2690105-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The evsel__detect_missing_features() is to check if the attributes of the evsel is supported or not. But it checks the attribute based on the given evsel, it might miss something if the attr doesn't have the bit or give incorrect results if the event is special. Also it maintains the order of the feature that was added to the kernel which means it can assume older features should be supported once it detects the current feature is working. To minimized the confusion and to accurately check the kernel features, I think it's better to use a software event and go through all the features at once. Also make the function static since it's only used in evsel.c. Signed-off-by: Namhyung Kim --- tools/perf/util/evsel.c | 345 +++++++++++++++++++++++++++++----------- tools/perf/util/evsel.h | 1 - 2 files changed, 249 insertions(+), 97 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index dadcaf6e37063dfa..1a4f52767942e5ad 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -2135,120 +2136,272 @@ int evsel__prepare_open(struct evsel *evsel, stru= ct perf_cpu_map *cpus, return err; } =20 -bool evsel__detect_missing_features(struct evsel *evsel) +static bool has_attr_feature(struct perf_event_attr *attr, unsigned long f= lags) { + int fd =3D syscall(SYS_perf_event_open, attr, /*pid=3D*/0, /*cpu=3D*/-1, + /*group_fd=3D*/-1, flags); + close(fd); + + if (fd < 0) { + attr->exclude_kernel =3D 1; + + fd =3D syscall(SYS_perf_event_open, attr, /*pid=3D*/0, /*cpu=3D*/-1, + /*group_fd=3D*/-1, flags); + close(fd); + } + + if (fd < 0) { + attr->exclude_hv =3D 1; + + fd =3D syscall(SYS_perf_event_open, attr, /*pid=3D*/0, /*cpu=3D*/-1, + /*group_fd=3D*/-1, flags); + close(fd); + } + + if (fd < 0) { + attr->exclude_guest =3D 1; + + fd =3D syscall(SYS_perf_event_open, attr, /*pid=3D*/0, /*cpu=3D*/-1, + /*group_fd=3D*/-1, flags); + close(fd); + } + + attr->exclude_kernel =3D 0; + attr->exclude_guest =3D 0; + attr->exclude_hv =3D 0; + + return fd >=3D 0; +} + +static void evsel__detect_missing_brstack_features(struct evsel *evsel) +{ + static bool detection_done =3D false; + struct perf_event_attr attr =3D { + .type =3D evsel->core.attr.type, + .config =3D evsel->core.attr.config, + .disabled =3D 1, + .sample_type =3D PERF_SAMPLE_BRANCH_STACK, + .sample_period =3D 1000, + }; + int old_errno; + + if (detection_done) + return; + + old_errno =3D errno; + /* * Must probe features in the order they were added to the - * perf_event_attr interface. + * perf_event_attr interface. These are PMU specific limitation + * so we can detect with the given hardware event and stop on the + * first one succeeded. */ - if (!perf_missing_features.branch_counters && - (evsel->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_COUNTERS)) { - perf_missing_features.branch_counters =3D true; - pr_debug2("switching off branch counters support\n"); - return true; - } else if (!perf_missing_features.read_lost && - (evsel->core.attr.read_format & PERF_FORMAT_LOST)) { - perf_missing_features.read_lost =3D true; - pr_debug2("switching off PERF_FORMAT_LOST support\n"); + + /* Please add new feature detection here. */ + + attr.branch_sample_type =3D PERF_SAMPLE_BRANCH_COUNTERS; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.branch_counters =3D true; + pr_debug2("switching off branch counters support\n"); + + attr.branch_sample_type =3D PERF_SAMPLE_BRANCH_HW_INDEX; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.branch_hw_idx =3D true; + pr_debug2("switching off branch HW index support\n"); + + attr.branch_sample_type =3D PERF_SAMPLE_BRANCH_NO_CYCLES | PERF_SAMPLE_BR= ANCH_NO_FLAGS; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.lbr_flags =3D true; + pr_debug2_peo("switching off branch sample type no (cycles/flags)\n"); + +found: + detection_done =3D true; + errno =3D old_errno; +} + +static bool evsel__detect_missing_features(struct evsel *evsel) +{ + static bool detection_done =3D false; + struct perf_event_attr attr =3D { + .type =3D PERF_TYPE_SOFTWARE, + .config =3D PERF_COUNT_SW_TASK_CLOCK, + .disabled =3D 1, + }; + int old_errno; + + if (evsel__has_br_stack(evsel)) + evsel__detect_missing_brstack_features(evsel); + + if (detection_done) + goto check; + + old_errno =3D errno; + + /* + * Must probe features in the order they were added to the + * perf_event_attr interface. These are kernel core limitation + * not PMU-specific so we can detect with a software event and + * stop on the first one succeeded. + */ + + /* Please add new feature detection here. */ + + attr.read_format =3D PERF_FORMAT_LOST; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.read_lost =3D true; + pr_debug2("switching off PERF_FORMAT_LOST support\n"); + attr.read_format =3D 0; + + attr.sample_type =3D PERF_SAMPLE_WEIGHT_STRUCT; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.weight_struct =3D true; + pr_debug2("switching off weight struct support\n"); + attr.sample_type =3D 0; + + attr.sample_type =3D PERF_SAMPLE_CODE_PAGE_SIZE; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.code_page_size =3D true; + pr_debug2_peo("Kernel has no PERF_SAMPLE_CODE_PAGE_SIZE support\n"); + attr.sample_type =3D 0; + + attr.sample_type =3D PERF_SAMPLE_DATA_PAGE_SIZE; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.data_page_size =3D true; + pr_debug2_peo("Kernel has no PERF_SAMPLE_DATA_PAGE_SIZE support\n"); + attr.sample_type =3D 0; + + attr.cgroup =3D 1; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.cgroup =3D true; + pr_debug2_peo("Kernel has no cgroup sampling support\n"); + attr.cgroup =3D 0; + + attr.aux_output =3D 1; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.aux_output =3D true; + pr_debug2_peo("Kernel has no attr.aux_output support\n"); + attr.aux_output =3D 0; + + attr.bpf_event =3D 1; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.bpf =3D true; + pr_debug2_peo("switching off bpf_event\n"); + attr.bpf_event =3D 0; + + attr.ksymbol =3D 1; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.ksymbol =3D true; + pr_debug2_peo("switching off ksymbol\n"); + attr.ksymbol =3D 0; + + attr.write_backward =3D 1; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.write_backward =3D true; + pr_debug2_peo("switching off write_backward\n"); + attr.write_backward =3D 0; + + attr.use_clockid =3D 1; + attr.clockid =3D CLOCK_MONOTONIC; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.clockid =3D true; + pr_debug2_peo("switching off clockid\n"); + attr.use_clockid =3D 0; + attr.clockid =3D 0; + + if (has_attr_feature(&attr, /*flags=3D*/PERF_FLAG_FD_CLOEXEC)) + goto found; + perf_missing_features.cloexec =3D true; + pr_debug2_peo("switching off cloexec flag\n"); + + attr.mmap2 =3D 1; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.mmap2 =3D true; + pr_debug2_peo("switching off mmap2\n"); + attr.mmap2 =3D 0; + + /* set this unconditionally? */ + perf_missing_features.sample_id_all =3D true; + pr_debug2_peo("switching off sample_id_all\n"); + + attr.inherit =3D 1; + attr.read_format =3D PERF_FORMAT_GROUP; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.group_read =3D true; + pr_debug2_peo("switching off group read\n"); + attr.inherit =3D 0; + attr.read_format =3D 0; + +found: + detection_done =3D true; + errno =3D old_errno; + +check: + if ((evsel->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_COUNTERS) && + perf_missing_features.branch_counters) return true; - } else if (!perf_missing_features.weight_struct && - (evsel->core.attr.sample_type & PERF_SAMPLE_WEIGHT_STRUCT)) { - perf_missing_features.weight_struct =3D true; - pr_debug2("switching off weight struct support\n"); + + if ((evsel->core.attr.read_format & PERF_FORMAT_LOST) && + perf_missing_features.read_lost) return true; - } else if (!perf_missing_features.code_page_size && - (evsel->core.attr.sample_type & PERF_SAMPLE_CODE_PAGE_SIZE)) { - perf_missing_features.code_page_size =3D true; - pr_debug2_peo("Kernel has no PERF_SAMPLE_CODE_PAGE_SIZE support, bailing= out\n"); - return false; - } else if (!perf_missing_features.data_page_size && - (evsel->core.attr.sample_type & PERF_SAMPLE_DATA_PAGE_SIZE)) { - perf_missing_features.data_page_size =3D true; - pr_debug2_peo("Kernel has no PERF_SAMPLE_DATA_PAGE_SIZE support, bailing= out\n"); - return false; - } else if (!perf_missing_features.cgroup && evsel->core.attr.cgroup) { - perf_missing_features.cgroup =3D true; - pr_debug2_peo("Kernel has no cgroup sampling support, bailing out\n"); - return false; - } else if (!perf_missing_features.branch_hw_idx && - (evsel->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_HW_INDEX)) { - perf_missing_features.branch_hw_idx =3D true; - pr_debug2("switching off branch HW index support\n"); + + if ((evsel->core.attr.sample_type & PERF_SAMPLE_WEIGHT_STRUCT) && + perf_missing_features.weight_struct) return true; - } else if (!perf_missing_features.aux_output && evsel->core.attr.aux_outp= ut) { - perf_missing_features.aux_output =3D true; - pr_debug2_peo("Kernel has no attr.aux_output support, bailing out\n"); - return false; - } else if (!perf_missing_features.bpf && evsel->core.attr.bpf_event) { - perf_missing_features.bpf =3D true; - pr_debug2_peo("switching off bpf_event\n"); + + if (evsel->core.attr.use_clockid && evsel->core.attr.clockid !=3D CLOCK_M= ONOTONIC && + !perf_missing_features.clockid) { + perf_missing_features.clockid_wrong =3D true; return true; - } else if (!perf_missing_features.ksymbol && evsel->core.attr.ksymbol) { - perf_missing_features.ksymbol =3D true; - pr_debug2_peo("switching off ksymbol\n"); + } + + if (evsel->core.attr.use_clockid && perf_missing_features.clockid) return true; - } else if (!perf_missing_features.write_backward && evsel->core.attr.writ= e_backward) { - perf_missing_features.write_backward =3D true; - pr_debug2_peo("switching off write_backward\n"); - return false; - } else if (!perf_missing_features.clockid_wrong && evsel->core.attr.use_c= lockid) { - perf_missing_features.clockid_wrong =3D true; - pr_debug2_peo("switching off clockid\n"); + + if ((evsel->open_flags & PERF_FLAG_FD_CLOEXEC) && + perf_missing_features.cloexec) return true; - } else if (!perf_missing_features.clockid && evsel->core.attr.use_clockid= ) { - perf_missing_features.clockid =3D true; - pr_debug2_peo("switching off use_clockid\n"); + + if (evsel->core.attr.mmap2 && perf_missing_features.mmap2) return true; - } else if (!perf_missing_features.cloexec && (evsel->open_flags & PERF_FL= AG_FD_CLOEXEC)) { - perf_missing_features.cloexec =3D true; - pr_debug2_peo("switching off cloexec flag\n"); + + if ((evsel->core.attr.branch_sample_type & (PERF_SAMPLE_BRANCH_NO_FLAGS | + PERF_SAMPLE_BRANCH_NO_CYCLES)) && + perf_missing_features.lbr_flags) return true; - } else if (!perf_missing_features.mmap2 && evsel->core.attr.mmap2) { - perf_missing_features.mmap2 =3D true; - pr_debug2_peo("switching off mmap2\n"); + + if (evsel->core.attr.inherit && (evsel->core.attr.read_format & PERF_FORM= AT_GROUP) && + perf_missing_features.group_read) return true; - } else if (evsel->core.attr.exclude_guest || evsel->core.attr.exclude_hos= t) { - if (evsel->pmu =3D=3D NULL) - evsel->pmu =3D evsel__find_pmu(evsel); - - if (evsel->pmu) - evsel->pmu->missing_features.exclude_guest =3D true; - else { - /* we cannot find PMU, disable attrs now */ - evsel->core.attr.exclude_host =3D false; - evsel->core.attr.exclude_guest =3D false; - } =20 - if (evsel->exclude_GH) { - pr_debug2_peo("PMU has no exclude_host/guest support, bailing out\n"); - return false; - } - if (!perf_missing_features.exclude_guest) { - perf_missing_features.exclude_guest =3D true; - pr_debug2_peo("switching off exclude_guest, exclude_host\n"); - } + if (evsel->core.attr.ksymbol && perf_missing_features.ksymbol) return true; - } else if (!perf_missing_features.sample_id_all) { - perf_missing_features.sample_id_all =3D true; - pr_debug2_peo("switching off sample_id_all\n"); + + if (evsel->core.attr.bpf_event && perf_missing_features.bpf) return true; - } else if (!perf_missing_features.lbr_flags && - (evsel->core.attr.branch_sample_type & - (PERF_SAMPLE_BRANCH_NO_CYCLES | - PERF_SAMPLE_BRANCH_NO_FLAGS))) { - perf_missing_features.lbr_flags =3D true; - pr_debug2_peo("switching off branch sample type no (cycles/flags)\n"); + + if ((evsel->core.attr.branch_sample_type & PERF_SAMPLE_BRANCH_HW_INDEX) && + perf_missing_features.branch_hw_idx) return true; - } else if (!perf_missing_features.group_read && - evsel->core.attr.inherit && - (evsel->core.attr.read_format & PERF_FORMAT_GROUP) && - evsel__is_group_leader(evsel)) { - perf_missing_features.group_read =3D true; - pr_debug2_peo("switching off group read\n"); + + if (evsel->core.attr.sample_id_all && perf_missing_features.sample_id_all) return true; - } else { - return false; - } + + return false; } =20 static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 15acf293e12af713..098aa0d8eeb65466 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -363,7 +363,6 @@ int evsel__open(struct evsel *evsel, struct perf_cpu_ma= p *cpus, void evsel__close(struct evsel *evsel); int evsel__prepare_open(struct evsel *evsel, struct perf_cpu_map *cpus, struct perf_thread_map *threads); -bool evsel__detect_missing_features(struct evsel *evsel); =20 bool evsel__precise_ip_fallback(struct evsel *evsel); =20 --=20 2.46.0.469.g59c65b2a67-goog From nobody Wed Jan 15 08:03:46 2025 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 08CE61B12FE; Thu, 5 Sep 2024 20:24:33 +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=1725567874; cv=none; b=aByISh1vSCd5/L+jx/S0bh2fTaJVRDC3v6JksC/+E2Hesz1GzHr7p7aDF/XvFn8DLRtgcc2MgFZrcxRDLnwfJ4OrPpXPieup3hxPklRyLwg+S3Atdybbg8vKIAdMH9Wy+zgU5Dt41y6EX0ONOIFMwKNJ2KPa/FYcb8IjYNH/llE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567874; c=relaxed/simple; bh=29eATBDBumyqrjtaCtZNaXbHhGBs2etJ13trK8RfIoY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qMzOKP117YdUTl3+9VSbfB9FzqSeVTxcGjbNP4lC8kclghqANSJKei6H6gwAhtzr4oWGPJWS3naZaWEznRDVZUvKZl/6YWoDf757Ui9rkT2SbMZG3zL8N7D8lbQmY/fSUqG1nDi2A6cTjLAL10m/gZ73OGPD+Lp1quGlswcxnAM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fR34QT0a; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fR34QT0a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A0C8C4CECD; Thu, 5 Sep 2024 20:24:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725567873; bh=29eATBDBumyqrjtaCtZNaXbHhGBs2etJ13trK8RfIoY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fR34QT0a7F5KlkOJ06tMpuelsc9h3cPCz2pHqY2aQfGzSBkXKuIww4rvMAsssxV/2 6V3ZVYlAQpXyqhG7bDZ48bylMnT9Np+4v5RcwHSSUlTX7xigmmlj3fQ50Ty80Nv3A6 m7kSyfJiZMYuMesHLFuBlS73yx+iHNsh8REqgpw9pJIr0mKWQx1+9kaDARqWb5hEnd 0vfrUHl88VKFBm8r8+3quxbRQwNEI9Y6hQ93BuTD5b2mpS0VnagfwpW6GtThFe/TLx GnESHl/hYEj83prPzhdlCZ9d/4jI3NJSnayk9BXT3fuu9GlqjPEQ8vUvdQeFD/dtHD t+bpWPLhKd9SA== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Ravi Bangoria , Mark Rutland , James Clark , Kajol Jain , Thomas Richter , Atish Patra , Palmer Dabbelt , Mingwei Zhang Subject: [PATCH 07/10] perf tools: Separate exclude_hv fallback Date: Thu, 5 Sep 2024 13:24:23 -0700 Message-ID: <20240905202426.2690105-8-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240905202426.2690105-1-namhyung@kernel.org> References: <20240905202426.2690105-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The exclude_hv was added in the evsel__fallback() in the commit 4ec8d984895fef43a ("perf record: Fix priv level with branch sampling for paranoid=3D2") to address branch stack samples on Intel PMUs. As some other PMUs might not support that, let's separate the bit from exclude_kernel to make sure it can add the bit only if required. Technically it should change the modifier string at the end of the event name. ":u" is for exclude_kernel + exclude_hv, so it should be ":uh" if it has exclude_kernel only. That means the default events for regular users will looks like "cycles:Puh" (for perf record) or "instructions:uh" (for perf stat). But I'm not sure if it's worth the trouble so I didn't touch the name in this patch. Signed-off-by: Namhyung Kim --- tools/perf/util/evsel.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 1a4f52767942e5ad..c5df45bb74dfc1b5 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -3389,10 +3389,20 @@ bool evsel__fallback(struct evsel *evsel, struct ta= rget *target, int err, free(evsel->name); evsel->name =3D new_name; scnprintf(msg, msgsize, "kernel.perf_event_paranoid=3D%d, trying " - "to fall back to excluding kernel and hypervisor " - " samples", paranoid); + "to fall back to excluding kernel samples", paranoid); evsel->core.attr.exclude_kernel =3D 1; - evsel->core.attr.exclude_hv =3D 1; + + return true; + } else if (err =3D=3D EACCES && !evsel->core.attr.exclude_hv && + (paranoid =3D perf_event_paranoid()) > 1) { + /* If event has exclude user then don't exclude hv. */ + if (evsel->core.attr.exclude_user) + return false; + + /* Intel branch stack requires exclude_hv */ + scnprintf(msg, msgsize, "kernel.perf_event_paranoid=3D%d, trying " + "to fall back to excluding hypervisor samples", paranoid); + evsel->core.attr.exclude_hv =3D 1; =20 return true; } else if (err =3D=3D EOPNOTSUPP && !evsel->core.attr.exclude_guest && --=20 2.46.0.469.g59c65b2a67-goog From nobody Wed Jan 15 08:03:46 2025 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 B35411B2EE8; Thu, 5 Sep 2024 20:24:34 +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=1725567874; cv=none; b=NYn71DAm50BxMWSWW+SI/rEVahB2MjhwI8I/m0H1xfnKyTXbMAWiNvp+Nh2XMqv3zzjC4aw7SBxPACXsbWlIpy6lVAYfrvoTdOtyedfc33BRG99TAGUg3g+4367QFF8QsCxEVVwf7BsRIY+SF9VPVFYEQE4qd/BaODjXbx0Kkac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567874; c=relaxed/simple; bh=MUj8CTCtB4NLF/yrO1JxR1Didkl0TCC5awQMA0iC0QU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jU4yS01Me+XRdKnP13wDF7yaC7vBg6mG7/U7V0EEHAoP53kc6Kn2nurVIxLJGsAjojQMWU2cpB9bPFI62DGEuTFHY9gpnERrIoutzTc4UX0QfjZLWux6ehk5JBxKW6JXYMIFL3YzDKiP6lqL0SljF5AU05IjiYe1VrbVNcvTMds= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UTlJ4epj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UTlJ4epj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0316C4CECA; Thu, 5 Sep 2024 20:24:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725567874; bh=MUj8CTCtB4NLF/yrO1JxR1Didkl0TCC5awQMA0iC0QU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UTlJ4epjDeOCuLaCiQHvKPNwHmzmEMXFhYXZyXFQwbVyK97lGJXA6FvB1WIWJ8+NF hPDkuALifMeCfA5O8walBtDQo65JyREZX8XOrVpZiFkcPUQuaaNMhOym8LSbbccTej HT4sech2LiYI/ILOTtSjGF0wC8X/7nU4D0u+lW2rqNHOMq9rYVl1IaMSyqUmHtOO7w n005d1CdHNEm3M5lPv++QwGOtNCOCIDr5ytmWQ92J8YjYOJj8Vw2OTrEfAeYspk1mV lxs5haWCwxgwWTy6m82u64bolSh4/Ug3YsIBLUIWt+2OtQkdzWRF/A5zejUDHWbBX6 7l+FjczqUBq8w== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Ravi Bangoria , Mark Rutland , James Clark , Kajol Jain , Thomas Richter , Atish Patra , Palmer Dabbelt , Mingwei Zhang Subject: [PATCH 08/10] perf tools: Move x86__is_amd_cpu() to util/env.c Date: Thu, 5 Sep 2024 13:24:24 -0700 Message-ID: <20240905202426.2690105-9-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240905202426.2690105-1-namhyung@kernel.org> References: <20240905202426.2690105-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It can be called from non-x86 platform so let's move it to the general util directory. Also add a new helper perf_env__is_x86_amd_cpu() so that it can be called with an existing perf_env as well. Signed-off-by: Namhyung Kim --- tools/perf/arch/x86/util/Build | 1 - tools/perf/arch/x86/util/env.c | 19 ------------------- tools/perf/arch/x86/util/env.h | 7 ------- tools/perf/arch/x86/util/pmu.c | 2 +- tools/perf/util/env.c | 23 +++++++++++++++++++++++ tools/perf/util/env.h | 4 ++++ 6 files changed, 28 insertions(+), 28 deletions(-) delete mode 100644 tools/perf/arch/x86/util/env.c delete mode 100644 tools/perf/arch/x86/util/env.h diff --git a/tools/perf/arch/x86/util/Build b/tools/perf/arch/x86/util/Build index 2607ed5c42966543..ce6d802a1381c5ab 100644 --- a/tools/perf/arch/x86/util/Build +++ b/tools/perf/arch/x86/util/Build @@ -10,7 +10,6 @@ perf-util-y +=3D evlist.o perf-util-y +=3D mem-events.o perf-util-y +=3D evsel.o perf-util-y +=3D iostat.o -perf-util-y +=3D env.o =20 perf-util-$(CONFIG_DWARF) +=3D dwarf-regs.o perf-util-$(CONFIG_BPF_PROLOGUE) +=3D dwarf-regs.o diff --git a/tools/perf/arch/x86/util/env.c b/tools/perf/arch/x86/util/env.c deleted file mode 100644 index 3e537ffb1353aab2..0000000000000000 --- a/tools/perf/arch/x86/util/env.c +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -#include "linux/string.h" -#include "util/env.h" -#include "env.h" - -bool x86__is_amd_cpu(void) -{ - struct perf_env env =3D { .total_mem =3D 0, }; - static int is_amd; /* 0: Uninitialized, 1: Yes, -1: No */ - - if (is_amd) - goto ret; - - perf_env__cpuid(&env); - is_amd =3D env.cpuid && strstarts(env.cpuid, "AuthenticAMD") ? 1 : -1; - perf_env__exit(&env); -ret: - return is_amd >=3D 1 ? true : false; -} diff --git a/tools/perf/arch/x86/util/env.h b/tools/perf/arch/x86/util/env.h deleted file mode 100644 index d78f080b6b3f889a..0000000000000000 --- a/tools/perf/arch/x86/util/env.h +++ /dev/null @@ -1,7 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _X86_ENV_H -#define _X86_ENV_H - -bool x86__is_amd_cpu(void); - -#endif /* _X86_ENV_H */ diff --git a/tools/perf/arch/x86/util/pmu.c b/tools/perf/arch/x86/util/pmu.c index c3d89d6ba1bf03ad..e0060dac2a9f9242 100644 --- a/tools/perf/arch/x86/util/pmu.c +++ b/tools/perf/arch/x86/util/pmu.c @@ -16,7 +16,7 @@ #include "../../../util/fncache.h" #include "../../../util/pmus.h" #include "mem-events.h" -#include "env.h" +#include "util/env.h" =20 void perf_pmu__arch_init(struct perf_pmu *pmu __maybe_unused) { diff --git a/tools/perf/util/env.c b/tools/perf/util/env.c index a459374d0a1a1dc8..6965f3d498e327cc 100644 --- a/tools/perf/util/env.c +++ b/tools/perf/util/env.c @@ -5,6 +5,7 @@ #include "util/header.h" #include "linux/compiler.h" #include +#include #include #include "cgroup.h" #include @@ -624,3 +625,25 @@ char *perf_env__find_pmu_cap(struct perf_env *env, con= st char *pmu_name, free(cap_eq); return NULL; } + +bool perf_env__is_x86_amd_cpu(struct perf_env *env) +{ + static int is_amd; /* 0: Uninitialized, 1: Yes, -1: No */ + + if (is_amd =3D=3D 0) + is_amd =3D env->cpuid && strstarts(env->cpuid, "AuthenticAMD") ? 1 : -1; + + return is_amd >=3D 1 ? true : false; +} + +bool x86__is_amd_cpu(void) +{ + struct perf_env env =3D { .total_mem =3D 0, }; + bool is_amd; + + perf_env__cpuid(&env); + is_amd =3D perf_env__is_x86_amd_cpu(&env); + perf_env__exit(&env); + + return is_amd; +} diff --git a/tools/perf/util/env.h b/tools/perf/util/env.h index 2a2c37cc40b7828e..573ad9823d16d5cf 100644 --- a/tools/perf/util/env.h +++ b/tools/perf/util/env.h @@ -192,4 +192,8 @@ char *perf_env__find_pmu_cap(struct perf_env *env, cons= t char *pmu_name, const char *cap); =20 bool perf_env__has_pmu_mapping(struct perf_env *env, const char *pmu_name); + +bool x86__is_amd_cpu(void); +bool perf_env__is_x86_amd_cpu(struct perf_env *env); + #endif /* __PERF_ENV_H */ --=20 2.46.0.469.g59c65b2a67-goog From nobody Wed Jan 15 08:03:46 2025 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 9084E1B4C56; Thu, 5 Sep 2024 20:24:35 +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=1725567875; cv=none; b=ARLkcm6UOGk8OjQ1E0Ahvh3DoIcabEDr/OwG1cKVk/FUCn8JisVAyMqQP5F2/HeQgskxYW1Ws7uxPc7bCUHaYbZK6/RtU3yH8uJReIPZAoUbW36/FAx47N/kh1ezZY5E+ilMLmO1jrMyBoBcu+xVGGbBuAQBeyDYIrhW31Bhgws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567875; c=relaxed/simple; bh=AufemQAU604Y4JGWJuF8BhzAdHiSnLIB5lKrQoVMdK0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pdEukLJ0fC+Dfvl8YOpOhptKc/YSSVp0khahw2Mz7UAUKTqFsUhqs7LV6yWWnklq4Mk4utqrTy2tPIG3mz9v376eIo1qMBlijaF95mga7nl5JOjEF3vf0RsV67dKsWsIw4hRPjV+pe+yk0PrLkG2XRAj9+y5q1Lajqvsbb1I8uM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GfCiNnwE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GfCiNnwE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83658C4CEC9; Thu, 5 Sep 2024 20:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725567875; bh=AufemQAU604Y4JGWJuF8BhzAdHiSnLIB5lKrQoVMdK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GfCiNnwE0sdsRr5mZ1AvaDDmoOAJVxKj7xOteJOz/SuY9hh06Jez1EMYH9TTnEY+H IdEJXEszSWefypTkQSOZaC7DnJkmoBIzj4FbGqZEJllEGU+GxWeYtT035oiv/Gs61k WHzBoCbeJc4z9L4AIn7pkVme0dlk/2zF9QonHqZP2n0CzAl1+RQJH58CWHJQLKaPYJ OIKJDqxQcHykVB0uMAKiwojeU7RvQo7phtnzk1W/DC/N2T+YhsVe5x/vwTqp2mQtMK Z0uu0OOokS1opBLmmeqH/XfRsDtE0E4EEJ51WBdJr4mq4z6VdB3FVT59axIipkJK0u nRJNZq77jG8VA== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Ravi Bangoria , Mark Rutland , James Clark , Kajol Jain , Thomas Richter , Atish Patra , Palmer Dabbelt , Mingwei Zhang Subject: [PATCH 09/10] perf tools: Check fallback error and order Date: Thu, 5 Sep 2024 13:24:25 -0700 Message-ID: <20240905202426.2690105-10-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240905202426.2690105-1-namhyung@kernel.org> References: <20240905202426.2690105-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The perf_event_open might fail due to various reasons, so blindly reducing precise_ip level might not be the best way to deal with it. It seems the kernel return -EOPNOTSUPP when PMU doesn't support the given precise level. Let's try again with the correct error code. This caused a problem on AMD, as it stops on precise_ip of 2 for IBS but user events with exclude_kernel=3D1 cannot make progress. Let's add the evsel__handle_error_quirks() to this case specially. I plan to work on the kernel side to improve this situation but it'd still need some special handling for IBS. Signed-off-by: Namhyung Kim --- tools/perf/util/evsel.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index c5df45bb74dfc1b5..895f45921da30bb2 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2404,6 +2404,20 @@ static bool evsel__detect_missing_features(struct ev= sel *evsel) return false; } =20 +static bool evsel__handle_error_quirks(struct evsel *evsel, int error) +{ + /* AMD IBS doesn't support exclude_kernel, forward it to core PMU */ + if (error =3D=3D -EINVAL && evsel->precise_max && evsel->core.attr.precis= e_ip && + evsel->core.attr.exclude_kernel && x86__is_amd_cpu()) { + evsel->core.attr.precise_ip =3D 0; + pr_debug2_peo("removing precise_ip on AMD\n"); + display_attr(&evsel->core.attr); + return true; + } + + return false; +} + static int evsel__open_cpu(struct evsel *evsel, struct perf_cpu_map *cpus, struct perf_thread_map *threads, int start_cpu_map_idx, int end_cpu_map_idx) @@ -2565,9 +2579,6 @@ static int evsel__open_cpu(struct evsel *evsel, struc= t perf_cpu_map *cpus, return 0; =20 try_fallback: - if (evsel__precise_ip_fallback(evsel)) - goto retry_open; - if (evsel__ignore_missing_thread(evsel, perf_cpu_map__nr(cpus), idx, threads, thread, err)) { /* We just removed 1 thread, so lower the upper nthreads limit. */ @@ -2584,11 +2595,15 @@ static int evsel__open_cpu(struct evsel *evsel, str= uct perf_cpu_map *cpus, if (err =3D=3D -EMFILE && rlimit__increase_nofile(&set_rlimit)) goto retry_open; =20 - if (err !=3D -EINVAL || idx > 0 || thread > 0) - goto out_close; + if (err =3D=3D -EOPNOTSUPP && evsel__precise_ip_fallback(evsel)) + goto retry_open; =20 - if (evsel__detect_missing_features(evsel)) + if (err =3D=3D -EINVAL && evsel__detect_missing_features(evsel)) goto fallback_missing_features; + + if (evsel__handle_error_quirks(evsel, err)) + goto retry_open; + out_close: if (err) threads->err_thread =3D thread; --=20 2.46.0.469.g59c65b2a67-goog From nobody Wed Jan 15 08:03:46 2025 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 069AD1B6552; Thu, 5 Sep 2024 20:24:36 +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=1725567876; cv=none; b=eyygs96cww0jFkRHyIrqik9XOiUzMJqRj9i07L21EcGzaOR687PT4Dwlst7V4F7lw+zycWoOctJV0tyHmrN3/QNZ68pvR57FUuyYCGNTQ5XmwnL0O4s7SBug8pOxifCIyDQKP04edhQODZwubRyeXEEDqPAYDPXKHGng5fNWJvc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725567876; c=relaxed/simple; bh=357L4htyQZgC3GnbOdl4w0QF9QxWOkOrNAzwRiz9rSg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Orj7av7RW15/HyRA5whZV2c1rkdoqVKMe0+o157xG6EFtlu9aKn6EJio92kV+yVK3X4nDoDI2S1LFMPhQL1yTTh6RrVWzaRMnGdfnDFmtOkT6MI5Y1SABaclJvR55s+hC86bmp33owQSRYLAhsQM5YHZSadlkkidmOw+VPPMqKc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ny2MK3o2; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ny2MK3o2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4798FC4CEC7; Thu, 5 Sep 2024 20:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725567875; bh=357L4htyQZgC3GnbOdl4w0QF9QxWOkOrNAzwRiz9rSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ny2MK3o21J3gK1zGAJWYQ+5c3yVBaKmkgaAc0XtZmrrYPQtZU02D/aKGOD23HP2N8 S2YJOUkiJbBpNvUAIxE+N8XdJR/+0fL8dYSZGY9uySrROs6Q3MXHDF8x65FaeU+zyu 4fLB+emEK5k7CV7hhkjY5luYeKjH7NjFr5ZUA9qEsSJ3EkT2b/TgiBaL9Aq/XvkgNl fgUj9oU4Y7LhcktRjbJw+HBjmkndbiiWeIjUUXvov4wYLhBDasRm6xENp4cTmirPRB asdiLRubu8YJw+/irf3WbXQAUFNxkwrdGPMzbVHx11qcvhXAiDIEQ0kR7fPpHP0Qzr G6l1jBP7D1ifg== From: Namhyung Kim To: Arnaldo Carvalho de Melo , Ian Rogers , Kan Liang Cc: Jiri Olsa , Adrian Hunter , Peter Zijlstra , Ingo Molnar , LKML , linux-perf-users@vger.kernel.org, Ravi Bangoria , Mark Rutland , James Clark , Kajol Jain , Thomas Richter , Atish Patra , Palmer Dabbelt , Mingwei Zhang Subject: [PATCH 10/10] perf record: Just use "cycles:P" as the default event Date: Thu, 5 Sep 2024 13:24:26 -0700 Message-ID: <20240905202426.2690105-11-namhyung@kernel.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240905202426.2690105-1-namhyung@kernel.org> References: <20240905202426.2690105-1-namhyung@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The fallback logic can add ":u" modifier if needed. Signed-off-by: Namhyung Kim --- tools/perf/builtin-record.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index adbaf80b398c1f4c..f8325247292112d7 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -4157,9 +4157,7 @@ int cmd_record(int argc, const char **argv) record.opts.tail_synthesize =3D true; =20 if (rec->evlist->core.nr_entries =3D=3D 0) { - bool can_profile_kernel =3D perf_event_paranoid_check(1); - - err =3D parse_event(rec->evlist, can_profile_kernel ? "cycles:P" : "cycl= es:Pu"); + err =3D parse_event(rec->evlist, "cycles:P"); if (err) goto out; } --=20 2.46.0.469.g59c65b2a67-goog