From: Sean Christopherson <seanjc@google.com>
To: Yan Zhao <yan.y.zhao@intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Maxim Levitsky <mlevitsk@redhat.com>,
kvm@vger.kernel.org, James Houghton <jthoughton@google.com>
Subject: Re: Lockdep failure due to 'wierd' per-cpu wakeup_vcpus_on_cpu_lock lock
Date: Thu, 27 Mar 2025 16:41:42 -0700 [thread overview]
Message-ID: <Z-XiNiQqhbwLmimp@google.com> (raw)
In-Reply-To: <Z+U/W202ngjZxBOV@yzhao56-desk.sh.intel.com>
On Thu, Mar 27, 2025, Yan Zhao wrote:
> On Fri, Mar 21, 2025 at 12:49:42PM +0100, Paolo Bonzini wrote:
> > On Wed, Mar 19, 2025 at 5:17 PM Sean Christopherson <seanjc@google.com> wrote:
> > > Yan posted a patch to fudge around the issue[*], I strongly objected (and still
> > > object) to making a functional and confusing code change to fudge around a lockdep
> > > false positive.
> >
> > In that thread I had made another suggestion, which Yan also tried,
> > which was to use subclasses:
> >
> > - in the sched_out path, which cannot race with the others:
> > raw_spin_lock_nested(&per_cpu(wakeup_vcpus_on_cpu_lock, vcpu->cpu), 1);
> >
> > - in the irq and sched_in paths, which can race with each other:
> > raw_spin_lock(&per_cpu(wakeup_vcpus_on_cpu_lock, vcpu->cpu));
> Hi Paolo, Sean, Maxim,
>
> The sched_out path still may race with sched_in path. e.g.
> CPU 0 CPU 1
> ----------------- ---------------
> vCPU 0 sched_out
> vCPU 1 sched_in
> vCPU 1 sched_out vCPU 0 sched_in
>
> vCPU 0 sched_in may race with vCPU 1 sched_out on CPU 0's wakeup list.
>
>
> So, the situation is
> sched_in, sched_out: race
> sched_in, irq: race
> sched_out, irq: mutual exclusive, do not race
>
>
> Hence, do you think below subclasses assignments reasonable?
> irq: subclass 0
> sched_out: subclass 1
> sched_in: subclasses 0 and 1
>
> As inspired by Sean's solution, I made below patch to inform lockdep that the
> sched_in path involves both subclasses 0 and 1 by adding a line
> "spin_acquire(&spinlock->dep_map, 1, 0, _RET_IP_)".
>
> I like it because it accurately conveys the situation to lockdep :)
Me too :-)
Can you give your SoB? I wrote comments and a changelog to explain to myself
(yet again), what the problem is, and why it's a false positive. I also want
to change the local_irq_{save,restore}() into a lockdep assertion in a prep patch,
because this and the self-IPI trick rely on IRQs being disabled until the task
is fully scheduled out and the scheduler locks are dopped.
next prev parent reply other threads:[~2025-03-27 23:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-19 2:19 Lockdep failure due to 'wierd' per-cpu wakeup_vcpus_on_cpu_lock lock Maxim Levitsky
2025-03-19 16:17 ` Sean Christopherson
2025-03-19 22:49 ` Maxim Levitsky
2025-03-21 11:11 ` Yan Zhao
2025-03-21 11:49 ` Paolo Bonzini
2025-03-24 13:25 ` Maxim Levitsky
2025-03-27 12:06 ` Yan Zhao
2025-03-27 23:41 ` Sean Christopherson [this message]
2025-03-28 0:52 ` Yan Zhao
2025-03-28 23:02 ` Maxim Levitsky
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=Z-XiNiQqhbwLmimp@google.com \
--to=seanjc@google.com \
--cc=jthoughton@google.com \
--cc=kvm@vger.kernel.org \
--cc=mlevitsk@redhat.com \
--cc=pbonzini@redhat.com \
--cc=yan.y.zhao@intel.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