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>
Cc: Maxim Kuvyrkov <maxim.kuvyrkov@grdncc.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>,
	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: Re: [PATCH 0/6] sched: Expose writable interface for preferred CPUs mask
Date: Thu, 12 Nov 2026 10:39:03 +0530	[thread overview]
Message-ID: <1d170fb4-7e78-4c8c-9cd0-642973dd9163@linux.ibm.com> (raw)
In-Reply-To: <avSorfTkB3pZX2ic@yury>



On 11/11/26 11:11 PM, Yury Norov wrote:
> On Tue, Nov 10, 2026 at 02:45:58PM +0530, Shrikanth Hegde wrote:
>> Hi,
>>
>> On 11/10/26 8:45 AM, Maxim Kuvyrkov wrote:
>>>> On Nov 2, 2026, at 08:21, Yury Norov <ynorov@nvidia.com> wrote:
>>>>
>>>> The preferred CPU mask currently lets the steal governor reduce vCPU
>>>> demand when physical CPUs are contended. This series adds manual control,
>>>> opening more use cases.
>>>>
>>>> For example, setting CPUs aside for selected fair tasks at runtime while
>>>> steering other fair tasks toward the remaining CPUs.
>>>
>>> Hi Yury,
>>>
>>> I've been trying to do this with crutches in user-space for a long time.  Thanks for implementing this in the kernel, and with a convenient user interface.
>>>
>>>>
>>>> A user can mark a CPU non-preferred and pin a workload to it. Fair tasks
>>>> whose affinity includes preferred CPUs are steered away, while tasks
>>>> whose allowed CPUs contain no preferred CPU can still run there. The CPU
>>>> stays online, task affinity is preserved, and the selection can be
>>>> reversed without rebooting:
>>>>
>>>>      # rmmod steal_governor
>>>>      # echo 0 > /sys/devices/system/cpu/cpu3/preferred
>>>>      # taskset -c 3 ./my_workload
>>>>      # echo 1 > /sys/devices/system/cpu/cpu3/preferred
>>>
>>> My use-case (being a compiler optimization engineer) is to pin benchmarks to specific cores, and stop the system from using those cores even when the cores are idle.  This prevents L1/L2 cache pollution and makes performance numbers more stable.
>>>
>>
>> Do you change it when running workload based on any signal/event? or you set it before starting it?
>>
>> If it is set before starting, you might as well offline the CPUs to achieve the same. I assume you are
>> managing the preferred CPUs manually with write interface. You can do the same for online state.
>> (Though it takes a longer)
> 
> How that? I tried, and offlining destroys the affinity, as it should:
> 

You are doing "hotplug when workload is running".

>    # taskset -c 3 sh -c 'while :; do :; done' &
>    [1] 380
>    # taskset -pc "$pid"
>    pid 380's current affinity list: 3
>    # echo 0 >/sys/devices/system/cpu/cpu3/online
>    [  115.767634] process 380 (sh) no longer affine to cpu3
>    [  115.772881] smpboot: CPU 3 is now offline
>    taskset -pc 380
>    pid 380's current affinity list: 0-2,4-7
> 
> Did you mean something else, maybe?

What matters is how/when you start the workload.
 From the use case, I see it is about using only specific set of CPUs and there is no explicit affinity assigned.

Sequence1:
1. You are setting preferred CPUs.
2. You start the workload. Workload finishes using preferred CPUs.
3. You set the preferred same as active.

In that sequence, offlining the CPUs is going to be similar. You are managing preferred CPUs, you can as well manage
offline CPUs. Most of the workload check the CPU state before assigning any explicit affinity or spawning threads etc.

Sequence 2:
1. workload is long running job. Lets say comprising of warmup/steady/closure phases.
2. You only to run on specific CPUs during steady phase.
3. You fallback to active during closure phase again.

In that sequence what you said about offline breaking affinities is very much possibility. It is
good to set preferred CPUs in this sequence.

but reading maxim's description it fitted Sequence1.

  reply	other threads:[~2026-11-12  5:09 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01 19:21 Yury Norov
2026-11-01 19:21 ` [PATCH 1/6] sched: decouple PREFERRED_CPU from PARAVIRT in Kconfig.preempt Yury Norov
2026-11-02 10:16   ` Ilya Leoshkevich
2026-11-02 11:00     ` Peter Zijlstra
2026-11-02 11:34       ` Ilya Leoshkevich
2026-11-02 13:00         ` Shrikanth Hegde
2026-11-02 13:41           ` Ilya Leoshkevich
2026-11-02 14:57             ` Shrikanth Hegde
2026-11-03  5:49             ` Shrikanth Hegde
2026-11-03 11:26               ` Ilya Leoshkevich
2026-11-03 11:30                 ` Ilya Leoshkevich
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-05  9:05   ` Fushuai Wang
2026-11-05 13:27     ` Yury Norov
2026-11-01 19:22 ` [PATCH 4/6] sched: serialize preferred cpumask update better Yury Norov
2026-11-01 19:22 ` [PATCH 5/6] virt: steal_governor: Warn on unexpected preferred mask states Yury Norov
2026-11-01 19:22 ` [PATCH 6/6] cpu: Add per-CPU preferred sysfs control Yury Norov
2026-11-02  8:47 ` [PATCH 0/6] sched: Expose writable interface for preferred CPUs mask Peter Zijlstra
2026-11-03 16:49   ` Yury Norov
2026-11-05 14:55     ` Peter Zijlstra
2026-11-06 17:34       ` Yury Norov
2026-11-10  3:15 ` Maxim Kuvyrkov
2026-11-10  9:15   ` Shrikanth Hegde
2026-11-11 17:41     ` Yury Norov
2026-11-12  5:09       ` Shrikanth Hegde [this message]
2026-11-11 20:37   ` Yury Norov
2026-11-12  5:12     ` Shrikanth Hegde

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=1d170fb4-7e78-4c8c-9cd0-642973dd9163@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=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®