* [PATCH v1] perf test: Allow tolerance for leader sampling test
@ 2025-04-01 17:22 Chun-Tse Shao
2025-04-01 19:51 ` Ian Rogers
2025-04-03 5:26 ` Namhyung Kim
0 siblings, 2 replies; 3+ messages in thread
From: Chun-Tse Shao @ 2025-04-01 17:22 UTC (permalink / raw)
To: linux-kernel
Cc: Chun-Tse Shao, Ian Rogers, Thomas Richter, peterz, mingo, acme,
namhyung, mark.rutland, alexander.shishkin, jolsa, adrian.hunter,
kan.liang, james.clark, dapeng1.mi, vmolnaro, linux-perf-users
There is a known issue that the leader sampling is inconsistent, since
throttle only affect leader, not the slave. The detail is in [1]. To
maintain test coverage, this patch sets a tolerance rate of 80% to
accommodate the throttled samples and prevent test failures due to
throttling.
[1] lore.kernel.org/20250328182752.769662-1-ctshao@google.com
Signed-off-by: Chun-Tse Shao <ctshao@google.com>
Suggested-by: Ian Rogers <irogers@google.com>
Suggested-by: Thomas Richter <tmricht@linux.ibm.com>
Tested-by: Thomas Richter <tmricht@linux.ibm.com>
---
tools/perf/tests/shell/record.sh | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
index ba8d873d3ca7..1bbe16fb3420 100755
--- a/tools/perf/tests/shell/record.sh
+++ b/tools/perf/tests/shell/record.sh
@@ -238,22 +238,35 @@ test_leader_sampling() {
err=1
return
fi
+ perf script -i "${perfdata}" | grep brstack > $script_output
+ # Check if the two instruction counts are equal in each record.
+ # However, the throttling code doesn't consider event grouping. During throttling, only the
+ # leader is stopped, causing the slave's counts significantly higher. To temporarily solve this,
+ # let's set the tolerance rate to 80%.
+ # TODO: Revert the code for tolerance once the throttling mechanism is fixed.
index=0
- perf script -i "${perfdata}" > $script_output
+ valid_counts=0
+ invalid_counts=0
+ tolerance_rate=0.8
while IFS= read -r line
do
- # Check if the two instruction counts are equal in each record
cycles=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="cycles:") print $(i-1)}')
if [ $(($index%2)) -ne 0 ] && [ ${cycles}x != ${prev_cycles}x ]
then
- echo "Leader sampling [Failed inconsistent cycles count]"
- err=1
- return
+ invalid_counts=$(($invalid_counts+1))
+ else
+ valid_counts=$(($valid_counts+1))
fi
index=$(($index+1))
prev_cycles=$cycles
done < $script_output
- echo "Basic leader sampling test [Success]"
+ if [[ "$(echo "scale=2; $invalid_counts/($invalid_counts+$valid_counts)" | bc)" > 1-$tolerance_rate ]]
+ then
+ echo "Leader sampling [Failed inconsistent cycles count]"
+ err=1
+ else
+ echo "Basic leader sampling test [Success]"
+ fi
}
test_topdown_leader_sampling() {
--
2.49.0.472.ge94155a9ec-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v1] perf test: Allow tolerance for leader sampling test
2025-04-01 17:22 [PATCH v1] perf test: Allow tolerance for leader sampling test Chun-Tse Shao
@ 2025-04-01 19:51 ` Ian Rogers
2025-04-03 5:26 ` Namhyung Kim
1 sibling, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2025-04-01 19:51 UTC (permalink / raw)
To: Chun-Tse Shao
Cc: linux-kernel, Thomas Richter, peterz, mingo, acme, namhyung,
mark.rutland, alexander.shishkin, jolsa, adrian.hunter, kan.liang,
james.clark, dapeng1.mi, vmolnaro, linux-perf-users
On Tue, Apr 1, 2025 at 10:23 AM Chun-Tse Shao <ctshao@google.com> wrote:
>
> There is a known issue that the leader sampling is inconsistent, since
> throttle only affect leader, not the slave. The detail is in [1]. To
> maintain test coverage, this patch sets a tolerance rate of 80% to
> accommodate the throttled samples and prevent test failures due to
> throttling.
>
> [1] lore.kernel.org/20250328182752.769662-1-ctshao@google.com
>
> Signed-off-by: Chun-Tse Shao <ctshao@google.com>
> Suggested-by: Ian Rogers <irogers@google.com>
> Suggested-by: Thomas Richter <tmricht@linux.ibm.com>
> Tested-by: Thomas Richter <tmricht@linux.ibm.com>
Reviewed-by: Ian Rogers <irogers@google.com>
Thanks,
Ian
> ---
> tools/perf/tests/shell/record.sh | 25 +++++++++++++++++++------
> 1 file changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index ba8d873d3ca7..1bbe16fb3420 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -238,22 +238,35 @@ test_leader_sampling() {
> err=1
> return
> fi
> + perf script -i "${perfdata}" | grep brstack > $script_output
> + # Check if the two instruction counts are equal in each record.
> + # However, the throttling code doesn't consider event grouping. During throttling, only the
> + # leader is stopped, causing the slave's counts significantly higher. To temporarily solve this,
> + # let's set the tolerance rate to 80%.
> + # TODO: Revert the code for tolerance once the throttling mechanism is fixed.
> index=0
> - perf script -i "${perfdata}" > $script_output
> + valid_counts=0
> + invalid_counts=0
> + tolerance_rate=0.8
> while IFS= read -r line
> do
> - # Check if the two instruction counts are equal in each record
> cycles=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="cycles:") print $(i-1)}')
> if [ $(($index%2)) -ne 0 ] && [ ${cycles}x != ${prev_cycles}x ]
> then
> - echo "Leader sampling [Failed inconsistent cycles count]"
> - err=1
> - return
> + invalid_counts=$(($invalid_counts+1))
> + else
> + valid_counts=$(($valid_counts+1))
> fi
> index=$(($index+1))
> prev_cycles=$cycles
> done < $script_output
> - echo "Basic leader sampling test [Success]"
> + if [[ "$(echo "scale=2; $invalid_counts/($invalid_counts+$valid_counts)" | bc)" > 1-$tolerance_rate ]]
> + then
> + echo "Leader sampling [Failed inconsistent cycles count]"
> + err=1
> + else
> + echo "Basic leader sampling test [Success]"
> + fi
> }
>
> test_topdown_leader_sampling() {
> --
> 2.49.0.472.ge94155a9ec-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v1] perf test: Allow tolerance for leader sampling test
2025-04-01 17:22 [PATCH v1] perf test: Allow tolerance for leader sampling test Chun-Tse Shao
2025-04-01 19:51 ` Ian Rogers
@ 2025-04-03 5:26 ` Namhyung Kim
1 sibling, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2025-04-03 5:26 UTC (permalink / raw)
To: Chun-Tse Shao
Cc: linux-kernel, Ian Rogers, Thomas Richter, peterz, mingo, acme,
mark.rutland, alexander.shishkin, jolsa, adrian.hunter, kan.liang,
james.clark, dapeng1.mi, vmolnaro, linux-perf-users
Hello,
On Tue, Apr 01, 2025 at 10:22:39AM -0700, Chun-Tse Shao wrote:
> There is a known issue that the leader sampling is inconsistent, since
> throttle only affect leader, not the slave. The detail is in [1]. To
> maintain test coverage, this patch sets a tolerance rate of 80% to
> accommodate the throttled samples and prevent test failures due to
> throttling.
>
> [1] lore.kernel.org/20250328182752.769662-1-ctshao@google.com
>
> Signed-off-by: Chun-Tse Shao <ctshao@google.com>
> Suggested-by: Ian Rogers <irogers@google.com>
> Suggested-by: Thomas Richter <tmricht@linux.ibm.com>
> Tested-by: Thomas Richter <tmricht@linux.ibm.com>
> ---
> tools/perf/tests/shell/record.sh | 25 +++++++++++++++++++------
> 1 file changed, 19 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/tests/shell/record.sh b/tools/perf/tests/shell/record.sh
> index ba8d873d3ca7..1bbe16fb3420 100755
> --- a/tools/perf/tests/shell/record.sh
> +++ b/tools/perf/tests/shell/record.sh
> @@ -238,22 +238,35 @@ test_leader_sampling() {
> err=1
> return
> fi
> + perf script -i "${perfdata}" | grep brstack > $script_output
> + # Check if the two instruction counts are equal in each record.
> + # However, the throttling code doesn't consider event grouping. During throttling, only the
> + # leader is stopped, causing the slave's counts significantly higher. To temporarily solve this,
> + # let's set the tolerance rate to 80%.
> + # TODO: Revert the code for tolerance once the throttling mechanism is fixed.
> index=0
> - perf script -i "${perfdata}" > $script_output
> + valid_counts=0
> + invalid_counts=0
> + tolerance_rate=0.8
> while IFS= read -r line
> do
> - # Check if the two instruction counts are equal in each record
> cycles=$(echo $line | awk '{for(i=1;i<=NF;i++) if($i=="cycles:") print $(i-1)}')
> if [ $(($index%2)) -ne 0 ] && [ ${cycles}x != ${prev_cycles}x ]
> then
> - echo "Leader sampling [Failed inconsistent cycles count]"
> - err=1
> - return
> + invalid_counts=$(($invalid_counts+1))
> + else
> + valid_counts=$(($valid_counts+1))
> fi
> index=$(($index+1))
> prev_cycles=$cycles
> done < $script_output
> - echo "Basic leader sampling test [Success]"
> + if [[ "$(echo "scale=2; $invalid_counts/($invalid_counts+$valid_counts)" | bc)" > 1-$tolerance_rate ]]
Shouldn't it be double parenthesis to use numeric comparisons?
Also I'm not sure if bash supports floating-point arithmetic.
It'd be better to compare the value in bc and use its return value.
Thanks,
Namhyung
> + then
> + echo "Leader sampling [Failed inconsistent cycles count]"
> + err=1
> + else
> + echo "Basic leader sampling test [Success]"
> + fi
> }
>
> test_topdown_leader_sampling() {
> --
> 2.49.0.472.ge94155a9ec-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-03 5:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-01 17:22 [PATCH v1] perf test: Allow tolerance for leader sampling test Chun-Tse Shao
2025-04-01 19:51 ` Ian Rogers
2025-04-03 5:26 ` Namhyung Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox