lkml.org 
[lkml]   [1997]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Unmapping memory
On Tue, 6 May 1997, Martin von Loewis wrote:

> > Would it be possible to add a syscall to "zero" a range of memory? I mean
> > not only clear it to zero, as with memset, but if any complete pages are
> > within the range, unmap them, and replace them with zero mappings (as
> > mmap()'ing /dev/zero gives you).
>
> You could just mmap /dev/zero instead. No need to unmap what was previously
> there, it will get automatically discarded. The malloc implementation would
> need to keep a file descriptor for /dev/zero to avoid the overhead of
> opening the file over and over again. Other than that, there would be no
> overhead compared to a special-case system call.

Ah, so a mmap of /dev/zero doesn't involve any of the overhead of a
"normal" mmapping of a file, then? If so, and you can successfully mmap in
blank pages over sbrk()'d space with this, without consuming any
resources, then it does indeed match my request.

> I think one should perform measurements first to find out:
> - how many, and which applications suffer from this phenomen. E.g. after
> running Netscape for one day, how many pages could be returned to the
> system. LD_PRELOAD is your friend, here.

Agreed.

> - for those applications, how much overhead is introduced by inserting the
> additional mappings. For example, drivers/char/mem.c:read_zero only changes
> the mapping if the user requested at least four pages.

And whether the implementation should wait for eight pages, or whatever,
to be free before discarding them in this manner.

> Once those data are available, we could decide whether this algorithm
> becomes part of the standard C library, or a special malloc library that
> is only linked into selected applications.
>
> Regards,
> Martin

--
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)



\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.038 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site