Re: [PATCH RFC V5 00/11] Paravirtualized ticketlocks

From: Jason Baron
Date: Fri Oct 14 2011 - 10:18:29 EST


On Thu, Oct 13, 2011 at 09:44:48AM -0700, Jeremy Fitzhardinge wrote:
> On 10/13/2011 03:54 AM, Peter Zijlstra wrote:
> > On Wed, 2011-10-12 at 17:51 -0700, Jeremy Fitzhardinge wrote:
> >> This is is all unnecessary complication if you're not using PV ticket
> >> locks, it also uses the jump-label machinery to use the standard
> >> "add"-based unlock in the non-PV case.
> >>
> >> if (TICKET_SLOWPATH_FLAG &&
> >> unlikely(static_branch(&paravirt_ticketlocks_enabled))) {
> >> arch_spinlock_t prev;
> >>
> >> prev = *lock;
> >> add_smp(&lock->tickets.head, TICKET_LOCK_INC);
> >>
> >> /* add_smp() is a full mb() */
> >>
> >> if (unlikely(lock->tickets.tail & TICKET_SLOWPATH_FLAG))
> >> __ticket_unlock_slowpath(lock, prev);
> >> } else
> >> __add(&lock->tickets.head, TICKET_LOCK_INC, UNLOCK_LOCK_PREFIX);
> > Not that I mind the jump_label usage, but didn't paravirt have an
> > existing alternative() thingy to do things like this? Or is the
> > alternative() stuff not flexible enough to express this?
>
> Yeah, that's a good question. There are three mechanisms with somewhat
> overlapping concerns:
>
> * alternative()
> * pvops patching
> * jump_labels
>
> Alternative() is for low-level instruction substitution, and really only
> makes sense at the assembler level with one or two instructions.
>
> pvops is basically a collection of ordinary _ops structures full of
> function pointers, but it has a layer of patching to help optimise it.
> In the common case, this just replaces an indirect call with a direct
> one, but in some special cases it can inline code. This is used for
> small, extremely performance-critical things like cli/sti, but it
> awkward to use in general because you have to specify the inlined code
> as a parameterless asm.
>

I haven't look at the pvops patching (probably should), but I was
wondering if jump labels could be used for it? Or is there something
that the pvops patching is doing that jump labels can't handle?


> Jump_labels is basically an efficient way of doing conditionals
> predicated on rarely-changed booleans - so it's similar to pvops in that
> it is effectively a very ordinary C construct optimised by dynamic code
> patching.
>

Another thing is that it can be changed at run-time...Can pvops be
adjusted at run-time as opposed to just boot-time?

thanks,

-Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/