From: "Chen, Zide" <zide.chen@intel.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Ingo Molnar <mingo@redhat.com>, Jiri Olsa <jolsa@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Ian Rogers <irogers@google.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
thomas.falcon@intel.com, dapeng1.mi@linux.intel.com,
xudong.hao@intel.com
Subject: Re: [PATCH] perf test: Add a perf event fallback test
Date: Tue, 11 Nov 2025 17:39:00 -0800 [thread overview]
Message-ID: <48f84128-bd74-4d82-8095-4b21e386bd81@intel.com> (raw)
In-Reply-To: <aRPdmoNdUWIlWhJU@google.com>
On 11/11/2025 5:06 PM, Namhyung Kim wrote:
> On Tue, Nov 11, 2025 at 02:42:46PM -0800, Zide Chen wrote:
>> This adds test cases to verify the precise ip fallback logic:
>>
>> - If the system supports precise ip, for an event given with the maximum
>> precision level, it should be able to decrease precise_ip to find a
>> supported level.
>> - The same fallback behavior should also work in more complex scenarios,
>> such as event groups or when PEBS is involved
>>
>> Additional fallback tests, such as those covering missing feature cases,
>> can be added in the future.
>>
>> Suggested-by: Ian Rogers <irogers@google.com>
>> Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
>> Signed-off-by: Zide Chen <zide.chen@intel.com>
>> ---
>> .../tests/shell/test_event_open_fallback.sh | 86 +++++++++++++++++++
>> 1 file changed, 86 insertions(+)
>> create mode 100755 tools/perf/tests/shell/test_event_open_fallback.sh
>>
>> diff --git a/tools/perf/tests/shell/test_event_open_fallback.sh b/tools/perf/tests/shell/test_event_open_fallback.sh
>> new file mode 100755
>> index 000000000000..72c1ac32c785
>> --- /dev/null
>> +++ b/tools/perf/tests/shell/test_event_open_fallback.sh
>> @@ -0,0 +1,86 @@
>> +#!/bin/bash
>> +# Perf event open fallback test
>> +# SPDX-License-Identifier: GPL-2.0
>> +
>> +skip_cnt=0
>> +ok_cnt=0
>> +err_cnt=0
>> +
>> +cleanup()
>> +{
>> + rm -f perf.data
>> + rm -f perf.data.old
>> + trap - EXIT TERM INT
>> +}
>> +
>> +trap_cleanup()
>> +{
>> + cleanup
>> + exit 1
>> +}
>> +
>> +trap trap_cleanup EXIT TERM INT
>> +
>> +perf_record()
>> +{
>> + perf record "$@" -- true 1>/dev/null 2>&1
>> +}
>> +
>> +test_decrease_precise_ip()
>> +{
>> + echo "Decrease precise ip test"
>> +
>> + perf list pmu | grep -q 'cycles' || return 2
>> +
>> + if ! perf_record -e cycles; then
>> + return 2
>> + fi
>> +
>> + # It should reduce precision level down to 0 if needed.
>> + if ! perf_record -e cycles:ppp; then
>
> I think you need 'P' instead of 'ppp' for automatic precision.
Yes, it's better with "-e cycles:P" to explicitly set evsel.precise_max
to 1.
> Thanks,
> Namhyung
>
>
>> + return 1
>> + fi
>> + return 0
>> +}
>> +
>> +test_decrease_precise_ip_complicated()
>> +{
>> + echo "Decrease precise ip test (complicated case)"
>> +
>> + perf list pmu | grep -q 'mem-loads-aux' || return 2
>> +
>> + if ! perf_record -e '{cpu/mem-loads-aux/S,cpu/mem-loads/PS}'; then
>> + return 1
>> + fi
>> + return 0
>> +}
>> +
>> +count_result()
>> +{
>> + if [ "$1" -eq 2 ] ; then
>> + skip_cnt=$((skip_cnt + 1))
>> + return
>> + fi
>> + if [ "$1" -eq 0 ] ; then
>> + ok_cnt=$((ok_cnt + 1))
>> + return
>> + fi
>> + err_cnt=$((err_cnt + 1))
>> +}
>> +
>> +ret=0
>> +test_decrease_precise_ip || ret=$? ; count_result $ret ; ret=0
>> +test_decrease_precise_ip_complicated || ret=$? ; count_result $ret ; ret=0
>> +
>> +cleanup
>> +
>> +if [ ${err_cnt} -gt 0 ] ; then
>> + exit 1
>> +fi
>> +
>> +if [ ${ok_cnt} -gt 0 ] ; then
>> + exit 0
>> +fi
>> +
>> +# Skip
>> +exit 2
>> --
>> 2.51.1
>>
prev parent reply other threads:[~2025-11-12 1:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-11 22:42 [PATCH] perf test: Add a perf event fallback test Zide Chen
2025-11-12 1:06 ` Namhyung Kim
2025-11-12 1:39 ` Chen, Zide [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48f84128-bd74-4d82-8095-4b21e386bd81@intel.com \
--to=zide.chen@intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=thomas.falcon@intel.com \
--cc=xudong.hao@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox