public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Glauber Costa <glommer@redhat.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, avi@redhat.com
Subject: Re: [PATCH] remove static declaration from wall clock version
Date: Thu, 26 Feb 2009 22:22:22 -0300	[thread overview]
Message-ID: <20090227012222.GA5979@poweredge.glommer> (raw)
In-Reply-To: <200902262050.27555.arnd@arndb.de>

On Thu, Feb 26, 2009 at 08:50:26PM +0100, Arnd Bergmann wrote:
> On Thursday 26 February 2009, Glauber Costa wrote:
> > @@ -548,15 +548,13 @@ static int do_set_msr(struct kvm_vcpu *vcpu, unsigned index, u64 *data)
> >  
> >  static void kvm_write_wall_clock(struct kvm *kvm, gpa_t wall_clock)
> >  {
> > -       static int version;
> > +       int version = 1;
> >         struct pvclock_wall_clock wc;
> >         struct timespec now, sys, boot;
> >  
> >         if (!wall_clock)
> >                 return;
> >  
> > -       version++;
> > -
> >         kvm_write_guest(kvm, wall_clock, &version, sizeof(version));
> >  
> >         /*
> 
> Doesn't this mean that kvm_write_guest now writes an uninitialized value
> to the guest?
No. If you look closely, it's now initialized to 1.

> 
> I think what you need here is a 'static atomic_t version;' so you can
> do an atomic_inc instead of the ++.

I don't see the need for atomicity. This is just called once, at boot time.
The only thing we're protecting here is one guest from another. The stack
will do fine for this.

  reply	other threads:[~2009-02-27  1:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-26 19:42 [PATCH] remove static declaration from wall clock version Glauber Costa
2009-02-26 19:50 ` Arnd Bergmann
2009-02-27  1:22   ` Glauber Costa [this message]
2009-02-27  1:28     ` Arnd Bergmann
2009-02-27 16:44 ` Marcelo Tosatti
2009-03-03 11:21 ` Marcelo Tosatti
2009-03-08 12:15 ` Avi Kivity

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=20090227012222.GA5979@poweredge.glommer \
    --to=glommer@redhat.com \
    --cc=arnd@arndb.de \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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