Subject: RE: map user memory in kernel
To: Jaromir Dolecek <jdolecek@NetBSD.org>
From: Gordon Waidhofer <gww@traakan.com>
List: tech-kern
Date: 11/06/2005 14:58:05
What guarantees does futex() make?

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?

	-gww

> -----Original Message-----
> From: tech-kern-owner@NetBSD.org [mailto:tech-kern-owner@NetBSD.org]On
> Behalf Of Jaromir Dolecek
> Sent: Sunday, November 06, 2005 2:53 PM
> To: Chuck Silvers
> Cc: Eric Haszlakiewicz; Thor Lancelot Simon; Emmanuel Dreyfus;
> tech-kern@NetBSD.org
> Subject: Re: map user memory in kernel
> 
> 
> On Sun, Nov 06, 2005 at 01:52:16PM -0800, Chuck Silvers wrote:
> > On Sun, Nov 06, 2005 at 09:49:31PM +0100, Jaromir Dolecek wrote:
> > > > the logical page can be paged out and replaced with a different
> > > > physical page when it's paged backed in, so we cannot use the
> > > > vm_page pointer for this purpose.
> > > 
> > > Could we use vm_map_entry ?
> > 
> > how?  could you be more specific?
> 
> I mean, use address of appropriate vm_map_entry as the futex wait
> channel base. However, that is process-specific too, sorry for the
> noise :)
> 
> Okay, back to anon:
> 
> > > vm_anon is per-process thing, so we don't want to use that -
> > > we need to use the vm_page or vm_object.
> 
> > also, I believe there are already cases where will we replace the anon
> > that is used to represent a given page of process anonymous memory
> > with a different anon, and I plan on adding more.  we should not rely
> > on the anon remaining the same.
> 
> If the anonymous memory is shared, both processes actually use 
> the same anon
> structure, right? Why would you want to replace the anon with
> different one?
> 
> Jaromir
> -- 
> Jaromir Dolecek <jdolecek@NetBSD.org>            http://www.NetBSD.cz/
> -=- We can walk our road together if our goals are all the same;     -=-
> -=- We can run alone and free if we pursue a different aim.          -=-
> 
>