From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: Re: [PATCH 3/4] kvm tools: Add a brlock Date: Sun, 29 May 2011 22:30:58 +0300 Message-ID: <1306697458.14564.22.camel@lappy> References: <1306690348-23260-1-git-send-email-levinsasha928@gmail.com> <1306690348-23260-3-git-send-email-levinsasha928@gmail.com> <20110529184731.GB9835@elte.hu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: penberg@kernel.org, avi@redhat.com, kvm@vger.kernel.org, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com To: Ingo Molnar Return-path: Received: from mail-wy0-f174.google.com ([74.125.82.174]:38336 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752761Ab1E2Tb1 (ORCPT ); Sun, 29 May 2011 15:31:27 -0400 Received: by wya21 with SMTP id 21so2235520wya.19 for ; Sun, 29 May 2011 12:31:26 -0700 (PDT) In-Reply-To: <20110529184731.GB9835@elte.hu> Sender: kvm-owner@vger.kernel.org List-ID: On Sun, 2011-05-29 at 20:47 +0200, Ingo Molnar wrote: > * Sasha Levin 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. > > +#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? -- Sasha.