From: "Michael S. Tsirkin" <mst@redhat.com>
To: Aamir Ahmed <elb12345@hotmail.co.uk>
Cc: "Jason Wang" <jasowangio@gmail.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Valentin Schneider" <vschneid@redhat.com>,
"Aaron Lu" <ziqianlu@bytedance.com>,
"Peter Zijlstra" <peterz@infradead.org>,
kvm@vger.kernel.org, virtualization@lists.linux.dev,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] vhost: Run TIF_NOTIFY_RESUME work in the vhost_task loop
Date: Mon, 2 Nov 2026 17:09:42 -0500 [thread overview]
Message-ID: <20261102170928-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <AS8P251MB00012469E6ECBEA2B7D87BB0C86C2@AS8P251MB0001.EURP251.PROD.OUTLOOK.COM>
On Sat, Oct 31, 2026 at 01:33:13AM +0000, Aamir Ahmed wrote:
> Since commit e1fad12dcb66 ("sched/fair: Switch to task based throttle
> model"), a throttled task is only dequeued when TWA_RESUME task_work
> runs on its way back to user mode.
>
> vhost workers never return to user mode, and vhost_task_fn() only runs
> task_work via get_signal() when a signal is pending. A busy vhost worker
> therefore ignores its cgroup's cpu.max, while its runtime is still
> charged to the group, throttling the group's other tasks (typically the
> VM's vCPUs) harder.
>
> Run pending notify-resume work at the top of the worker loop, as io-wq
> does in io_run_task_work(). Commit 12013e3d4695 ("KVM: powerpc: Use
> generic xfer to guest work function") fixed the same problem for KVM.
>
> Fixes: e1fad12dcb66 ("sched/fair: Switch to task based throttle model")
> Cc: stable@vger.kernel.org # 6.18+
> Assisted-by: LLM
> Signed-off-by: Aamir Ahmed <elb12345@hotmail.co.uk>
Could you pls respond to Sashiko's review?
> ---
> Tested on x86_64 with a vhost_task-based reproducer: in a 0.2-CPU cgroup
> a busy worker drops from 100% to 19% of a CPU. Reproducer available on
> request.
>
> kernel/vhost_task.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/kernel/vhost_task.c b/kernel/vhost_task.c
> index 3717885a599..7fa96e1b85b 100644
> --- a/kernel/vhost_task.c
> +++ b/kernel/vhost_task.c
> @@ -6,6 +6,7 @@
> #include <linux/completion.h>
> #include <linux/sched/task.h>
> #include <linux/sched/vhost_task.h>
> +#include <linux/resume_user_mode.h>
> #include <linux/sched/signal.h>
>
> enum vhost_task_flags {
> @@ -31,6 +32,14 @@ static int vhost_task_fn(void *data)
> for (;;) {
> bool did_work;
>
> + /*
> + * We never return to user mode, so TWA_RESUME task_work (e.g. CFS
> + * bandwidth throttling) would otherwise never run. Run it here,
> + * where no locks are held, like io-wq workers do.
> + */
> + if (test_thread_flag(TIF_NOTIFY_RESUME))
> + resume_user_mode_work(NULL);
> +
> if (signal_pending(current)) {
> struct ksignal ksig;
>
>
> base-commit: c03c1a14507dfaf8b856c2608f9ac216021fc222
> --
> 2.43.0
next prev parent reply other threads:[~2026-11-02 22:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 1:33 [PATCH] vhost: Run TIF_NOTIFY_RESUME work in the vhost_task loop Aamir Ahmed
2026-10-31 19:05 ` Shakeel Butt
2026-11-01 1:33 ` sashiko-bot
2026-11-02 22:09 ` Michael S. Tsirkin [this message]
2026-11-03 10:13 ` Aamir Ahmed
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=20261102170928-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=elb12345@hotmail.co.uk \
--cc=eperezma@redhat.com \
--cc=jasowangio@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=stable@vger.kernel.org \
--cc=virtualization@lists.linux.dev \
--cc=vschneid@redhat.com \
--cc=ziqianlu@bytedance.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.