Subject: RE: map user memory in kernel
To: Eric Haszlakiewicz <erh@nimenees.com>
From: Gordon Waidhofer <gww@traakan.com>
List: tech-kern
Date: 11/06/2005 19:29:12
> > If they are as light at tsleep()/wakeup(), then,
> > as somebody already pointed out:
> > 
> > 	int futex_event;
> > 	futex_sleep () { sleep (&futex_event); }
> > 	futex_wakeup () { wakeup (&futex_event); }
> > 
> > will work. Everything else is an improvement.
> > Is this a case of trying to hard? It really depends
> > on the guarantees made by futex() and whether the
> > kernel need to manipulate any variables visible in
> > userland. Is that the case? What is the case?
> 
> 	I don't think that's going to cut it.  I read that even
> waking up too many processes on a single futex can cause things
> to go 20x slower.  Creating a thundering herd of all users of
> futex on a system would probably make it unusable.

I'm sure you are right. But measure it first.

The trick using the page offset (addr&0xFFF) to calculate
a 32-bit event ID would work just fine. Then measure that.
If it's still not good enough, then more aggressive means
of coming up with a rendevouz event ID can be sought including
drilling through all the VM data structures.

Unless there is something about futex() I'm missing
(entirely possible), you'll get to victory long before
you have to worry about navigating VM data structures.

	-gww