Re: crazy idea: big percpu lock (Re: task isolation)

Rik van Riel
2015-11-10T14:19:10Z

On 10/28/2015 02:45 PM, Andy Lutomirski wrote:

>> The model I chose is to have a per-cpu state that indicates whether
>> the core is in kernel space, in user space, or in user space with
>> a TLB flush pending. On entry to user space with task isolation
>> in effect we just set the state to "user". When doing a remote
>> TLB flush we decide whether or not to actually issue the flush by
>> doing a cmpxchg() from "user" to "user pending", and if the
>> old state was either "user" or "user pending", we don't issue the
>> flush. Finally, on entry to the kernel for a task-isolation task we
>> do an atomic xchg() to set the state to "kernel", and if we discover
>> a flush was pending, we just globally flush the kernel's full VA range
>> (no real reason to optimize for this case).
>
> This sounds like it belongs in the generic context tracking code, or
> at least the tracking part and the option to handle deferred work
> should go there.

I wonder if your whole idea could also piggyback on the
context tracking code.

If the remote CPU is in a quiescent state, have the per-cpu
thing done by the calling CPU, instead of interrupting the
quiescent CPU.

In the unlikely event quiescent CPU wakes up (or returns to
kernel space) while some per-cpu thing is done remotely, it
can wait for completion before it continues into the kernel.

The amount of time it waits will, at worst, be as much as
it would have spent doing that per-cpu thing itself.

--
All rights reversed