mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: Yury Norov <ynorov@nvidia.com>,
	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>
Cc: 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>,
	Ilya Leoshkevich <iii@linux.ibm.com>,
	Johan Hovold <johan@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
	K Prateek Nayak <kprateek.nayak@amd.com>,
	Maxim Kuvyrkov <maxim.kuvyrkov@grdncc.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: Re: [PATCH 5/7] virt: steal_governor: warn on unexpected preferred mask states
Date: Sat, 28 Nov 2026 10:12:27 +0530	[thread overview]
Message-ID: <75748781-c20c-4b1b-acc9-ba8e6e06cf60@linux.ibm.com> (raw)
In-Reply-To: <20261113184257.621707-6-ynorov@nvidia.com>

Hi Yury.

On 11/14/26 12:12 AM, Yury Norov wrote:
> 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
> paths 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 | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/virt/steal_governor.c b/drivers/virt/steal_governor.c
> index 8cd5c0f3e3ef..c34d91267ec1 100644
> --- a/drivers/virt/steal_governor.c
> +++ b/drivers/virt/steal_governor.c
> @@ -142,6 +142,11 @@ static void decrease_preferred_cpus(void)
>   
>   	lockdep_assert_cpus_held();
>   	lockdep_assert_held(&cpu_preferred_mutex);
> +
> +	/* We can't end up with no preferred CPUs under normal conditions. */
> +	if (WARN_ON(cpumask_empty(cpu_preferred_mask)))
> +		return;
> +

With this, we will end up with 2 WARN's for the same thing.
Once here and once again in preferred_cpus_valid.

What we have in preferred_cpus_valid covers this already. Why again here?

>   	cpu = cpumask_first_and(housekeeping_cpumask(HK_TYPE_KERNEL_NOISE),
>   				cpu_preferred_mask);
>   	if (cpu >= nr_cpu_ids)
> @@ -150,8 +155,6 @@ 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)
> -		return;
>   
>   	/* Find the last CPU which doesn't belong to that first hk_core. */
>   	if (!cpumask_test_cpu(cpu, first_hk_core)) {
> @@ -246,7 +249,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;
>   	}

Regarding this series, IMHO we should split the patches into

1.ones which are actually about fixing the hotplug race (PATCH 3 and 6)
2.ones which are needed only when the another write interface comes in (PATCH 1,2,4,5,7).

  reply	other threads:[~2026-11-28  4:43 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 18:42 [PATCH 0/7] Harden preferred CPUs management Yury Norov
2026-11-13 18:42 ` [PATCH 1/7] cpumask: add reset_preferred_cpumask() helper Yury Norov
2026-11-13 18:42 ` [PATCH 2/7] sched: restore preferred CPUs when hotplug removes the last one Yury Norov
2026-11-19  6:13   ` Shrikanth Hegde
2026-11-19 16:46     ` Yury Norov
2026-11-13 18:42 ` [PATCH 3/7] virt: steal_governor: remove the minimum elapsed-time check Yury Norov
2026-11-13 18:42 ` [PATCH 4/7] virt: steal_governor: serialize sampling against CPU hotplug Yury Norov
2026-11-19  6:22   ` Shrikanth Hegde
2026-11-19 16:50     ` Yury Norov
2026-11-20  8:38       ` Shrikanth Hegde
2026-11-20 15:35         ` Yury Norov
2026-11-22 15:54           ` Shrikanth Hegde
2026-11-22 16:17             ` Yury Norov
2026-11-13 18:42 ` [PATCH 5/7] virt: steal_governor: warn on unexpected preferred mask states Yury Norov
2026-11-28  4:42   ` Shrikanth Hegde [this message]
2026-11-13 18:42 ` [PATCH 6/7] virt: steal_governor: restart sampling immediately after CPU hotplug Yury Norov
2026-11-16  2:13   ` Yury Norov
2026-11-19  6:06   ` Shrikanth Hegde
2026-11-19 17:39     ` Yury Norov
2026-11-20  8:50       ` Shrikanth Hegde
2026-11-20 15:36         ` Yury Norov
2026-11-13 18:42 ` [PATCH 7/7] cpu: make preferred CPU policy writers mutually exclusive Yury Norov
2026-11-19  6:10   ` Shrikanth Hegde
2026-11-19 17:47     ` Yury Norov
2026-11-20 15:38   ` Peter Zijlstra
2026-11-20 15:59     ` Yury Norov
2026-11-20 16:09       ` Peter Zijlstra
2026-11-20 16:25         ` Yury Norov
2026-11-20 16:26           ` 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=75748781-c20c-4b1b-acc9-ba8e6e06cf60@linux.ibm.com \
    --to=sshegde@linux.ibm.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=iii@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=maxim.kuvyrkov@grdncc.com \
    --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=svens@linux.ibm.com \
    --cc=tglx@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    --cc=ynorov@nvidia.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®