[uClibc] mmaps for malloc should be private

David Howells dhowells at redhat.com
Tue Mar 30 09:50:34 UTC 2004


> > To make this work, uClinux's mmap() support had to be changed to work more
> > like that on MMU linux. To summarise the way nommu mmap() works in our
> > kernel:
> > 

> >  (*) no file, MAP_PRIVATE: mapping shared over clone() or vfork(),
> >	 discarded by execve().
> > 
> >  (*) no file, MAP_SHARED: shared over clone() or vfork(), discarded by
> >      execve().
> ...
> >  (*) file, MAP_SHARED, PROT_WRITE: not supported; it would be hard to
> >	 reflect changes to memory into the file.
> ...

I've improved things here a little. If the file being mmapped is a chardev,
then we do actually allow shared-writable mmaps, and the chardev driver can
either propose a specific address at which to create the mapping (/dev/fb0
perhaps) or can allow any old address (/dev/zero).

With chardevs, MAP_FIXED is permitted, but currently the chardev's mmap method
must verify that the address is valid. I should possibly reject mappings fixed
to an address in RAM before the chardev driver sees them. I'm not sure
though. Any thoughts?


> It doesn't.  Thus,  I think we need to have a config option in uClibc
> to handle the current limited uClinux versions.

MAP_SHARED of MAP_ANON memory works identically to MAP_PRIVATE of MAP_ANON on
uClinux, it's just that when you try and run it on vmlinux, where fork() may
be an issue that it's a problem.

Of course, uClibc could always try MAP_PRIVATE first, and if that doesn't
work, make a note in a variable to only try MAP_SHARED in future.


> All of this sounds pretty neat and I am sure a lot of people would like
> to see this added to uClinux.  Do you guys base anything off the uClinux.org
> sources ?  What kernel version are you at ?

We're currently based on linux-2.4.24-uc0 or similar downloaded from the
uclinux.org website.

> It might be nice to try and get your support for frv (and all the other
> general purpose bits) included into the source on uClinux.org ;-)

Yes.

David



More information about the uClibc mailing list