linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: Paolo Bonzini <pbonzini@redhat.com>,
	linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: seanjc@google.com, Joel Fernandes <joel@joelfernandes.org>,
	Matthew Wilcox <willy@infradead.org>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Josh Triplett <josh@joshtriplett.org>,
	rcu@vger.kernel.org, Michal Luczaj <mhal@rbox.co>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] Documentation: kvm: fix SRCU locking order docs
Date: Thu, 12 Jan 2023 08:24:16 +0000	[thread overview]
Message-ID: <a14a13a690277d4cc95a4b26aa2d9a4d9b392a74.camel@infradead.org> (raw)
In-Reply-To: <20230111183031.2449668-1-pbonzini@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1022 bytes --]

On Wed, 2023-01-11 at 13:30 -0500, Paolo Bonzini wrote:
> 
> +- ``synchronize_srcu(&kvm->srcu)`` is called inside critical sections
> +  for kvm->lock, vcpu->mutex and kvm->slots_lock.  These locks _cannot_
> +  be taken inside a kvm->srcu read-side critical section; that is, the
> +  following is broken::
> +
> +      srcu_read_lock(&kvm->srcu);
> +      mutex_lock(&kvm->slots_lock);
> +

"Don't tell me. Tell lockdep!"

Did we conclude in
https://lore.kernel.org/kvm/122f38e724aae9ae8ab474233da1ba19760c20d2.camel@infradead.org/
that lockdep *could* be clever enough to catch a violation of this rule
by itself?

The general case of the rule would be that 'if mutex A is taken in a
read-section for SCRU B, then any synchronize_srcu(B) while mutex A is
held shall be verboten'. And vice versa.

If we can make lockdep catch it automatically, yay!

If not, I'm inclined to suggest that we have explicit wrappers of our
own for kvm_mutex_lock() which will do the check directly.

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]

  reply	other threads:[~2023-01-12  8:24 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11 18:30 [PATCH] Documentation: kvm: fix SRCU locking order docs Paolo Bonzini
2023-01-12  8:24 ` David Woodhouse [this message]
2023-01-12 15:20   ` Paul E. McKenney
2023-01-13  7:18     ` Boqun Feng
2023-01-13  9:20       ` Paolo Bonzini
2023-01-13 10:33         ` David Woodhouse
2023-01-13 11:03           ` David Woodhouse
2023-01-13 22:26             ` Michal Luczaj
2023-01-14  0:02           ` Boqun Feng
2023-01-16 17:37           ` Paolo Bonzini

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=a14a13a690277d4cc95a4b26aa2d9a4d9b392a74.camel@infradead.org \
    --to=dwmw2@infradead.org \
    --cc=joel@joelfernandes.org \
    --cc=josh@joshtriplett.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhal@rbox.co \
    --cc=paulmck@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rcu@vger.kernel.org \
    --cc=seanjc@google.com \
    --cc=willy@infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).