From nobody Tue Mar 11 05:08:09 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 F060D18D634; Wed, 16 Oct 2024 06:24:01 +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=1729059842; cv=none; b=nPxUDHlPdHqZPrbJCpzwoOd5Y/8Q71ILPpIsGfHuuKrS3WjMQ/cfGFz6aPzoJ0VYZ5PNkxs+EJ6rgJiWCyG6eW0wNSOVmj+/DRvsPbobxrECZs08/HSB+PXKGPHy4C5DtSOcxInjusz+NyxKld7YoZFcKH/jCgOsuVLeiFwqsf8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729059842; c=relaxed/simple; bh=2GuXExIeHB5Pio+GUyFCWdTjHAtYr6iB9FkrPvyroKo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dix1SaAg/HOShoSjEow+651ustR8y/fCOfm6MJT0uoDyJ2rXj/HDsKe+sBzegN4jGMT7YbbqNxVhKIUlolEzyamCzhRa0oPqglSK2mdM9rPAp8OiKhLpvQ79r7vMM3f4T8aT8haNOKkl/JIamt1h/FSCLSUjUAn2I5A+2SHWPvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Rx0XkuZy; 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="Rx0XkuZy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F24E4C4CED1; Wed, 16 Oct 2024 06:24:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729059841; bh=2GuXExIeHB5Pio+GUyFCWdTjHAtYr6iB9FkrPvyroKo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rx0XkuZyBLavS9dEbq1Ak9nE2fjXQyZLsdbnjM6SpGmeCLr4udyRGnI9M70tYiBLB 9I8Rhf3GHsBftYfSOv0sv1LfyZUz/jgF59Awyn1gY4XjQAyrswgsLBCDeFNLrNoGGy l3Kr3NiX7YgJjYK/nqcOjnobnKpDZiP6qUkgAxzmXoBtWydpwwfgumRm8nWpdXoZoo hqIIT1li6NgAVLKSv78tFckNDsbDILTXVT19tbYyrvxNtz/O88tfx/sne9hyQmReLk PkooBzyf8zVnBSw0Z5yM9NzIbIC95irHprmwL+rCYjGrEvumqDaNfO9ybbTfmCTOIS lY5rBqntASAsQ== 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 v5 1/9] perf tools: Add fallback for exclude_guest Date: Tue, 15 Oct 2024 23:23:51 -0700 Message-ID: <20241016062359.264929-2-namhyung@kernel.org> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241016062359.264929-1-namhyung@kernel.org> References: <20241016062359.264929-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. Also update perf stat hybrid tests to handle possible u or H modifiers. Fixes: 7b100989b4f6bce70 ("perf evlist: Remove __evlist__add_default") Reviewed-by: Ian Rogers Acked-by: Kan Liang Reviewed-by: James Clark Reviewed-by: Ravi Bangoria Cc: Mark Rutland Signed-off-by: Namhyung Kim --- tools/perf/builtin-stat.c | 18 +++++++++++++++--- tools/perf/tests/shell/stat.sh | 2 +- tools/perf/util/evsel.c | 21 +++++++++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index b5e18853982cdb0f..0de3db9810db16f8 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -640,8 +640,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)); @@ -659,7 +658,7 @@ static enum counter_recovery stat_handle_error(struct e= vsel *counter) if (verbose > 0) ui__warning("%s\n", msg); return COUNTER_RETRY; - } else if (target__has_per_thread(&target) && + } else if (target__has_per_thread(&target) && errno !=3D EOPNOTSUPP && evsel_list->core.threads && evsel_list->core.threads->err_thread !=3D -1) { /* @@ -680,6 +679,19 @@ static enum counter_recovery stat_handle_error(struct = evsel *counter) return COUNTER_SKIP; } =20 + if (errno =3D=3D EOPNOTSUPP) { + if (verbose > 0) { + ui__warning("%s event is not supported by the kernel.\n", + evsel__name(counter)); + } + counter->supported =3D false; + counter->errored =3D true; + + if ((evsel__leader(counter) !=3D counter) || + !(counter->core.leader->nr_members > 1)) + return COUNTER_SKIP; + } + evsel__open_strerror(counter, &target, errno, msg, sizeof(msg)); ui__error("%s\n", msg); =20 diff --git a/tools/perf/tests/shell/stat.sh b/tools/perf/tests/shell/stat.sh index f25ef468b8fca992..7a8adf81e4b39338 100755 --- a/tools/perf/tests/shell/stat.sh +++ b/tools/perf/tests/shell/stat.sh @@ -185,7 +185,7 @@ test_hybrid() { fi =20 # Run default Perf stat - cycles_events=3D$(perf stat -- true 2>&1 | grep -E "/cycles/| cycles "= | wc -l) + cycles_events=3D$(perf stat -- true 2>&1 | grep -E "/cycles/[uH]*| cycl= es[:uH]* " -c) =20 if [ "$pmus" -ne "$cycles_events" ] then diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index e9e1f576d34ddf64..c965ec5676f8d54a 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -3037,6 +3037,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.47.0.rc1.288.g06298d1525-goog From nobody Tue Mar 11 05:08:09 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 DA10718EFC6; Wed, 16 Oct 2024 06:24:02 +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=1729059842; cv=none; b=nRMEXEerTHiaxahDuJwuzSaD4+m7WID06eVO+7NkPu3Tvk9Yi6canpXNuXJXiabkGaX/pSuKnbTZG8FX94sQyguZG3DCrQPy0NkKYyZJTr613rrUSDmIsbiCW5Cf8Yxu7NfLJsqiQgx3nv5EaGeWRmyI1UM0My4JShT/aV7XMyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729059842; c=relaxed/simple; bh=Gwg+tPQ+DHx54YBjE78wDe8fiXCuqrJBnWwjHGXGXP4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qu7vYwjVV0/V0zf7i09m9UwppyYQkXUwLJOft26OVsJyNWHsAV6O5fSOAf2E+EMm8mvV5RI/qT55Q0RIx73dMpoSDDVJYDaNpdNSCMxfNE3ADacMifVAf/TG3u2D9skK70deBQ0YuOb0qB6SBOCz7QcvCmhTg7KcJKFx8Vxlleg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=a3sUNmXA; 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="a3sUNmXA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9047C4CED3; Wed, 16 Oct 2024 06:24:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729059842; bh=Gwg+tPQ+DHx54YBjE78wDe8fiXCuqrJBnWwjHGXGXP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a3sUNmXALfrJAigrgkdm52blg52WOJzOXVV0K528CLSSRqvdbJDg0/mfFy5qqhDzU HDplAr9nfcl4ZMG0NrHF5yA6MMGnUtyLMxvXycurWrzqTdjgj5SbrU7Lo83Jx4kg4h 5Lagqciz8IznNTrfC4FOrAM2CljTG/tRLALmt8z68j1hkXnUn/THTJetK6eF6dONNu 5QZ597N41y/wzMi4e6zM0Q4E945GAs1HzeeEnbaIp5p0U+Rft8+I/Ch/0kTcz7xWJs HJW0s4UxM3SayMxODCfXxzPRniRYBFWAwawNRgaGByebXkkvp8oxfIw9QEAZdFymCW XZZggppsVQISA== 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 v5 2/9] perf tools: Don't set attr.exclude_guest by default Date: Tue, 15 Oct 2024 23:23:52 -0700 Message-ID: <20241016062359.264929-3-namhyung@kernel.org> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241016062359.264929-1-namhyung@kernel.org> References: <20241016062359.264929-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. Reviewed-by: Ian Rogers Acked-by: Kan Liang Reviewed-by: James Clark Reviewed-by: Ravi Bangoria Cc: Mark Rutland 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..099ce3ebf67ce6ee 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_GH_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 3050298bd6140d64..91499405fff4d32b 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 78e999f03d2d75f4..727683f249f66f5a 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -932,7 +932,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)); @@ -947,7 +947,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)) @@ -1072,7 +1072,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)); @@ -1222,7 +1222,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)); @@ -1437,7 +1437,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); @@ -1453,7 +1453,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)); @@ -1468,7 +1468,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); @@ -1497,7 +1497,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); @@ -1513,7 +1513,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 4507ae68198bd6a8..687125570f563382 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1740,7 +1740,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_GH_default) eG =3D 1; eu =3D 0; } diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 9d55a13787ce3c05..280c86d61d8a7956 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_GH_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_GH_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..4920e102ff54879a 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_GH_default; + extern bool perf_host; extern bool perf_guest; =20 --=20 2.47.0.rc1.288.g06298d1525-goog From nobody Tue Mar 11 05:08:09 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 499E8190686; Wed, 16 Oct 2024 06:24:03 +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=1729059843; cv=none; b=SPStZ6IL7MV7otD8FV+uUJ61eFBqKhtIska58TEbxSmlGUefOBowa464MsPndCyLJe+hupORXd09kkTAdRw8xFwV0RF78VkOcz9OOuXGgL+U54oibPqsshHPEg0bah5KaC7CmfCvvqecfE/9XZRw60NO4eacxaPGaa43nR996c4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729059843; c=relaxed/simple; bh=h3H1s+HDvAm6uYjvq5M56pT6DF5MvKcb0eyQMPgkL4w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kv9WbqYFnbPoRLbqllqn3ts4SZwsvMuzKB1s/c/RYe19InuMpLAM6YV24OgpKXmEbvrmR0/xdUdjqq7Lt4HNkph+uyvQpy55txqhDY4DWqhc/GMSzi9HP6+49hy59VvEQAQKX2xPrd98xjBInDLlDsrsIPEXJJelAtrslEBoIV0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=BbnYmFtX; 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="BbnYmFtX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EA8CC4CEC5; Wed, 16 Oct 2024 06:24:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729059843; bh=h3H1s+HDvAm6uYjvq5M56pT6DF5MvKcb0eyQMPgkL4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BbnYmFtXdetq2ewQI+eYRBH38cfgTbn+7RE87z7U2v/NpRl3kEwKkT5V60i5aNrdf 20oe5o1AmvdX61OdRnAxUG7TylGhJl0wZVhoOUbX1SLXm8zhG4K9FDbetWIBCgSZ2k +PcWsIumTvflplnnNeC4LmQzzEVshkytAROqWduXepFQSk1NbNHmkuhz3Ob/12h5Ym 0x+icjD87AAzAgMYC5knpBcD2V6eZLwldFVawS4toQ2a5l9H17axKsJZNf8JYTGuTx 0L3I7r3F1P1MDckmhCvMek9Vny3N6x2H6aP/SgVNTMNTPF/c418K61M4kzXfOGFhht Yr6wBfdK+oG4A== 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 v5 3/9] perf tools: Simplify evsel__add_modifier() Date: Tue, 15 Oct 2024 23:23:53 -0700 Message-ID: <20241016062359.264929-4-namhyung@kernel.org> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241016062359.264929-1-namhyung@kernel.org> References: <20241016062359.264929-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. Reviewed-by: Ian Rogers Acked-by: Kan Liang Reviewed-by: James Clark Reviewed-by: Ravi Bangoria 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 c965ec5676f8d54a..353b8da972bcfc54 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -517,7 +517,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) { \ @@ -529,17 +528,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.47.0.rc1.288.g06298d1525-goog From nobody Tue Mar 11 05:08:09 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 6B4BB199FD0; Wed, 16 Oct 2024 06:24:04 +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=1729059844; cv=none; b=A4EJoC3Z4ijOxIvjY/stCHFchRF5r0bL69S38J7nVdXEYvIJAvFTIzYp2foii5J4eWxHzLIqHmqmYKmo476ZgjXjaU6nZQ7LEPCUSMaTbH3BpgYRLiwIsETk7kHx60KED+ur+vJbIKr036u413I7UBP8wICk7L2FDE3rqHCIRZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729059844; c=relaxed/simple; bh=gfIUl0frZC2vYd/pJlh2y+Fr3OBIfZxRSU+NdtZ02po=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nogaLx3PtNsZ9UWY6g7UXc2d5hvqYAP16LIj+KChr0m9tavB7l/YSpOUxTbrR4EmItfhN+inkWSSkQGGaeQuO6OXWx0s9Z0CdmDzBta7ihf1xPZIPV0lGEUhTUiENgzEQTp9/Cf/ygbbJyppQL5k1B9Jt3zNErLF0caXe8N0CIA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=INT3wGXP; 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="INT3wGXP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49BA6C4CED0; Wed, 16 Oct 2024 06:24:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729059843; bh=gfIUl0frZC2vYd/pJlh2y+Fr3OBIfZxRSU+NdtZ02po=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=INT3wGXPKN6iNyv15wX3xWWzlYRsUUUw1a0iSwFqyqhpw80P0sio+8vjnA70xU/+c aIXJhAgqK/dSlE1hFRjzPfJ+2+Uhm26b+nuDEQzzfWoXsTUMfhH/nXXa8nAn4Ss39w uRg2dZuI/6clEgXAhN5/9fjKb4sEt31kS8SkPJhSz9F7EjfuVWU3MtFaNBFzpsyptp Kpf4v4SEy9VB19b75NeEKjQQq1bEjWqb1LxKxgeqvRCj7astSXVfFtR2cMp6AWHBTu xnYZ/G4xmyKQsM8chZGJwhbxfhT9bJOuXrfKzCb6HjrizzUI0w9nqCsWrlWXZoQ84v zmzjSJ5+CTRwA== 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 v5 4/9] perf tools: Do not set exclude_guest for precise_ip Date: Tue, 15 Oct 2024 23:23:54 -0700 Message-ID: <20241016062359.264929-5-namhyung@kernel.org> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241016062359.264929-1-namhyung@kernel.org> References: <20241016062359.264929-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. Reviewed-by: Ian Rogers Acked-by: Kan Liang Reviewed-by: James Clark Reviewed-by: Ravi Bangoria 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 727683f249f66f5a..82a19674a38f774e 100644 --- a/tools/perf/tests/parse-events.c +++ b/tools/perf/tests/parse-events.c @@ -898,8 +898,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)); @@ -1016,9 +1015,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", @@ -1103,8 +1101,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); @@ -1122,8 +1119,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 687125570f563382..afeb8d815bbff26d 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1733,10 +1733,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.47.0.rc1.288.g06298d1525-goog From nobody Tue Mar 11 05:08:09 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 125111AE875; Wed, 16 Oct 2024 06:24:04 +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=1729059845; cv=none; b=vFMv5mxt8+93g0Ygc4xLInIE6ayblx3jYDJeWIaheOH1p2L1QXt3wbLIeX5/p6y9cBxNPRyhAOwqQKmBlOi3AnRxs2moIUKeXc2MdwtGRJ/w4aMN1j3TUyXlJxcMP131ZN9UqNXRpTHjzjqNgPfSJv2maACIo0emJ0+BoG1GKvA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729059845; c=relaxed/simple; bh=wOC3wbvjULyv4qDchNgQPs64pdP2NWEZY6UxX/KhnY0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mn4A8U31kyE1DAdvTPviS/jbaHoptZKeM41HXhXoFIqSS9Gw4nHHiDbFWGd3OxjaTDeZ4h9qWbJVS3AeHLA7eT3XQwS8kbmTO/Q8zQWMgaR6DhdWd4TNdDs+z4q2mvfhkGR2fx+YkUppXY0X9seMDgfI03/TWORDKBRE4kQM3IE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nkFkL5Ny; 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="nkFkL5Ny" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1562FC4CECE; Wed, 16 Oct 2024 06:24:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729059844; bh=wOC3wbvjULyv4qDchNgQPs64pdP2NWEZY6UxX/KhnY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nkFkL5NyKDNqFYu6TvS0q0Df5FoTKf/epGP2DGVTPAYMoXVRjiDJXsr3PYeUn2DxS 6m3tvadJkscj2stJ2ti/CX68yr1O8dfqFm/Ao4DwJhR9WlKooDmGKkNO48HEPY+quG m7E5/vkt+T1BA5rUmw/JiGcCt5hQSekcfaXoc6PF7S14Kltf7Gi+P07N+KLtcBmZlh 8T4afVLlivrAhv1TTYm6+SNXOzmPD5zjvxKCeCWwmCLkaG00YBzSyitdQWWz4SBA/m 8rfcmJ8SNEKIzCmW07okWk/de3L3t+2SD7gsRfmJk+q40MdOBq6epwftVjSe+AIUaF KziClYXQZxgWA== 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 v5 5/9] perf tools: Detect missing kernel features properly Date: Tue, 15 Oct 2024 23:23:55 -0700 Message-ID: <20241016062359.264929-6-namhyung@kernel.org> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241016062359.264929-1-namhyung@kernel.org> References: <20241016062359.264929-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. Acked-by: Kan Liang Reviewed-by: James Clark Reviewed-by: Ravi Bangoria Signed-off-by: Namhyung Kim --- tools/perf/util/evsel.c | 403 ++++++++++++++++++++++++++++++---------- tools/perf/util/evsel.h | 1 - tools/perf/util/pmu.h | 4 + 3 files changed, 307 insertions(+), 101 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 353b8da972bcfc54..a7213cfa75f31150 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -1964,125 +1965,327 @@ 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_pmu_features(struct evsel *evsel) +{ + struct perf_event_attr attr =3D { + .type =3D evsel->core.attr.type, + .config =3D evsel->core.attr.config, + .disabled =3D 1, + }; + struct perf_pmu *pmu =3D evsel->pmu; + int old_errno; + + old_errno =3D errno; + + if (pmu =3D=3D NULL) + pmu =3D evsel->pmu =3D evsel__find_pmu(evsel); + + if (pmu =3D=3D NULL || pmu->missing_features.checked) + goto out; + /* * 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.inherit_sample_read && - evsel->core.attr.inherit && (evsel->core.attr.sample_type & PERF_SAMP= LE_READ)) { - perf_missing_features.inherit_sample_read =3D true; - pr_debug2("Using PERF_SAMPLE_READ / :S modifier is not compatible with i= nherit, falling back to no-inherit.\n"); - return true; - } else 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"); + + /* Please add new feature detection here. */ + + attr.exclude_guest =3D 1; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + pmu->missing_features.exclude_guest =3D true; + pr_debug2("switching off exclude_guest for PMU %s\n", pmu->name); + +found: + pmu->missing_features.checked =3D true; +out: + errno =3D old_errno; +} + +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. These are PMU specific limitation + * so we can detect with the given hardware event and stop on the + * first one succeeded. + */ + + /* 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; + + evsel__detect_missing_pmu_features(evsel); + + 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.inherit =3D true; + attr.sample_type =3D PERF_SAMPLE_READ; + if (has_attr_feature(&attr, /*flags=3D*/0)) + goto found; + perf_missing_features.inherit_sample_read =3D true; + pr_debug2("Using PERF_SAMPLE_READ / :S modifier is not compatible with in= herit, falling back to no-inherit.\n"); + attr.inherit =3D false; + attr.sample_type =3D 0; + + 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.inherit && + (evsel->core.attr.sample_type & PERF_SAMPLE_READ) && + perf_missing_features.inherit_sample_read) 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"); + + 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 9fcaf417b277859e..04934a7af174524e 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -343,7 +343,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 diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index e400db9e9eb1581a..b86b3c3685a23cfb 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -170,6 +170,10 @@ struct perf_pmu { * exclude_host. */ bool exclude_guest; + /** + * @checked: Are the missing features checked? + */ + bool checked; } missing_features; =20 /** --=20 2.47.0.rc1.288.g06298d1525-goog From nobody Tue Mar 11 05:08:09 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 E6F481B2185; Wed, 16 Oct 2024 06:24:05 +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=1729059846; cv=none; b=Iotk+i61nKlSp/FApvYUGmySFqj0VUwtwsa+avnQmBMs3ZRjknsBCo68uQtaF67Fu8o13mATwLddQT22l0pwnml2aMuFTcS+las+s09DP2K+J0DLHg9wcHhQFeOPiRwFwQBOgYtjGIltows2t7Uiv53GpVO8pJM5eVga+7j9GEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729059846; c=relaxed/simple; bh=4u2/7ezE+cWeue94azvuOtqAysSTt8l2h1qfZ+QYrIY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hXOmlyFlRs6ybVJkEUCnjRu3+tFDLHfehIRVh7xfu99241I5P2y6B5VA8eiZKsbgt3AG8ir9liRWu4lth5y8lBXV4sS6XX1LrqOiKWU4GV5kuoevT+S/PlNG4lNQ2WfmgH5RQ864LbBgmvrak8Z8iST9Ej5GUMFXcFcGvMpIuPs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hhIMjroL; 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="hhIMjroL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2612C4CED5; Wed, 16 Oct 2024 06:24:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729059845; bh=4u2/7ezE+cWeue94azvuOtqAysSTt8l2h1qfZ+QYrIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hhIMjroLvSPwuDMpwrlguEJ9DcyquTNOp4sCqoLmfnh98y7GD6RqOVdg2U1iucbMl PqvMbGP9lMvOGOFSOFbHo5gtwtGkwF/ZeX5n7v1RjPAm9+IPFmtINp7Th9ab1sjwOl xez+Ve9+FVOHyOC4bb848Kc4hn8bxuJbpqS3/XD6YTmhg688QuDUCa8sYYdRu63r5i EhYOtLVwcK2yoJGjpVoFBFOno5OAgh4/CiSxkDoWy1MRCfyXzfGRKQ5BgLl/bu17cP HN639cH8V1m8MLraPsnrZs1S3uUbDH1fHDfTSCIMygFGvyDwtqakSSSo9dTuIKzO0f oIbpeNvFvzU9w== 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 v5 6/9] perf tools: Move x86__is_amd_cpu() to util/env.c Date: Tue, 15 Oct 2024 23:23:56 -0700 Message-ID: <20241016062359.264929-7-namhyung@kernel.org> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241016062359.264929-1-namhyung@kernel.org> References: <20241016062359.264929-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. Acked-by: Kan Liang Reviewed-by: James Clark Reviewed-by: Ravi Bangoria 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 1edbccfc3281d2b1..ccb4640266428947 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 @@ -639,3 +640,25 @@ void perf_env__find_br_cntr_info(struct perf_env *env, env->pmu_caps->br_cntr_width; } } + +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 51b36c36019be666..ae604c4edbb7eb44 100644 --- a/tools/perf/util/env.h +++ b/tools/perf/util/env.h @@ -195,4 +195,8 @@ bool perf_env__has_pmu_mapping(struct perf_env *env, co= nst char *pmu_name); void perf_env__find_br_cntr_info(struct perf_env *env, unsigned int *nr, unsigned int *width); + +bool x86__is_amd_cpu(void); +bool perf_env__is_x86_amd_cpu(struct perf_env *env); + #endif /* __PERF_ENV_H */ --=20 2.47.0.rc1.288.g06298d1525-goog From nobody Tue Mar 11 05:08:09 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 AA5401B395F; Wed, 16 Oct 2024 06:24:06 +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=1729059846; cv=none; b=ASAR5uUV3apkLOB5re1QOZXcTThb+nFJVLqNx537HmJ3V1CrJfwG9AVgmKDXTeNPgfy9F3mMwt2KtP9w3DhVqeFMxVIkTJHAVCnvhIqXqI6XQsug+JCEun1dbD3X0+LMBEFlNT6qQAZNguliGHB2lsqDu/iico90QeQMihzGBEM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729059846; c=relaxed/simple; bh=rnRrIKaQslEqNn8T+FG377t3JCt5vKicziBWbvSfEEI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=udieJi1eYAbHOcjLM3HhM6uRxdMEYJQw4vAxbKiMroIEAhhj+8r8L9hKN1h1kj3UWVUCtUCBEfYRYk9X7pKxwNimIsHCOy7c0Y9b5cLQyISltAkPYmtL5fzyoUR0Agtk6vMMd/79y6AxdeT4u7GX7dFicXkL6b/jmme22Icl+z8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eMK1NizS; 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="eMK1NizS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E120C4CED4; Wed, 16 Oct 2024 06:24:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729059846; bh=rnRrIKaQslEqNn8T+FG377t3JCt5vKicziBWbvSfEEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eMK1NizSlWoQSIRj/eK5RnqG8te6h/Lh3wDLjiqC9ZDNJELcWV3CedJh8eHPbixwj j2b9njw9bF4j9V4yyP0FGhrpcZwCs20xVD0G8lXluE4SXL6zhOXKP/ZDUVnfgoI3UK 3ma6x8L3aALbn1KHVGOq08dwHdOXJINjZ6uHlPhJQbi1gLUzT9sSusKEJlb3ubacnh iMRVwyrxeOiyZESKCUZ823bkBVolMbMe81xQ/CnCRNeHYUPeYMAIvksrilMPa22VqW wVhRDgw6/8HwC4zZZUBP7HklC3zPKcfT//09ujHDPgIVxve/xM0ZqKHc3/eXG15hUf oH+1Fm8pAk+hA== 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 v5 7/9] perf tools: Check fallback error and order Date: Tue, 15 Oct 2024 23:23:57 -0700 Message-ID: <20241016062359.264929-8-namhyung@kernel.org> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241016062359.264929-1-namhyung@kernel.org> References: <20241016062359.264929-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. Acked-by: Kan Liang Reviewed-by: James Clark Reviewed-by: Ravi Bangoria Signed-off-by: Namhyung Kim --- tools/perf/util/evsel.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index a7213cfa75f31150..68380d08a21c5a36 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -2060,9 +2060,9 @@ static void evsel__detect_missing_brstack_features(st= ruct evsel *evsel) =20 /* * Must probe features in the order they were added to the - * 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. + * perf_event_attr interface. These are kernel core limitation but + * specific to PMUs with branch stack. So we can detect with the given + * hardware event and stop on the first one succeeded. */ =20 /* Please add new feature detection here. */ @@ -2288,6 +2288,25 @@ 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 core PMU tries to forward events with precise_ip to IBS PMU + * implicitly. But IBS PMU has more restrictions so it can fail with + * supported event attributes. Let's forward it back to the core PMU + * by clearing precise_ip only if it's from precise_max (:P). + */ + if ((error =3D=3D -EINVAL || error =3D=3D -ENOENT) && x86__is_amd_cpu() && + evsel->core.attr.precise_ip && evsel->precise_max) { + 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) @@ -2408,9 +2427,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. */ @@ -2427,11 +2443,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.47.0.rc1.288.g06298d1525-goog From nobody Tue Mar 11 05:08:09 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 768A11BBBC8; Wed, 16 Oct 2024 06:24:07 +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=1729059847; cv=none; b=O/tWLXsPZQVfUQ9of3kmRYoNNqxkJFSFBOBIkH9M3/ATK8DHwWrFTzewsWkq4DrasKjZAJs/N1c3/rk8zArlVhOtKo4h3McYALgvbP3DO6IaqFKJxmvH0HPrqouJPRJGnvgrZLEaLhF3pFMwnWhapkQHEHks7h2LL0TVq2FlD+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729059847; c=relaxed/simple; bh=YduFT+h2EYjPQi9RMbXm5/YsBmtNRq8tS/1Xljb0YZ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=vEyZ7QuyZICwbeWwAOzAVHHoaGd65PcQ1fogDz1gWG6CTW5jGaPDfXmz2Ws9cf2CfaLc9v9P5J9WSIi7F0ysaFdKylVa7xZmoxZQB8ZaNon5P+9KU8ecSu9E8zsMw6AyQGKldFvaxpPtemeJ+0zIu+hyyrcPsZ+dHQBlSYDVZ9M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lnfM4iAb; 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="lnfM4iAb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 693CEC4AF0D; Wed, 16 Oct 2024 06:24:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729059847; bh=YduFT+h2EYjPQi9RMbXm5/YsBmtNRq8tS/1Xljb0YZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lnfM4iAbkoaUIgyh5gSZ5Hn57ueylPwic4tvZdeiXbWpSFCGjpkjAentiAoCW41Jj /GAgLKgRpNQbQ2YQWR8sYsN1QuPr9mN56RAnhucROVeB6WWjGgw6K3pd5L8+FIgnJU ZAHIaY5XKj9YhBC3cZRf4etRHi69YvSMnid/4eWKw/pXr93K8fWefWhd5Ztk2wAiYD zGZcVYmXOUPN7K+Qi/+FsOo3L9PPbhw1GTHeLw+GAJWwKXotC/X8ImYxlFYvf+WTGW cHyHy+7/wgeVv6BjGt5s+bYFRnVAcxxnX9LC0AfLrTIBN0b4LNM2moo8jzujSYPp/x 7i2+nH0FEKt9Q== 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 v5 8/9] perf record: Just use "cycles:P" as the default event Date: Tue, 15 Oct 2024 23:23:58 -0700 Message-ID: <20241016062359.264929-9-namhyung@kernel.org> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241016062359.264929-1-namhyung@kernel.org> References: <20241016062359.264929-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. Reviewed-by: Ian Rogers Acked-by: Kan Liang Reviewed-by: James Clark Reviewed-by: Ravi Bangoria 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.47.0.rc1.288.g06298d1525-goog From nobody Tue Mar 11 05:08:09 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 3E78E1C233A; Wed, 16 Oct 2024 06:24:07 +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=1729059848; cv=none; b=lFU/VGR2qSSXKVjzBNtwHoLQayXdxOYMrXObqFAnSlBeKC99r0MdAtO+3fHL+d/xFrt95xgVuJSZYRKqU5DJ9UesXwqyPHagrHfedWPUDbV15BBO30mTJo6v2Gcidn6LETkVRXfwWobJSqkl+wNAwiJ+L6LV7dqQFGRzKOUzHpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729059848; c=relaxed/simple; bh=OEMIX3Py57TTYZipJctDBI2XnKZ9J1B9wCuvXhKmHuM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Zjo2nJ4eG+MxhwCVTEosX3pKKC1pGNIsg3/vr4OCYAO81JrJJVM7XNKiCLCzsMB+250wjQ0rdt5wkHnJYQOqwlJIZXpgWVQezQSDg7iGZfC1h9qNPOnbKEpV9PoqZSL5ks7S/BWWYSrGA3I33+VmzY87kKYCEtwaxH1C6Eg7iCc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hAWZmH8j; 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="hAWZmH8j" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33846C4AF0E; Wed, 16 Oct 2024 06:24:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729059847; bh=OEMIX3Py57TTYZipJctDBI2XnKZ9J1B9wCuvXhKmHuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hAWZmH8jjihHsVx/4phlnScWheuIoYmDZi/Gp6pXjgpcll8V8i4k5JwL6l6fqdmMW qkjXlqWI56Ezk5Y1sM3IiHmfwpNzKMSsD3DgzytwW+pBu9Y2hbUvP5eW2HqumvuG0f JGp3lUw1vJjziWEpKfu36ytZziNnlBi0wJKT2A5H5tqDWWpK5Y+jNRj4Vlc6IGwak/ AWQmPH221Ck1XYLedMBbMLHw4VkT5kHOw4f0VPxdGDg9m6rNe9Urv96QZ576yVsi2B 0klvJFxdba5W3sZkZU8QgD2w8tB5/8uhRJko1qBL+3/vIl4CV7XJyY2gRKJj/m6NkA 4hG01j+7q2pPA== 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 v5 9/9] perf test: Add precise_max subtest to the perf record shell test Date: Tue, 15 Oct 2024 23:23:59 -0700 Message-ID: <20241016062359.264929-10-namhyung@kernel.org> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241016062359.264929-1-namhyung@kernel.org> References: <20241016062359.264929-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's a very simply test just to run with cycles:P and instructions:P events. Signed-off-by: Namhyung Kim --- tools/perf/tests/shell/record.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/reco= rd.sh index 8d6366d96883edb3..b23e83a099f84a65 100755 --- a/tools/perf/tests/shell/record.sh +++ b/tools/perf/tests/shell/record.sh @@ -271,6 +271,30 @@ test_topdown_leader_sampling() { echo "Topdown leader sampling test [Success]" } =20 +test_precise_max() { + echo "precise_max attribute test" + if ! perf stat -e "cycles,instructions" true 2> /dev/null + then + echo "precise_max attribute [Skipped no hardware events]" + return + fi + # Just to make sure it doesn't fail + if ! perf record -o "${perfdata}" -e "cycles:P" true 2> /dev/null + then + echo "precise_max attribute [Failed cycles:P event]" + err=3D1 + return + fi + # On AMD, cycles and instructions events are treated differently + if ! perf record -o "${perfdata}" -e "instructions:P" true 2> /dev/null + then + echo "precise_max attribute [Failed instructions:P event]" + err=3D1 + return + fi + echo "precise_max attribute test [Success]" +} + # raise the limit of file descriptors to minimum if [[ $default_fd_limit -lt $min_fd_limit ]]; then ulimit -Sn $min_fd_limit @@ -284,6 +308,7 @@ test_branch_counter test_cgroup test_leader_sampling test_topdown_leader_sampling +test_precise_max =20 # restore the default value ulimit -Sn $default_fd_limit --=20 2.47.0.rc1.288.g06298d1525-goog