Re: [PATCH 4/6] kvm tools: Add rwlock wrapper

Mathieu Desnoyers
2011-05-27T13:22:53Z

* Ingo Molnar (mingo@elte.hu) wrote:
>
> * Mathieu Desnoyers <mathieu.desnoyers@efficios.com> wrote:
>
> > > - Check kernel/tinyrcu.c to see how RCU is implemented in its
> > > simplest form. :)
> >
> > ...so simplistic it only works on UP systems, which are not so common
> > these days on the systems targeted by kvm.
>
> As i said above, in its simplest form - which is UP.
>
> Obviously it's not tinyrcu.c that should be used by tools/kvm/ but
> what i suggested, tree-RCU:

I agree that tree-RCU has some grace-period management scalability
benefits that would be interesting to have.

> > > - Copy the tree-RCU code from kernel/treercu.c to tools/kvm/rcu/
> >
> > This code is very much tied with the kernel scheduler. [...]
>
> It would not be particularly complex to enable user-space to request
> a callback on context switch events.
>
> I was thinking on and off about allowing perf events to generate a
> per sampling event notification signal on specific events, such as
> page faults or context switches.
>
> Obviously this won't be enabled from NMI contexts due to atomicity
> constraints, but the pagefault and maybe the context switch path
> looks doable.
>
> That capability would be a rather simple kernel change and it would
> allow a user-space RCU implementation to be notified of various key
> events, context switches in particular.

I'm worried about "self-recursion" behaviors that could be triggered
though: if the userland callback code called from a page fault triggers
a page fault all by itself, then it looks like a good way to bring the
system to its knees. The same apply to context switches. Do you have a
way to handle this in mind ?

>
> Would you be interested in helping code up such a facility? The urcu
> library could make good use of it i think, regardless of what we do
> in tools/kvm/.

I'm open to try finding out the best possible approach to support RCU in
user-space (disclaimer: I might need some help on this due to my time
being fully taken by contracts currently). I guess the sweet spot will
end up being at a crossroad between kernel-only and userland-only
solution.

Thanks,

Mathieu

>
> Thanks,
>
> Ingo

--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.