Re: Ideas for memory management hackers.

Alexander Kjeldaas (astor@guardian.no)
Fri, 14 Nov 1997 15:58:09 +0100 (MET)


On Fri, 14 Nov 1997, Pavel Machek wrote:

> Hi!
> > > Send Linux memory-management wishes to me: I'm currently looking
> > > for something to hack...
> >
> > Dear Rick,
> >
> > I'm writing to you with some ideas for Linux memory management.
> > There are two things which I think would be really nice.
> >
> > 1. Imagine you're running a Linux binary off a umsdos or nfs or
> > 2. I know free RAM is bad, but....
>
> 3. It might be nice to do something like swap priorities. When I know
> that task xyz is memory hog that traverses memory in linear way, you
> may want system not to give it too much memory. Might be nice. (I have
> it partly implemented - now I can set swap priority. But the way I did
> it it gave 0% performance gain, so...)
>
> What might be even nicer would be for system to look for memory access
> paterns. Could do a _lot_ of difference, but also is really hard.
>

4. Implement madvise(). From the NetBSD 1.2 man-page:

(found on Solaris, HP-UX, NetBSD, AIX, IRIX(although only
supporting MADV_DONTNEED))

MADVISE(2) NetBSD Programmer's Manual
MADVISE(2)

NAME
madvise - give advice about use of memory

SYNOPSIS
#include <sys/types.h>
#include <sys/mman.h>

int
madvise(caddr_t addr, size_t len, int behav)

DESCRIPTION
The madvise() system call allows a process that has knowledge of its
mem-
ory behavior to describe it to the system. The known behaviors are
given
in <sys/mman.h>:

#define MADV_NORMAL 0 /* no further special treatment */
#define MADV_RANDOM 1 /* expect random page references */
#define MADV_SEQUENTIAL 2 /* expect sequential references */
#define MADV_WILLNEED 3 /* will need these pages */
#define MADV_DONTNEED 4 /* don't need these pages */
#define MADV_SPACEAVAIL 5 /* insure that resources are reserved
*/

SEE ALSO
mincore(2), mprotect(2), msync(2), munmap(2)

HISTORY
The madvise function first appeared in 4.4BSD.

BSD Experimental September 16, 1996
1

astor

--
 Alexander Kjeldaas, Guardian Networks AS, Trondheim, Norway
 http://www.guardian.no/