From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: sashiko-reviews@lists.linux.dev
Cc: virtualization@lists.linux.dev,
Eugenio Perez <eperezma@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH v13 13/13] virt/steal_governor: Enable the driver
Date: Wed, 9 Sep 2026 22:28:08 +0530 [thread overview]
Message-ID: <9fb85c37-a886-46ae-b738-f0eadf3dd468@linux.ibm.com> (raw)
In-Reply-To: <20260909141723.AF5971F00A3D@smtp.kernel.org>
On 9/9/26 7:47 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] preferred_cpus_valid() reads cpu_preferred_mask and cpu_active_mask without holding cpus_read_lock(), creating a data race with CPU hotplug that causes the governor to permanently shut down.
> --
>
> commit b0d791ea69ac4f874448d3baf935e4825cba622f
> Author: Shrikanth Hegde <sshegde@linux.ibm.com>
>
> virt/steal_governor: Enable the driver
>
> This commit provides a configuration option to enable the steal_governor driver
> for paravirtualized environments. It enforces PARAVIRT and SMP dependencies and
> selects CONFIG_PREFERRED_CPU for core scheduler mechanisms.
>
>> diff --git a/drivers/virt/Kconfig b/drivers/virt/Kconfig
>> index 52eb7e4ba71f6..eeb84e578ddf9 100644
>> --- a/drivers/virt/Kconfig
>> +++ b/drivers/virt/Kconfig
>> @@ -41,6 +41,23 @@ config FSL_HV_MANAGER
>> 4) A kernel interface for receiving callbacks when a managed
>> partition shuts down.
>>
>> +config STEAL_GOVERNOR
>> + tristate "Dynamic vCPU management based on steal time"
>> + depends on PARAVIRT && SMP
>> + select PREFERRED_CPU
>
> [Severity: High]
> While this patch enables the driver, can the background loop in
> steal_governor_loop() permanently terminate during a concurrent CPU hotplug
> operation?
>
> If a CPU is offlined, sched_cpu_deactivate() clears the target CPU from
> cpu_preferred_mask and then cpu_active_mask without memory barriers. If this
> happens concurrently, preferred_cpus_valid() in drivers/virt/steal_governor.c
> might observe a torn state because it evaluates the masks without holding
> cpus_read_lock():
>
clear_bit is atomic operation. It cannot happen concurrently IMHO.
> drivers/virt/steal_governor.c:preferred_cpus_valid()
> if (!cpumask_subset(cpu_preferred_mask, cpu_active_mask)) {
> pr_err("preferred: %*pbl is not subset of active: ...\n",
> ...);
> return false;
> }
>
> If the check fails due to this race, the governor loop permanently shuts down
> since it returns instead of requeuing the work:
Even if it happens, it is safe to shut down, rather than continue in weird state.
>
> drivers/virt/steal_governor.c:steal_governor_loop()
> if (!preferred_cpus_valid()) {
> restore_preferred_to_active();
> return;
> }
>
> Would holding cpus_read_lock() during these mask checks prevent this race and
> keep the loop running correctly?
>
> [ ... ]
>
prev parent reply other threads:[~2026-09-09 16:58 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 13:56 [PATCH v13 00/13] sched, steal_governor: Introduce preferred CPUs and steal-driven vCPU backoff Shrikanth Hegde
2026-09-09 13:56 ` [PATCH v13 01/13] sched/cputime: Add kcpustat_field_total helper Shrikanth Hegde
2026-09-09 14:16 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 02/13] cpumask: Introduce cpumask_intersects_and Shrikanth Hegde
2026-09-09 14:02 ` sashiko-bot
2026-09-09 16:03 ` Yury Norov
2026-09-09 13:56 ` [PATCH v13 03/13] sched/docs: Document cpu_preferred_mask and Preferred CPU concept Shrikanth Hegde
2026-09-09 14:01 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 04/13] cpumask: Introduce cpu_preferred_mask Shrikanth Hegde
2026-09-09 14:06 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 05/13] sysfs: Add preferred CPU file Shrikanth Hegde
2026-09-09 14:04 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 06/13] sched/core: Try to use a preferred CPU in is_cpu_allowed Shrikanth Hegde
2026-09-09 14:18 ` sashiko-bot
2026-09-09 16:49 ` Shrikanth Hegde
2026-09-09 13:56 ` [PATCH v13 07/13] sched/fair: Load balance only among preferred CPUs Shrikanth Hegde
2026-09-09 14:33 ` sashiko-bot
2026-09-09 17:09 ` Shrikanth Hegde
2026-09-09 17:19 ` Yury Norov
2026-09-09 13:56 ` [PATCH v13 08/13] sched/core: Push current task from non preferred CPU Shrikanth Hegde
2026-09-09 14:18 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 09/13] sched/debug: Add migration stats due to non preferred CPUs Shrikanth Hegde
2026-09-09 14:07 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 10/13] virt: Introduce steal governor driver Shrikanth Hegde
2026-09-09 14:09 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 11/13] virt/steal_governor: Add control knobs for handling steal values Shrikanth Hegde
2026-09-09 14:06 ` sashiko-bot
2026-09-09 13:56 ` [PATCH v13 12/13] virt/steal_governor: Implement steal_governor policy loop Shrikanth Hegde
2026-09-09 14:16 ` sashiko-bot
2026-09-09 16:52 ` Shrikanth Hegde
2026-09-09 13:56 ` [PATCH v13 13/13] virt/steal_governor: Enable the driver Shrikanth Hegde
2026-09-09 14:17 ` sashiko-bot
2026-09-09 16:58 ` Shrikanth Hegde [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=9fb85c37-a886-46ae-b738-f0eadf3dd468@linux.ibm.com \
--to=sshegde@linux.ibm.com \
--cc=eperezma@redhat.com \
--cc=mst@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=virtualization@lists.linux.dev \
/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