回复: Re: [PATCH v2] selftests: cpufreq: stop CPU hotplug loop after cpufreq update test

From: xiongyining1480@xxxxxxxxxxxxxx

Date: Fri Oct 30 2026 - 06:48:26 EST


Hi,

Thank you for the review and the test script.

> The changelog still describes the v1 stop-file approach; please
> update it.

Right, thanks for catching that. I’ll update the changelog to describe the
current approach.

> The background hotplug loop is now started before switching to ondemand
> and before reading scaling_available_frequencies / scaling_min_freq. If
> the CPU happens to be offline at that point (such as single-CPU policy),
> those accesses return -EBUSY: the governor switch is lost, freqs is
> empty so the update loop does nothing while the test still passes, and
> oldfreq is empty so scaling_min_freq is not restored. Please start the
> hotplug subshell only after that setup is done.

Agreed. Starting it before governor switching and sysfs frequency reads can
hit -EBUSY if the target CPU is offline. I will launch the hotplug child only
after those setup steps finish.

> Bash runs the EXIT trap on SIGINT, SIGTERM, and SIGHUP, so I don't think
> additional traps are necessary. This issue occurs with Dash, but not
> with Bash.

Thanks for the comparison script and the test results — that's very helpful.
I agree that Bash runs the EXIT trap on SIGINT, SIGTERM, and SIGHUP. I tested
both the subshell case and the main-shell case:

When the signal is sent to the do_test subshell, the EXIT trap runs and cleanup
completes.

When this signal is sent to the main shell, the subshell does not receive it, keeps
running, and performs cleanup when it exits naturally.

Cleanup works correctly in both cases.

Sample simulation script:

#!/bin/bash


do_test() {
trap 'echo "EXIT trap ran"' EXIT
local sig="$1"
local target="$2"


case "$target" in
1)
echo "---- send $sig to do_test pid ----"
kill -"$sig" "$BASHPID"
;;
2)
echo "---- send $sig to main pid ----"
kill -"$sig" $$
;;
esac

echo "do_test finished"

}


export -f do_test

echo "---------sub shell-----------"
for sig in INT TERM HUP; do
bash -c "do_test '$sig' 1 | tee test.log"
done

echo "---------main shell-----------"
for sig in INT TERM HUP; do
bash -c "do_test '$sig' 2 | tee test.log" 2>/dev/null
done

output:
---------sub shell-----------
---- send INT to do_test pid ----
EXIT trap ran
---- send TERM to do_test pid ----
EXIT trap ran
---- send HUP to do_test pid ----
EXIT trap ran
---------main shell-----------
---- send INT to main pid ----
do_test finished
EXIT trap ran
Terminated
---- send TERM to main pid ----
do_test finished
EXIT trap ran
---- send HUP to main pid ----
do_test finished
EXIT trap ran


Thanks again for your useful test.
Best regards,
Yining Xiong