Linux Power Management development
 help / color / mirror / Atom feed
From: "xiongyining1480@phytium.com.cn" <xiongyining1480@phytium.com.cn>
Cc: linux-pm <linux-pm@vger.kernel.org>,
	 linux-kselftest <linux-kselftest@vger.kernel.org>,
	 linux-kernel <linux-kernel@vger.kernel.org>
Subject: 回复: Re: [PATCH v2] selftests: cpufreq: stop CPU hotplug loop after cpufreq update test
Date: Fri, 30 Oct 2026 18:39:20 +0800	[thread overview]
Message-ID: <202610301839207103055@phytium.com.cn> (raw)
In-Reply-To: b228d3c3-ac4b-43df-8829-edb9c459860d@oss.qualcomm.com

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

      reply	other threads:[~2026-10-30 10:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-28 10:02 [PATCH v2] selftests: cpufreq: stop CPU hotplug loop after cpufreq update test xiong yining
2026-10-28 14:41 ` Zhongqiu Han
2026-10-30 10:39   ` xiongyining1480 [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=202610301839207103055@phytium.com.cn \
    --to=xiongyining1480@phytium.com.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    /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