From: Yury Norov <ynorov@nvidia.com>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Thomas Gleixner <tglx@kernel.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Shrikanth Hegde <sshegde@linux.ibm.com>
Cc: Yury Norov <ynorov@nvidia.com>, Yury Norov <yury.norov@gmail.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Andrea Righi <arighi@nvidia.com>, Ben Segall <bsegall@google.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Danilo Krummrich <dakr@kernel.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Heiko Carstens <hca@linux.ibm.com>,
Johan Hovold <johan@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
K Prateek Nayak <kprateek.nayak@amd.com>,
Mel Gorman <mgorman@suse.de>, Mete Durlu <meted@linux.ibm.com>,
Randy Dunlap <rdunlap@infradead.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Shuah Khan <skhan@linuxfoundation.org>,
Steven Rostedt <rostedt@goodmis.org>,
Sven Schnelle <svens@linux.ibm.com>,
Valentin Schneider <vschneid@redhat.com>,
Vasily Gorbik <gor@linux.ibm.com>,
linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
driver-core@lists.linux.dev, linux-s390@vger.kernel.org
Subject: [PATCH 5/6] virt: steal_governor: Warn on unexpected preferred mask states
Date: Sun, 1 Nov 2026 14:22:01 -0500 [thread overview]
Message-ID: <20261101192203.6979-6-ynorov@nvidia.com> (raw)
In-Reply-To: <20261101192203.6979-1-ynorov@nvidia.com>
Now that preferred cpumask access is properly serialized, and CPU
hotplug restores all remaining active CPUs as preferred when the
last preferred CPU gets offlined, the corresponding logic in the
driver is redundant.
Instead of removing it completely, add WARN_ON()s in the corresponding
conditionals to harden the preferred CPUs mask management and highlight
that this condition is not expected during normal operation.
Signed-off-by: Yury Norov <ynorov@nvidia.com>
---
drivers/virt/steal_governor.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/virt/steal_governor.c b/drivers/virt/steal_governor.c
index bc3936e69eed..5679b7ddc078 100644
--- a/drivers/virt/steal_governor.c
+++ b/drivers/virt/steal_governor.c
@@ -145,7 +145,9 @@ static void decrease_preferred_cpus(void)
/* Always leave first housekeeping core as preferred. */
first_hk_core = topology_sibling_cpumask(cpu);
cpu = cpumask_last(cpu_preferred_mask);
- if (cpu >= nr_cpu_ids)
+
+ /* We can't end up with no preferred CPUs under normal conditions. */
+ if (WARN_ON(cpu >= nr_cpu_ids))
return;
/* Find the last CPU which doesn't belong to that first hk_core. */
@@ -246,7 +248,7 @@ static void steal_governor_loop(struct work_struct *work)
* else: steal ratio is within bounds. Still do design checks so that
* module restores to active if CPU hotplug breaks those assumptions.
*/
- if (!preferred_cpus_valid()) {
+ if (WARN_ON(!preferred_cpus_valid())) {
reset_preferred_cpumask();
return;
}
--
2.53.0
next prev parent reply other threads:[~2026-11-01 19:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-01 19:21 [PATCH 0/6] sched: Expose writable interface for preferred CPUs mask Yury Norov
2026-11-01 19:21 ` [PATCH 1/6] sched: decouple PREFERRED_CPU from PARAVIRT in Kconfig.preempt Yury Norov
2026-11-01 19:21 ` [PATCH 2/6] cpumask: Add reset_preferred_cpumask() helper Yury Norov
2026-11-01 19:21 ` [PATCH 3/6] sched: Restore preferred CPUs when hotplug removes the last one Yury Norov
2026-11-01 19:22 ` [PATCH 4/6] sched: serialize preferred cpumask update better Yury Norov
2026-11-01 19:22 ` Yury Norov [this message]
2026-11-01 19:22 ` [PATCH 6/6] cpu: Add per-CPU preferred sysfs control Yury Norov
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=20261101192203.6979-6-ynorov@nvidia.com \
--to=ynorov@nvidia.com \
--cc=agordeev@linux.ibm.com \
--cc=arighi@nvidia.com \
--cc=borntraeger@linux.ibm.com \
--cc=bsegall@google.com \
--cc=corbet@lwn.net \
--cc=dakr@kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=driver-core@lists.linux.dev \
--cc=gor@linux.ibm.com \
--cc=gregkh@linuxfoundation.org \
--cc=hca@linux.ibm.com \
--cc=johan@kernel.org \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=meted@linux.ibm.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=rdunlap@infradead.org \
--cc=rostedt@goodmis.org \
--cc=skhan@linuxfoundation.org \
--cc=sshegde@linux.ibm.com \
--cc=svens@linux.ibm.com \
--cc=tglx@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=yury.norov@gmail.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
all inboxes | Powered by JetHome®