lkml.org 
[lkml]   [1997]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Unmapping memory
> 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.

> With this ability, a free() implementation could invoke this call any time
> a largish chunk of memory is truly discarded, and thereby genuinely give
> memory back to the OS, _without_ the significant overhead and limitations
> of using mmap() and munmap().

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.
- 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.
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

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