From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: Yury Norov <ynorov@nvidia.com>
Cc: linux-kernel@vger.kernel.org, mingo@kernel.org,
peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, yury.norov@gmail.com,
kprateek.nayak@amd.com, iii@linux.ibm.com, corbet@lwn.net,
tglx@kernel.org, gregkh@linuxfoundation.org, pbonzini@redhat.com,
seanjc@google.com, vschneid@redhat.com, huschle@linux.ibm.com,
rostedt@goodmis.org, dietmar.eggemann@arm.com,
maddy@linux.ibm.com, srikar@linux.ibm.com, hdanton@sina.com,
chleroy@kernel.org, vineeth@bitbyteword.org, frederic@kernel.org,
arighi@nvidia.com, pauld@redhat.com, christian.loehle@arm.com,
tj@kernel.org, tommaso.cucinotta@gmail.com, maz@kernel.org,
rafael@kernel.org, rdunlap@infradead.org, kernellwp@gmail.com,
linux-doc@vger.kernel.org
Subject: Re: [PATCH v7 08/12] virt: Introduce steal monitor driver
Date: Mon, 13 Jul 2026 17:36:16 +0530 [thread overview]
Message-ID: <abb3fbf3-bdd6-44ca-85e7-0e1659381e61@linux.ibm.com> (raw)
In-Reply-To: <alFb0PBu8P44DmXD@yury>
Hi Yury,
On 7/11/26 2:23 AM, Yury Norov wrote:
> On Fri, Jul 10, 2026 at 03:26:44AM +0530, Shrikanth Hegde wrote:
>> Introduce a new driver in virt named steal_monitor. This driver
>> will compute the steal time and drive the policy decisions of preferred
>> CPU state.
>>
[...]
>> +
>> STI AUDIO (ASoC) DRIVERS
>> M: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
>> L: linux-sound@vger.kernel.org
>> diff --git a/drivers/virt/Kconfig b/drivers/virt/Kconfig
>> index 52eb7e4ba71f..a52233b2502e 100644
>> --- a/drivers/virt/Kconfig
>> +++ b/drivers/virt/Kconfig
>> @@ -47,6 +47,8 @@ source "drivers/virt/nitro_enclaves/Kconfig"
>>
>> source "drivers/virt/acrn/Kconfig"
>>
>> +source "drivers/virt/steal_monitor/Kconfig"
>> +
>> endif
>>
>> source "drivers/virt/coco/Kconfig"
>> diff --git a/drivers/virt/Makefile b/drivers/virt/Makefile
>> index f29901bd7820..b67fd8968ec3 100644
>> --- a/drivers/virt/Makefile
>> +++ b/drivers/virt/Makefile
>> @@ -9,4 +9,5 @@ obj-y += vboxguest/
>>
>> obj-$(CONFIG_NITRO_ENCLAVES) += nitro_enclaves/
>> obj-$(CONFIG_ACRN_HSM) += acrn/
>> +obj-$(CONFIG_STEAL_MONITOR) += steal_monitor/
>> obj-y += coco/
>> diff --git a/drivers/virt/steal_monitor/Kconfig b/drivers/virt/steal_monitor/Kconfig
>> new file mode 100644
>> index 000000000000..c7d7599c30ce
>> --- /dev/null
>> +++ b/drivers/virt/steal_monitor/Kconfig
>> @@ -0,0 +1,18 @@
>> +# SPDX-License-Identifier: GPL-2.0-only
>> +config STEAL_MONITOR
>
> The config should go in the last patch of the series. Otherwise,
> in case of bisection, you'll have half-written driver enabled by
> default.
Ok. I will keep it a patch at the end.
>
>> + tristate "Dynamic vCPU management based on steal time"
>> + depends on PARAVIRT && SMP
>> + select PREFERRED_CPU
>> + default m
>> + help
>> + This driver helps to reduce the steal time in paravirtualised
>> + environment, thereby reducing vCPU preemption. Reducing vCPU
>> + preemption provides improved lock holder preemption and reduces
>> + cost of vCPU preemption in the host.
>> +
>> + By default preferred CPUs will be same as active CPUs. Depending
>> + on the steal time when steal_monitor driver is enabled,
>> + preferred CPUs could become subset of active CPUs.
>> +
>> + It is recommended to build it as module and load the module
>> + to enable it.
>> diff --git a/drivers/virt/steal_monitor/Makefile b/drivers/virt/steal_monitor/Makefile
>> new file mode 100644
>> index 000000000000..bd7d120a79b5
>> --- /dev/null
>> +++ b/drivers/virt/steal_monitor/Makefile
>> @@ -0,0 +1,6 @@
>> +# SPDX-License-Identifier: GPL-2.0-only
>> +#
>> +# Steal time monitor to alter preferred CPU state.
>> +obj-$(CONFIG_STEAL_MONITOR) += steal_monitor.o
>> +
>> +steal_monitor-y := sm_core.o
>> diff --git a/drivers/virt/steal_monitor/sm_core.c b/drivers/virt/steal_monitor/sm_core.c
>> new file mode 100644
>> index 000000000000..180db424846c
>> --- /dev/null
>> +++ b/drivers/virt/steal_monitor/sm_core.c
>> @@ -0,0 +1,38 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * Steal time Monitor.
>> + *
>> + * Periodically compute steal time. Based on the thresholds either
>> + * reduce/increase the preferred CPUs which can be used
>> + * by the workload to avoid vCPU preemption to an extent possible.
>> + *
>> + * Available as module with CONFIG_STEAL_MONITOR=m
>> + *
>> + * Copyright (C) 2026 IBM
>> + * Author: Shrikanth Hegde <sshegde@linux.ibm.com>
>> + */
>> +
>> +#include "sm_core.h"
>> +
>> +struct steal_monitor sm_core_ctx;
>> +
>> +static int __init steal_monitor_init(void)
>> +{
>> + pr_info("steal_monitor is enabled\n");
>> + return 0;
>> +}
>> +
>> +static void __exit steal_monitor_exit(void)
>> +{
>> + guard(cpus_read_lock)();
>> + cpumask_copy(&__cpu_preferred_mask, cpu_active_mask);
>> +
>> + pr_info("steal_monitor is disabled\n");
>> +}
>> +
>> +module_init(steal_monitor_init);
>> +module_exit(steal_monitor_exit);
>> +
>> +MODULE_LICENSE("GPL");
>> +MODULE_AUTHOR("IBM Corporation");
>> +MODULE_DESCRIPTION("Virtualization Steal Time Monitor");
>> diff --git a/drivers/virt/steal_monitor/sm_core.h b/drivers/virt/steal_monitor/sm_core.h
>> new file mode 100644
>> index 000000000000..8bbb606add99
>> --- /dev/null
>> +++ b/drivers/virt/steal_monitor/sm_core.h
>> @@ -0,0 +1,27 @@
>> +/* SPDX-License-Identifier: GPL-2.0-only */
>> +#ifndef __VIRT_STEAL_CORE_H
>> +#define __VIRT_STEAL_CORE_H
>> +
>> +#include <linux/types.h>
>> +
>> +#include <linux/module.h>
>> +#include <linux/kernel.h>
>> +#include <linux/init.h>
>> +#include <linux/cpuhplock.h>
>> +#include <linux/cpumask.h>
>> +#include <linux/workqueue.h>
>> +#include <linux/ktime.h>
>> +
>> +struct steal_monitor {
>> + struct delayed_work work;
>> + u64 prev_steal;
>> + int prev_direction;
>
> Did you run pahole on it?
Ah my bad. Will do.
>
>> + unsigned int interval_ms;
>> + unsigned int high_threshold;
>> + unsigned int low_threshold;
>> + ktime_t prev_time;
>
> This 'prev_' prefix is useless and distracting. Just drop it.
>
>> +};
Ok. will keep it as time, steal. (prev_direction is being removed in v8)
>> +
>> +extern struct steal_monitor sm_core_ctx;
>> +
>> +#endif /* __VIRT_STEAL_CORE_H */
>> --
>> 2.47.3
next prev parent reply other threads:[~2026-07-13 12:06 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-09 21:56 [PATCH v7 00/12] sched, steal_monitor: Introduce cpu_preferred_mask and steal-driven vCPU backoff Shrikanth Hegde
2026-07-09 21:56 ` [PATCH v7 01/12] sched/docs: Document cpu_preferred_mask and Preferred CPU concept Shrikanth Hegde
2026-07-09 21:56 ` [PATCH v7 02/12] cpumask: Introduce cpu_preferred_mask Shrikanth Hegde
2026-07-13 14:53 ` Yury Norov
2026-07-14 6:30 ` Shrikanth Hegde
2026-07-14 13:01 ` Yury Norov
2026-07-09 21:56 ` [PATCH v7 03/12] sysfs: Add preferred CPU file Shrikanth Hegde
2026-07-10 15:41 ` Yury Norov
2026-07-10 17:00 ` Shrikanth Hegde
2026-07-10 23:09 ` Yury Norov
2026-07-13 12:00 ` Shrikanth Hegde
2026-07-09 21:56 ` [PATCH v7 04/12] sched/core: Try to use a preferred CPU in is_cpu_allowed Shrikanth Hegde
2026-07-09 21:56 ` [PATCH v7 05/12] sched/fair: Load balance only among preferred CPUs Shrikanth Hegde
2026-07-09 21:56 ` [PATCH v7 06/12] sched/core: Push current task from non preferred CPU Shrikanth Hegde
2026-07-10 23:02 ` Yury Norov
2026-07-13 12:35 ` Shrikanth Hegde
2026-07-09 21:56 ` [PATCH v7 07/12] sched/debug: Add migration stats due to non preferred CPUs Shrikanth Hegde
2026-07-09 21:56 ` [PATCH v7 08/12] virt: Introduce steal monitor driver Shrikanth Hegde
2026-07-10 1:27 ` Randy Dunlap
2026-07-10 4:28 ` Shrikanth Hegde
2026-07-10 20:53 ` Yury Norov
2026-07-13 12:06 ` Shrikanth Hegde [this message]
2026-07-09 21:56 ` [PATCH v7 09/12] virt/steal_monitor: Add control knobs for handling steal values Shrikanth Hegde
2026-07-10 4:27 ` Shrikanth Hegde
2026-07-09 21:56 ` [PATCH v7 10/12] virt/steal_monitor: Provide functions for managing " Shrikanth Hegde
2026-07-10 4:30 ` Shrikanth Hegde
2026-07-10 20:00 ` Yury Norov
2026-07-13 5:13 ` Shrikanth Hegde
2026-07-14 12:47 ` Yury Norov
2026-07-14 13:15 ` Shrikanth Hegde
2026-07-09 21:56 ` [PATCH v7 11/12] virt/steal_monitor: Act on steal time periodically and decide on preferred CPUs Shrikanth Hegde
2026-07-10 20:37 ` Yury Norov
2026-07-13 5:48 ` Shrikanth Hegde
2026-07-14 12:31 ` Yury Norov
2026-07-14 13:08 ` Shrikanth Hegde
2026-07-09 21:56 ` [PATCH v7 12/12] sched, virt/steal_monitor: Keep tick on for faster push on nohz_full CPU Shrikanth Hegde
2026-07-10 6:35 ` 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=abb3fbf3-bdd6-44ca-85e7-0e1659381e61@linux.ibm.com \
--to=sshegde@linux.ibm.com \
--cc=arighi@nvidia.com \
--cc=chleroy@kernel.org \
--cc=christian.loehle@arm.com \
--cc=corbet@lwn.net \
--cc=dietmar.eggemann@arm.com \
--cc=frederic@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=hdanton@sina.com \
--cc=huschle@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=juri.lelli@redhat.com \
--cc=kernellwp@gmail.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maddy@linux.ibm.com \
--cc=maz@kernel.org \
--cc=mingo@kernel.org \
--cc=pauld@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=rdunlap@infradead.org \
--cc=rostedt@goodmis.org \
--cc=seanjc@google.com \
--cc=srikar@linux.ibm.com \
--cc=tglx@kernel.org \
--cc=tj@kernel.org \
--cc=tommaso.cucinotta@gmail.com \
--cc=vincent.guittot@linaro.org \
--cc=vineeth@bitbyteword.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