Re: [ofa-general] Re: [GIT PULL] please pull ummunotify

Peter Zijlstra
2009-09-17T14:49:36Z

On Thu, 2009-09-17 at 07:32 -0700, Roland Dreier wrote:
> > So getting those events in the kernel is no problem -- we have the MMU
> > notifier hooks that tell us exactly what we need to know. The issue is
> > purely the way userspace registers interest in address ranges, and how
> > to kernel returns the events.
> >
> > For perf counters it seems that one would have to create a new counter
> > for each address range... is that correct? And also I don't know if
> > perf counter has an analog for the fast path optimization that
> > ummunotify provides via a mmap'ed generation counter (a quick way for
> > userspace to see 'nothing happened since last time you checked').
>
> Oh I forgot... ummunotify also preallocates everything etc. so that
> there is no way for events to be lost. Which saves userspace from
> having to trash everything cached and start over, which it would have to
> do if it misses an invalidate event.
>
> And AFAIK, pref counters does have the possibility of overflowing a
> buffer and losing an event, right?

Well, you cannot pre-allocate everything, either you get back-logged
evens in kernel space leading to a kernel DoS, or you loose events.

Perf counters have two modes, a RO mmap() and a RW mmap(). The RO mode
will automagically overwrite its tail data without regard for userspace
having observed it.

In the RW mode userspace has to advance the tail, the kernel will drop
events when full and insert a PERF_EVENT_LOST event once there is room
again.

Hmm, or are you saying you can only get 1 event per registered range and
allocate the thing on registration? That'd need some registration limit
to avoid DoS scenarios.