virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: the arch/x86 maintainers <x86@kernel.org>,
	KVM list <kvm@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	virtualization <virtualization@lists.linux-foundation.org>,
	Paul Gortmaker <paul.gortmaker@windriver.com>,
	Peter Anvin <hpa@zytor.com>, Davidlohr Bueso <dave@stgolabs.net>,
	Andrey Ryabinin <a.ryabinin@samsung.com>,
	Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Ingo Molnar <mingo@redhat.com>,
	Sasha Levin <sasha.levin@oracle.com>,
	Paul McKenney <paulmck@linux.vnet.ibm.com>,
	Rik van Riel <riel@redhat.com>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
	Andi Kleen <ak@linux.intel.com>,
	xen-devel@lists.xenproject.org, Dave Jones <davej@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Waiman Long <waiman.long@hp.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Paolo Bonzini <pbonzini@redhat.>
Subject: Re: [PATCH] x86 spinlock: Fix memory corruption on completing completions
Date: Wed, 11 Feb 2015 18:24:34 +0100	[thread overview]
Message-ID: <20150211172434.GA28689@redhat.com> (raw)
In-Reply-To: <54DAADEE.6070506@goop.org>

On 02/10, Jeremy Fitzhardinge wrote:
>
> On 02/10/2015 05:26 AM, Oleg Nesterov wrote:
> > On 02/10, Raghavendra K T wrote:
> >> Unfortunately xadd could result in head overflow as tail is high.
> >>
> >> The other option was repeated cmpxchg which is bad I believe.
> >> Any suggestions?
> > Stupid question... what if we simply move SLOWPATH from .tail to .head?
> > In this case arch_spin_unlock() could do xadd(tickets.head) and check
> > the result
>
> Well, right now, "tail" is manipulated by locked instructions by CPUs
> who are contending for the ticketlock, but head can be manipulated
> unlocked by the CPU which currently owns the ticketlock. If SLOWPATH
> moved into head, then non-owner CPUs would be touching head, requiring
> everyone to use locked instructions on it.
>
> That's the theory, but I don't see much (any?) code which depends on that.
>
> Ideally we could find a way so that pv ticketlocks could use a plain
> unlocked add for the unlock like the non-pv case, but I just don't see a
> way to do it.

I agree, and I have to admit I am not sure I fully understand why unlock
uses the locked add. Except we need a barrier to avoid the race with the
enter_slowpath() users, of course. Perhaps this is the only reason?

Anyway, I suggested this to avoid the overflow if we use xadd(), and I
guess we need the locked insn anyway if we want to eliminate the unsafe
read-after-unlock...

> > BTW. If we move "clear slowpath" into "lock" path, then probably trylock
> > should be changed too? Something like below, we just need to clear SLOWPATH
> > before cmpxchg.
>
> How important / widely used is trylock these days?

I am not saying this is that important. Just this looks more consistent imo
and we can do this for free.

Oleg.

  reply	other threads:[~2015-02-11 17:24 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1423234148-13886-1-git-send-email-raghavendra.kt@linux.vnet.ibm.com>
2015-02-06 15:20 ` [PATCH] x86 spinlock: Fix memory corruption on completing completions Sasha Levin
2015-02-06 16:15   ` Linus Torvalds
2015-02-06 17:03     ` Andrey Ryabinin
2015-02-08 17:14   ` Oleg Nesterov
2015-02-06 16:25 ` Linus Torvalds
2015-02-06 19:42   ` Davidlohr Bueso
     [not found]   ` <1423251764.1057.1.camel@stgolabs.net>
2015-02-06 21:15     ` Sasha Levin
2015-02-06 23:24       ` Davidlohr Bueso
2015-02-08 17:49   ` Raghavendra K T
2015-02-06 18:57 ` Sasha Levin
2015-02-08 17:57   ` Raghavendra K T
2015-02-08 21:14 ` Jeremy Fitzhardinge
     [not found] ` <54D7D19B.1000103@goop.org>
2015-02-09  9:34   ` Raghavendra K T
     [not found]   ` <54D87F1E.9060307@linux.vnet.ibm.com>
2015-02-09 12:02     ` Peter Zijlstra
2015-02-09 12:52       ` Raghavendra K T
2015-02-10  0:53       ` Linus Torvalds
2015-02-10  9:30         ` Raghavendra K T
2015-02-10 13:18           ` Denys Vlasenko
2015-02-10 13:23           ` Sasha Levin
2015-02-10 13:26           ` Oleg Nesterov
2015-02-11  1:18             ` Jeremy Fitzhardinge
2015-02-11 17:24               ` Oleg Nesterov [this message]
2015-02-11 23:15                 ` Jeremy Fitzhardinge
     [not found]                 ` <54DBE27C.8050105@goop.org>
2015-02-11 23:28                   ` Linus Torvalds
2015-02-12  7:08                     ` Jeremy Fitzhardinge
2015-02-12 14:18                   ` Oleg Nesterov
2015-02-11 11:08             ` Raghavendra K T
     [not found]             ` <54DB384A.2050305@linux.vnet.ibm.com>
2015-02-11 17:38               ` Oleg Nesterov
2015-02-11 18:38                 ` Raghavendra K T
     [not found]           ` <CAK1hOcNZ+hfjt=CmtZumPoFQRdQbf9SSEF0cOWv9-9ku0K7bcg@mail.gmail.com>
2015-02-10 13:20             ` Denys Vlasenko
2015-02-10 14:24             ` Oleg Nesterov
2015-02-06 14:49 Raghavendra K T

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=20150211172434.GA28689@redhat.com \
    --to=oleg@redhat.com \
    --cc=a.ryabinin@samsung.com \
    --cc=ak@linux.intel.com \
    --cc=borntraeger@de.ibm.com \
    --cc=dave@stgolabs.net \
    --cc=davej@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jeremy@goop.org \
    --cc=konrad.wilk@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paul.gortmaker@windriver.com \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=pbonzini@redhat. \
    --cc=peterz@infradead.org \
    --cc=raghavendra.kt@linux.vnet.ibm.com \
    --cc=riel@redhat.com \
    --cc=sasha.levin@oracle.com \
    --cc=tglx@linutronix.de \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=waiman.long@hp.com \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.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;
as well as URLs for NNTP newsgroup(s).