All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@samba.org>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Alexander Graf <agraf@suse.de>,
	kvm-ppc@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [RFC PATCH 5/5] KVM: PPC: Take the SRCU lock around memslot use
Date: Fri, 10 Aug 2012 10:37:15 +1000	[thread overview]
Message-ID: <20120810003715.GC26420@bloggs.ozlabs.ibm.com> (raw)
In-Reply-To: <20120809182717.GC12285@amt.cnet>

On Thu, Aug 09, 2012 at 03:27:17PM -0300, Marcelo Tosatti wrote:
> On Mon, Aug 06, 2012 at 08:08:16PM +1000, Paul Mackerras wrote:
> > The generic KVM code uses SRCU (sleeping RCU) to protect accesses
> > to the memslots data structures against updates due to userspace
> > adding, modifying or removing memory slots.  We need to do that too,
> > both to avoid accessing stale copies of the memslots and to avoid
> > lockdep warnings.  This therefore adds srcu_read_lock/unlock pairs
> > around code that accesses and uses memslots in the Book 3S PR code
> > and the Book E (44x and e500) code.
> > 
> > Signed-off-by: Paul Mackerras <paulus@samba.org>
> > ---
> > Compile-tested only.
> > 
> >  arch/powerpc/kvm/44x_tlb.c   |    6 ++++++
> >  arch/powerpc/kvm/book3s_pr.c |    6 ++++++
> >  arch/powerpc/kvm/e500_tlb.c  |    6 ++++++
> >  3 files changed, 18 insertions(+)
> 
> On top of the previous comment:
> 
> x86 calls srcu_read_lock at the beginning of the KVM_RUN ioctl handler
> (__vcpu_run in arch/x86/kvm/x86.c), unlocks srcu on guest entry, locks
> on guest exit before any potential use of memslots, and unlocks on
> exit to userspace.
> 
> This has the advantage of not sprinkling srcu lock/unlock calls all over
> (except from other ioctls, of course). Its low maintenance.
> 
> Perhaps doing the same on PPC is not a bad idea.

Perhaps... these changes are to areas of the PPC KVM code that I don't
use or maintain, so they're really more a suggestion of one way to fix
the problem than anything else.  That's why I put RFC in the subject
line.  It would be up to Alex whether he wants to fix it like this or
by taking the SRCU lock at a higher level.

Paul.

WARNING: multiple messages have this Message-ID (diff)
From: Paul Mackerras <paulus@samba.org>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Alexander Graf <agraf@suse.de>,
	kvm-ppc@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [RFC PATCH 5/5] KVM: PPC: Take the SRCU lock around memslot use
Date: Fri, 10 Aug 2012 00:37:15 +0000	[thread overview]
Message-ID: <20120810003715.GC26420@bloggs.ozlabs.ibm.com> (raw)
In-Reply-To: <20120809182717.GC12285@amt.cnet>

On Thu, Aug 09, 2012 at 03:27:17PM -0300, Marcelo Tosatti wrote:
> On Mon, Aug 06, 2012 at 08:08:16PM +1000, Paul Mackerras wrote:
> > The generic KVM code uses SRCU (sleeping RCU) to protect accesses
> > to the memslots data structures against updates due to userspace
> > adding, modifying or removing memory slots.  We need to do that too,
> > both to avoid accessing stale copies of the memslots and to avoid
> > lockdep warnings.  This therefore adds srcu_read_lock/unlock pairs
> > around code that accesses and uses memslots in the Book 3S PR code
> > and the Book E (44x and e500) code.
> > 
> > Signed-off-by: Paul Mackerras <paulus@samba.org>
> > ---
> > Compile-tested only.
> > 
> >  arch/powerpc/kvm/44x_tlb.c   |    6 ++++++
> >  arch/powerpc/kvm/book3s_pr.c |    6 ++++++
> >  arch/powerpc/kvm/e500_tlb.c  |    6 ++++++
> >  3 files changed, 18 insertions(+)
> 
> On top of the previous comment:
> 
> x86 calls srcu_read_lock at the beginning of the KVM_RUN ioctl handler
> (__vcpu_run in arch/x86/kvm/x86.c), unlocks srcu on guest entry, locks
> on guest exit before any potential use of memslots, and unlocks on
> exit to userspace.
> 
> This has the advantage of not sprinkling srcu lock/unlock calls all over
> (except from other ioctls, of course). Its low maintenance.
> 
> Perhaps doing the same on PPC is not a bad idea.

Perhaps... these changes are to areas of the PPC KVM code that I don't
use or maintain, so they're really more a suggestion of one way to fix
the problem than anything else.  That's why I put RFC in the subject
line.  It would be up to Alex whether he wants to fix it like this or
by taking the SRCU lock at a higher level.

Paul.

  reply	other threads:[~2012-08-10  0:45 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-06 10:02 [PATCH 0/5] Improve memory slot handling and other fixes Paul Mackerras
2012-08-06 10:02 ` Paul Mackerras
2012-08-06 10:03 ` [PATCH 1/5] KVM: PPC: Book3S HV: Fix incorrect branch in H_CEDE code Paul Mackerras
2012-08-06 10:03   ` Paul Mackerras
2012-08-06 10:04 ` [PATCH 2/5] KVM: PPC: Quieten message about allocating linear regions Paul Mackerras
2012-08-06 10:04   ` Paul Mackerras
2012-08-06 10:06 ` [PATCH 3/5] KVM: PPC: Book3S HV: Handle memory slot deletion and modification correctly Paul Mackerras
2012-08-06 10:06   ` Paul Mackerras
2012-08-09 18:16   ` Marcelo Tosatti
2012-08-09 18:16     ` Marcelo Tosatti
2012-08-10  0:34     ` Paul Mackerras
2012-08-10  0:34       ` Paul Mackerras
2012-08-10  1:25       ` Marcelo Tosatti
2012-08-10  1:25         ` Marcelo Tosatti
2012-08-10  1:33         ` Marcelo Tosatti
2012-08-10  1:33           ` Marcelo Tosatti
2012-08-10  2:09         ` Takuya Yoshikawa
2012-08-10  2:09           ` Takuya Yoshikawa
2012-08-10 18:35           ` Marcelo Tosatti
2012-08-10 18:35             ` Marcelo Tosatti
2012-08-11  0:37             ` Paul Mackerras
2012-08-11  0:37               ` Paul Mackerras
2012-08-13 16:34               ` Marcelo Tosatti
2012-08-13 16:34                 ` Marcelo Tosatti
2012-08-13 22:04                 ` Marcelo Tosatti
2012-08-13 22:04                   ` Marcelo Tosatti
2012-08-15  9:26                   ` Avi Kivity
2012-08-15  9:26                     ` Avi Kivity
2012-08-15 17:59                     ` Marcelo Tosatti
2012-08-15 17:59                       ` Marcelo Tosatti
2012-08-17  7:06                       ` Benjamin Herrenschmidt
2012-08-17  7:06                         ` Benjamin Herrenschmidt
2012-08-17 18:39                         ` Marcelo Tosatti
2012-08-17 18:39                           ` Marcelo Tosatti
2012-08-17 20:32                           ` Benjamin Herrenschmidt
2012-08-17 20:32                             ` Benjamin Herrenschmidt
2012-08-23 13:55                             ` Marcelo Tosatti
2012-08-23 13:55                               ` Marcelo Tosatti
2012-08-24  9:29                               ` Paul Mackerras
2012-08-24  9:29                                 ` Paul Mackerras
2012-08-24 18:58                                 ` Marcelo Tosatti
2012-08-24 18:58                                   ` Marcelo Tosatti
2012-08-19  9:39                           ` Avi Kivity
2012-08-19  9:39                             ` Avi Kivity
2012-08-15  6:06                 ` Paul Mackerras
2012-08-15  6:06                   ` Paul Mackerras
2012-08-15  9:23                 ` Avi Kivity
2012-08-15  9:23                   ` Avi Kivity
2012-08-06 10:06 ` [PATCH 4/5] KVM: PPC: Book3S HV: Take the SRCU read lock before looking up memslots Paul Mackerras
2012-08-06 10:06   ` Paul Mackerras
2012-08-09 18:22   ` Marcelo Tosatti
2012-08-09 18:22     ` Marcelo Tosatti
2012-08-10  0:45     ` Paul Mackerras
2012-08-10  0:45       ` Paul Mackerras
2012-08-06 10:08 ` [RFC PATCH 5/5] KVM: PPC: Take the SRCU lock around memslot use Paul Mackerras
2012-08-06 10:08   ` Paul Mackerras
2012-08-09 18:27   ` Marcelo Tosatti
2012-08-09 18:27     ` Marcelo Tosatti
2012-08-10  0:37     ` Paul Mackerras [this message]
2012-08-10  0:37       ` Paul Mackerras
2012-08-10  9:27       ` Alexander Graf
2012-08-10  9:27         ` Alexander Graf
2012-08-15  8:16         ` Benjamin Herrenschmidt
2012-08-15  8:16           ` Benjamin Herrenschmidt
2012-08-10  9:23 ` [PATCH 0/5] Improve memory slot handling and other fixes Alexander Graf
2012-08-10  9:23   ` Alexander Graf

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=20120810003715.GC26420@bloggs.ozlabs.ibm.com \
    --to=paulus@samba.org \
    --cc=agraf@suse.de \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.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.