From: Ingo Molnar <mingo@elte.hu>
To: Sasha Levin <levinsasha928@gmail.com>
Cc: penberg@kernel.org, avi@redhat.com, kvm@vger.kernel.org,
asias.hejun@gmail.com, gorcunov@gmail.com,
prasadjoshi124@gmail.com
Subject: Re: [PATCH 3/4] kvm tools: Add a brlock
Date: Sun, 29 May 2011 21:38:25 +0200 [thread overview]
Message-ID: <20110529193825.GA13539@elte.hu> (raw)
In-Reply-To: <1306697458.14564.22.camel@lappy>
* Sasha Levin <levinsasha928@gmail.com> wrote:
> On Sun, 2011-05-29 at 20:47 +0200, Ingo Molnar wrote:
> > * Sasha Levin <levinsasha928@gmail.com> wrote:
> >
> > > +++ b/tools/kvm/include/kvm/brlock.h
> > > @@ -0,0 +1,12 @@
> > > +#ifndef KVM__BRLOCK_H
> > > +#define KVM__BRLOCK_H
> > > +
> > > +#include "kvm/kvm.h"
> > > +#include "kvm/barrier.h"
> > > +
> > > +#define br_read_lock() mb()
> > > +#define br_read_unlock() mb()
> >
> > These only need to be compiler barrier()s AFAICS, because the 'pause'
> > op will signal back to the requestor thread - which whole operation
> > is a barrier to begin with.
>
> I'm wondering why we need a barrier here at all. In this brlock
> implementation the readers are waiting on a mutex in their main
> loop - right before a call to KVM_RUN. They can't get anywhere near
> a br_read_lock() once br_write_lock() has completed.
Yes - and i alluded to that in one of my previous mails - but i think
we should do a barrier() just to make sure people use them ;-)
We don't want huge sections of code assuming readonly data
structures. We should probably also add a debug variant that switches
this all to rwlocks: that way the correctness of the critical
sections can be tested.
5 years down the line we do not want to end up with another 'BKL'
kind of situation.
> > > +#define br_write_lock() kvm__pause()
> > > +#define br_write_unlock() kvm__continue()
> > > +#endif
> >
> > Btw., it might make sense to add a comment to this header file,
> > explaining what a 'big reader lock' is :-)
>
> I'll put the commit message into the header, should be enough?
Yeah, that should be more than enough!
Thanks,
Ingo
next prev parent reply other threads:[~2011-05-29 19:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-29 17:32 [PATCH 1/4] kvm tools: Use correct value for user signal base Sasha Levin
2011-05-29 17:32 ` [PATCH 2/4] kvm tools: Allow pausing guests Sasha Levin
2011-05-29 17:56 ` Sasha Levin
2011-05-29 17:32 ` [PATCH 3/4] kvm tools: Add a brlock Sasha Levin
2011-05-29 18:47 ` Ingo Molnar
2011-05-29 19:30 ` Sasha Levin
2011-05-29 19:38 ` Ingo Molnar [this message]
2011-05-29 17:32 ` [PATCH 4/4] kvm tools: Use brlock in MMIO and IOPORT Sasha Levin
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=20110529193825.GA13539@elte.hu \
--to=mingo@elte.hu \
--cc=asias.hejun@gmail.com \
--cc=avi@redhat.com \
--cc=gorcunov@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=levinsasha928@gmail.com \
--cc=penberg@kernel.org \
--cc=prasadjoshi124@gmail.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.