Subject: Re: map user memory in kernel
To: Emmanuel Dreyfus <manu@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 11/06/2005 08:19:18
On Sun, Nov 06, 2005 at 07:48:30AM +0000, Emmanuel Dreyfus wrote:
> On Sat, Nov 05, 2005 at 06:52:56PM -0800, Chuck Silvers wrote:
> > I don't see any robust way to construct a unique sleep address per futex
> > with UVM.  for now, the best thing to do would be to use one global sleep
> > address for all futex sleepers.
> 
> Yes, but how to cope with that:
> 
> process A maps some memory at address X
> process B maps the same memory at address Y
> 
> A sleeps on futex at X, B wakes up futex at Y. That should wake up
> process A. How do I discover (in kernel code) that X and Y are the same
> VM object?

With a single global sleep address you would wakeup A, you'd also wakeup
process C sleeping on an entirely different futex - but the code in C
should verify that the event it is waiting for has happened.

You could use [1]:
#define FUTEXT_SLEEP_IDENT(addr) ((void *)(0xf7478000u | (addr) & 0x7ff))
Since the 'offset in page' will be the same whatever address the item
is mapped at.

	David

[1] it needs more casts...

-- 
David Laight: david@l8s.co.uk