Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Oct 2012 17:13:41 +0000
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        Marcel Moolenaar <marcel@xcllnt.net>
Cc:        Tim LaBerge <tlaberge@juniper.net>, Alan Cox <alc@rice.edu>, "freebsd-arch@freebsd.org Arch" <freebsd-arch@freebsd.org>
Subject:   Re: Behavior of madvise(MADV_FREE)
Message-ID:  <4835.1350062021@critter.freebsd.dk>
In-Reply-To: <9FEBC10C-C453-41BE-8829-34E830585E90@xcllnt.net>
References:  <9FEBC10C-C453-41BE-8829-34E830585E90@xcllnt.net>

next in thread | previous in thread | raw e-mail | index | archive | help
--------
In message <9FEBC10C-C453-41BE-8829-34E830585E90@xcllnt.net>, Marcel Moolenaar writes:

>Now on to the questions:
>1.  madvise(MADV_FREE) marks the pages as clean and moves
>    them to the inactive queue. 

You can blame me for MADV_FREE, I nagged dyson into adding it for
phkmalloc back when 16meg RAM cost a fortune.

The main point of MADV_FREE when was to prevent a page-out of a
dirty page, when the actual bits in the page were discarded from
the applications point of view.

The idea was for it to be a very fast operation, which would
(potentially) save two disk operations, and the implementation
simply washed the dirty bits away.

(I think a later modification added further VM-wizardry to retain
the allocated paging area, while avoiding the page-in in the case
the pages were stolen.)

The mapping were left alone, because it was estimated and measured
that there were a high frequency of mapping reuse, in particular
in the WorldStone where multiple passes of GCC competed for physical
memory.  The reference bit were left alone to not disturb the
perceived/ measured VM-footprint of the process.

I seem to recall that we experimented with a more aggressive
version which severed the mapping and sent the page to pre-zeroing
but the benchmarks showed too much overhead in the common case
and too little gain in the relevant scenario.

The name was clearly a mistake, but MADV_CLEAN would have been
worse, and none of us had any other ideas at the time.  Today I
would have called it MADV_GARBAGE or MADV_RECYCLE.

Given that paging anonymous pages to disk is not a major activity
and unlikely to ever become a performance bottleneck again, it may
make good sense to let MADV_FREE make the pages more appetizing
for the rest of the system.

But all things considered, I would advocate implementing MADV_RECYCLE
for that, we need more nuance and expressability in madvice(2) and
MADV_RECYCLE would be a good addition in its own right.

Poul-Henning


-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4835.1350062021>