public inbox for linux-arch@vger.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>, Rob Landley <rob@landley.net>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, Arnd Bergmann <arnd@arndb.de>,
	David Howells <dhowells@redhat.com>,
	Akinobu Mita <akinobu.mita@gmail.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Herbert Xu <herbert@gondor.hengli.com.au>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arch@vger.kernel.org, Gleb Natapov <gleb@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	kvm@vger.kernel.org, Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] bitops: add _local bitops
Date: Wed, 9 May 2012 23:07:36 +0300	[thread overview]
Message-ID: <20120509200735.GA22743@redhat.com> (raw)
In-Reply-To: <20120509121940.459e93ba.akpm@linux-foundation.org>

On Wed, May 09, 2012 at 12:19:40PM -0700, Andrew Morton wrote:
> On Wed, 9 May 2012 16:45:29 +0300
> "Michael S. Tsirkin" <mst@redhat.com> wrote:
> 
> > kvm needs to update some hypervisor variables atomically
> > in a sense that the operation can't be interrupted
> > in the middle. However the hypervisor always runs
> > on the same CPU so it does not need any memory
> > barrier or lock prefix.
> 
> Well.  It adds more complexity, makes the kernel harder to understand
> and maintain and introduces more opportunities for developers to add
> bugs.  So from that point of view, the best way of handling this patch
> is to delete it.
> 
> Presumably the patch offers some benefit to offest all those costs. 
> But you didn't tell us what that benefit is, so we cannot make
> a decision.
> 
> IOW: numbers, please.  Convincing ones, for realistic test cases.

I can try but in practice it's not an optimization.
What kvm needs is a guarantee that a memory update will be done in a
single instruction.

> Secondly: can KVM just use __set_bit() and friends?  I suspect those
> interfaces happen to meet your requirements.  At least on architectures
> you care about.

Sigh. I started with this, but then Avi Kivity said that he's worried
about someone changing __test_and_clear_bit on x86
such that the change won't be atomic (single instruction) anymore.
So I put inline asm into kvm.c. This drew comment from Peter
that maintaining separate asm code in kvm.c adds too much
maintainance overhead so I should implement _local, add
asm-generic fallback and put it all in generic code.

In practice ATM any of the above will work. We probably don't even need
to add barrier() calls since what we do afterwards is apic access which
has an optimization barrier anyway.  But I'm fine with adding them in
there just in case if that's what people want.

However, since we've come full circle, I'd like to have a discussion
on what, exactly, is acceptable to all maintainers.
Avi, Andrew, Peter, could you please comment?

-- 
MST

  parent reply	other threads:[~2012-05-09 20:07 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-09 13:45 [PATCH] bitops: add _local bitops Michael S. Tsirkin
2012-05-09 13:45 ` Michael S. Tsirkin
2012-05-09 14:03 ` H. Peter Anvin
2012-05-09 14:03   ` H. Peter Anvin
2012-05-09 15:06   ` Michael S. Tsirkin
2012-05-09 15:06     ` Michael S. Tsirkin
2012-05-09 15:43   ` Michael S. Tsirkin
2012-05-09 15:43     ` Michael S. Tsirkin
2012-05-09 15:44     ` H. Peter Anvin
2012-05-09 15:44       ` H. Peter Anvin
2012-05-09 15:47   ` Michael S. Tsirkin
2012-05-09 15:47     ` Michael S. Tsirkin
2012-05-09 16:24     ` H. Peter Anvin
2012-05-09 16:24       ` H. Peter Anvin
2012-05-09 16:36       ` Michael S. Tsirkin
2012-05-09 16:45         ` H. Peter Anvin
2012-05-09 16:45           ` H. Peter Anvin
2012-05-09 16:55           ` Michael S. Tsirkin
2012-05-09 16:55             ` Michael S. Tsirkin
2012-05-09 14:06 ` Arnd Bergmann
2012-05-09 14:06   ` Arnd Bergmann
2012-05-09 14:17 ` Avi Kivity
2012-05-09 19:19 ` Andrew Morton
2012-05-09 19:23   ` H. Peter Anvin
2012-05-09 19:23     ` H. Peter Anvin
2012-05-09 20:07   ` Michael S. Tsirkin [this message]
2012-05-09 20:10     ` H. Peter Anvin
2012-05-09 20:10       ` H. Peter Anvin
2012-05-09 20:12       ` Michael S. Tsirkin
2012-05-09 20:12         ` Michael S. Tsirkin
2012-05-10  9:26         ` Avi Kivity
2012-05-10 23:02       ` Benjamin Herrenschmidt
2012-05-10 17:38 ` Rob Landley
2012-05-10 17:38   ` Rob Landley

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=20120509200735.GA22743@redhat.com \
    --to=mst@redhat.com \
    --cc=adobriyan@gmail.com \
    --cc=akinobu.mita@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=avi@redhat.com \
    --cc=dhowells@redhat.com \
    --cc=gleb@redhat.com \
    --cc=herbert@gondor.hengli.com.au \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=mtosatti@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=rob@landley.net \
    --cc=sfr@canb.auug.org.au \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@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