freebsd-src/sys
Alan Cox 8bcd3b1998 Essentially, neither madvise(..., MADV_DONTNEED) nor madvise(..., MADV_FREE)
work.  (Moreover, I don't believe that they have ever worked as intended.)
The explanation is fairly simple.  Both MADV_DONTNEED and MADV_FREE perform
vm_page_dontneed() on each page within the range given to madvise().  This
function moves the page to the inactive queue.  Specifically, if the page is
clean, it is moved to the head of the inactive queue where it is first in
line for processing by the page daemon.  On the other hand, if it is dirty,
it is placed at the tail.  Let's further examine the case in which the page
is clean.  Recall that the page is at the head of the line for processing by
the page daemon.  The expectation of vm_page_dontneed()'s author was that
the page would be transferred from the inactive queue to the cache queue by
the page daemon.  (Once the page is in the cache queue, it is, in effect,
free, that is, it can be reallocated to a new vm object by vm_page_alloc()
if it isn't reactivated quickly enough by a user of the old vm object.)  The
trouble is that nowhere in the execution of either MADV_DONTNEED or
MADV_FREE is either the machine-independent reference flag (PG_REFERENCED)
or the reference bit in any page table entry (PTE) mapping the page cleared.
Consequently, the immediate reaction of the page daemon is to reactivate the
page because it is referenced.  In effect, the madvise() was for naught.
The case in which the page was dirty is not too different.  Instead of being
laundered, the page is reactivated.

Note: The essential difference between MADV_DONTNEED and MADV_FREE is
that MADV_FREE clears a page's dirty field.  So, MADV_FREE is always
executing the clean case above.

This revision changes vm_page_dontneed() to clear both the machine-
independent reference flag (PG_REFERENCED) and the reference bit in all PTEs
mapping the page.

MFC after:	6 weeks
2008-06-06 18:38:43 +00:00
..
amd64 Correct an error in pmap_promote_pde() that may result in an errant 2008-06-01 07:36:59 +00:00
arm Support for the XScale PXA255 SoC as found on the Gumstix Basix and Connex 2008-06-06 05:08:09 +00:00
boot Add an entry for the jme(4) module. 2008-05-27 02:13:25 +00:00
bsm
cam Locking in the ses_ioctl handler doesn't have to be so strict because 2008-03-17 17:18:16 +00:00
cddl Merge a recent change from the OpenSolaris source tree. 2008-06-01 01:46:37 +00:00
compat Switch to emulating Linux 2.6 on default. 2008-06-03 17:50:13 +00:00
conf Support for the XScale PXA255 SoC as found on the Gumstix Basix and Connex 2008-06-06 05:08:09 +00:00
contrib Fix range check for rtable id. 2008-06-05 19:30:20 +00:00
crypto
ddb Rename debug.ddb.capture.bytes sysctl to debug.ddb.capture.bufoff in 2008-04-25 13:23:36 +00:00
dev - Use bus_foo() rather than bus_space_foo() and remove bus space tag/handle 2008-06-06 18:29:56 +00:00
fs When devfs_allocv() committed to create new vnode, since de_vnode is NULL, 2008-06-05 09:15:47 +00:00
gdb Commit SYSINIT() ;-adding patch missed in previous pass. 2008-03-16 13:02:04 +00:00
geom Remove the distinction between device minor and unit numbers. 2008-05-29 12:50:46 +00:00
gnu Move the head of byte-level advisory lock list from the 2008-04-16 11:33:32 +00:00
i386 After probing the available frequency settings, restore the CPU to run at 2008-05-30 22:01:09 +00:00
ia64 Work-around a compiler optimization bug, that broke libthr. Massive 2008-05-28 16:41:02 +00:00
isa atrtc.c is a repocopy of the RTC device driver from i386/isa/clock.c 2008-04-14 07:57:15 +00:00
kern Remove unneeded Giant locking of /dev/tty. 2008-06-03 12:38:00 +00:00
libkern
mips Retire pmap_addr_hint(). It is no longer used. 2008-05-18 04:16:57 +00:00
modules Add the DTrace test kernel module so that people can run the tests. 2008-05-31 09:37:40 +00:00
net When RADIX_MPATH is enabled, the route selection is not rotating 2008-05-30 09:34:35 +00:00
net80211 Add ieee80211_crypto_reload_keys to push all keys known 2008-05-28 23:33:29 +00:00
netatalk Add code to allow the system to handle multiple routing tables. 2008-05-09 23:03:00 +00:00
netgraph Pass really available buffer size to libalias instead of MCLBYTES constant. 2008-06-01 15:13:32 +00:00
netinet Sort IP addresses before hashing them for the signature. Otherwise carp is 2008-06-02 18:58:07 +00:00
netinet6 Employ read locks on UDP inpcbs, rather than write locks, when 2008-05-29 08:27:14 +00:00
netipsec In addition to the ipsec_osdep.h removal a week ago, now also eliminate 2008-05-24 15:32:46 +00:00
netipx Rather than m_free(dtom(si)) in spx_reass(), return (1) which causes the 2008-05-29 07:18:43 +00:00
netnatm
netncp lockmgrs need to be released before to be destroyed and draining doesn't 2008-03-30 18:16:33 +00:00
netsmb Really, smb_iod_main() is not totally MPSAFE, so just acquire and drop 2008-03-27 01:23:59 +00:00
nfs Replaced the misleading uses of a historical artefact M_TRYWAIT with M_WAIT. 2008-03-25 09:39:02 +00:00
nfs4client Once the ENOLCK is detected we expect to retry the acquisition. 2008-05-27 00:20:19 +00:00
nfsclient Once the ENOLCK is detected we expect to retry the acquisition. 2008-05-27 00:20:19 +00:00
nfsserver Change the fix in the rev. 1.179 to use nfsrv_lockedpair_nd(). 2008-05-28 16:23:17 +00:00
nlm Back out the nlm_global_lock part of the last change - I forgot that only 2008-06-03 08:10:58 +00:00
opencrypto
pc98 Remove ISDN4BSD (I4B) from HEAD as it is not MPSAFE and 2008-05-26 10:40:09 +00:00
pccard
pci - Use bus_foo() rather than bus_space_foo() and remove bus space tag/handle 2008-06-06 18:29:56 +00:00
powerpc Add link register to fatal trap printout to better diagnose NULL 2008-06-04 07:32:49 +00:00
rpc Fix some issues that showed up during Kris' testing. 2008-04-11 10:34:59 +00:00
security Add an XXX comment regarding a bug I introduced when modifying the behavior 2008-06-03 11:06:34 +00:00
sparc64 The VM system no longer uses setPQL2(). Remove it and its helpers. 2008-05-23 04:03:54 +00:00
sun4v Use the "options " spelling (vs. "options<TAB>") so that commented lines 2008-05-21 03:36:53 +00:00
sys Fix faulty character to control-character conversion for CTRL(). 2008-06-05 17:44:18 +00:00
tools
ufs Fix comments to replace SBSIZE with SBLOCKSIZE, since SBSIZE 2008-05-24 20:44:14 +00:00
vm Essentially, neither madvise(..., MADV_DONTNEED) nor madvise(..., MADV_FREE) 2008-06-06 18:38:43 +00:00
xdr Add the new kernel-mode NFS Lock Manager. To use it instead of the 2008-03-26 15:23:12 +00:00
Makefile Remove ISDN4BSD (I4B) from HEAD as it is not MPSAFE and 2008-05-26 10:40:09 +00:00