[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+55aFxpz+1bXVsg7kMeozePa=j_2-OaOuidQ4Y9Bg063=HMfg@mail.gmail.com>
Date: Fri, 2 Sep 2011 08:38:22 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Jeremy Fitzhardinge <jeremy@...p.org>
Cc: "H. Peter Anvin" <hpa@...or.com>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...e.hu>,
"the arch/x86 maintainers" <x86@...nel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Nick Piggin <npiggin@...nel.dk>, Avi Kivity <avi@...hat.com>,
Marcelo Tosatti <mtosatti@...hat.com>,
KVM <kvm@...r.kernel.org>, Andi Kleen <andi@...stfloor.org>,
Xen Devel <xen-devel@...ts.xensource.com>,
Jeremy Fitzhardinge <jeremy.fitzhardinge@...rix.com>
Subject: Re: [PATCH 00/13] [PATCH RFC] Paravirtualized ticketlocks
On Thu, Sep 1, 2011 at 5:54 PM, Jeremy Fitzhardinge <jeremy@...p.org> wrote:
>
> The inner part of ticket lock code becomes:
> inc = xadd(&lock->tickets, inc);
> inc.tail &= ~TICKET_SLOWPATH_FLAG;
>
> for (;;) {
> unsigned count = SPIN_THRESHOLD;
>
> do {
> if (inc.head == inc.tail)
> goto out;
> cpu_relax();
> inc.head = ACCESS_ONCE(lock->tickets.head);
> } while (--count);
> __ticket_lock_spinning(lock, inc.tail);
> }
Hmm. It strikes me that I don't think you should touch the
TICKET_SLOWPATH_FLAG in the fastpath at all.
Can't you just do this:
inc = xadd(&lock->tickets, inc);
if (likely(inc.head == inc.tail))
goto out;
### SLOWPATH ###
inc.tail &= ~TICKET_SLOWPATH_FLAG;
for (;;) {
.. as before ..
which might alleviate the problem with the fastpath being polluted by
all those silly slowpath things. Hmm?
(This assumes that TICKET_SLOWPATH_FLAG is never set in inc.head, so
if it's set that equality check will fail. I didn't actually check if
that assumption was correct)
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists