[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] Re: [PATCH 00/13] [PATCH RFC] Paravirtualized ticketlocks



On Thu, Sep 1, 2011 at 5:54 PM, Jeremy Fitzhardinge <jeremy@xxxxxxxx> 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

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.