Linux real-time development
 help / color / mirror / Atom feed
From: "Yuhang.chen" <yhchen312@gmail.com>
To: bigeasy@linutronix.de
Cc: anup@brainfault.org, atish.patra@linux.dev, clrkwllms@kernel.org,
	rostedt@goodmis.org, kvm@vger.kernel.org,
	kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev,
	zhouquan@iscas.ac.cn, "Yuhang . chen" <yhchen312@gmail.com>
Subject: Re: [PATCH] RISC-V: KVM: Use raw_spinlock for VMID update critical section
Date: Wed, 22 Jul 2026 20:33:50 +0800	[thread overview]
Message-ID: <20260722123350.3697232-1-yhchen312@gmail.com> (raw)
In-Reply-To: <20260717065137.FQ5Ax2W-@linutronix.de>

Hi Sebastian,

thanks for having a look.

On 2026-07-17 06:51:37 [+0000], Sebastian Andrzej Siewior wrote:
> Here you state _why_ it must not be preempted. What would be the worst
> that could happen.

The worst case is an unbounded hold of vmid_lock that stalls guest entry
system-wide. On rollover the section bumps vmid_version and then broadcasts
a guest-TLB flush via on_each_cpu_mask(..., wait=1) before assigning a
fresh VMID. Under PREEMPT_RT a plain spinlock_t is preemptible, so the
holder could be scheduled out while still waiting for that broadcast flush
to finish and keep vmid_lock held for an unbounded scheduling delay; every
other vCPU reaching the VMID-(re)assignment path on its way into the guest
would then block on the lock. The rollover is otherwise a short critical
section (a version bump plus one IPI), so keeping it non-preemptible with
raw_spinlock_t bounds its hold time.

I'll fold that into the commit log.

> That part starting with "Convert" belongs into into a new line.

Will fix in v2.

I'll send v2 with both changes.

  Yuhang

      reply	other threads:[~2026-07-22 12:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16  6:40 [PATCH] RISC-V: KVM: Use raw_spinlock for VMID update critical section yhchen312
2026-07-16  6:57 ` sashiko-bot
2026-07-17  6:51 ` Sebastian Andrzej Siewior
2026-07-22 12:33   ` Yuhang.chen [this message]

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=20260722123350.3697232-1-yhchen312@gmail.com \
    --to=yhchen312@gmail.com \
    --cc=anup@brainfault.org \
    --cc=atish.patra@linux.dev \
    --cc=bigeasy@linutronix.de \
    --cc=clrkwllms@kernel.org \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=rostedt@goodmis.org \
    --cc=zhouquan@iscas.ac.cn \
    /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