freebsd-dev/sys/vm
Alan Cox ebcddc7217 Introduce a new page queue, PQ_LAUNDRY, for storing unreferenced, dirty
pages, specificially, dirty pages that have passed once through the inactive
queue.  A new, dedicated thread is responsible for both deciding when to
launder pages and actually laundering them.  The new policy uses the
relative sizes of the inactive and laundry queues to determine whether to
launder pages at a given point in time.  In general, this leads to more
intelligent swapping behavior, since the laundry thread will avoid pageouts
when the marginal benefit of doing so is low.  Previously, without a
dedicated queue for dirty pages, the page daemon didn't have the information
to determine whether pageout provides any benefit to the system.  Thus, the
previous policy often resulted in small but steadily increasing amounts of
swap usage when the system is under memory pressure, even when the inactive
queue consisted mostly of clean pages.  This change addresses that issue,
and also paves the way for some future virtual memory system improvements by
removing the last source of object-cached clean pages, i.e., PG_CACHE pages.

The new laundry thread sleeps while waiting for a request from the page
daemon thread(s).  A request is raised by setting the variable
vm_laundry_request and waking the laundry thread.  We request launderings
for two reasons: to try and balance the inactive and laundry queue sizes
("background laundering"), and to quickly make up for a shortage of free
pages and clean inactive pages ("shortfall laundering").  When background
laundering is requested, the laundry thread computes the number of page
daemon wakeups that have taken place since the last laundering.  If this
number is large enough relative to the ratio of the laundry and (global)
inactive queue sizes, we will launder vm_background_launder_target pages at
vm_background_launder_rate KB/s.  Otherwise, the laundry thread goes back
to sleep without doing any work.  When scanning the laundry queue during
background laundering, reactivated pages are counted towards the laundry
thread's target.

In contrast, shortfall laundering is requested when an inactive queue scan
fails to meet its target.  In this case, the laundry thread attempts to
launder enough pages to meet v_free_target within 0.5s, which is the
inactive queue scan period.

A laundry request can be latched while another is currently being
serviced.  In particular, a shortfall request will immediately preempt a
background laundering.

This change also redefines the meaning of vm_cnt.v_reactivated and removes
the functions vm_page_cache() and vm_page_try_to_cache().  The new meaning
of vm_cnt.v_reactivated now better reflects its name.  It represents the
number of inactive or laundry pages that are returned to the active queue
on account of a reference.

In collaboration with:	markj
Reviewed by:	kib
Tested by:	pho
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D8302
2016-11-09 18:48:37 +00:00
..
_vm_radix.h
default_pager.c A change to KPI of vm_pager_get_pages() and underlying VOP_GETPAGES(). 2015-12-16 21:30:45 +00:00
device_pager.c Split long line instead of unindenting it. Add KASSERT() verifying 2016-10-30 18:04:11 +00:00
memguard.c Include sys/_task.h into uma_int.h, so that taskqueue.h isn't a 2016-02-09 20:22:35 +00:00
memguard.h
phys_pager.c sys: use our roundup2/rounddown2() macros when param.h is available. 2016-04-21 19:57:40 +00:00
pmap.h Various changes to pmap_ts_referenced() 2016-09-10 16:49:25 +00:00
redzone.c
redzone.h
sg_pager.c Plug a vm_page leak introduced in r292373. 2016-02-05 19:35:53 +00:00
swap_pager.c Introduce a new page queue, PQ_LAUNDRY, for storing unreferenced, dirty 2016-11-09 18:48:37 +00:00
swap_pager.h
uma_core.c Simplify keg_drain() a bit by using LIST_FOREACH_SAFE. 2016-10-20 23:10:27 +00:00
uma_dbg.c Fix memguard(9) in kernels with INVARIANTS enabled. 2016-06-01 22:31:35 +00:00
uma_dbg.h Move uma_dbg_alloc() and uma_dbg_free() into uma_core.c, which allows 2016-02-03 22:02:36 +00:00
uma_int.h Autotune the number of pages set aside for UMA startup based on the number 2016-07-07 18:37:12 +00:00
uma.h Replace a number of conflations of mp_ncpus and mp_maxid with either 2016-07-06 14:09:49 +00:00
vm_domain.c Move vm_domain_rr_selectdomain() under #ifdef VM_NUMA_ALLOC. 2016-05-10 22:25:55 +00:00
vm_domain.h Add an initial NUMA affinity/policy configuration for threads and processes. 2015-07-11 15:21:37 +00:00
vm_extern.h Various cleanups to the main function for AIO kernel processes: 2016-01-19 21:37:51 +00:00
vm_fault.c Introduce a new page queue, PQ_LAUNDRY, for storing unreferenced, dirty 2016-11-09 18:48:37 +00:00
vm_glue.c Eliminate unneeded vm_page_xbusy() and vm_page_xunbusy() operations when 2016-08-14 22:00:45 +00:00
vm_init.c Conditionally move initial vfs bio alloc above 4G 2016-10-03 13:23:43 +00:00
vm_kern.c Introduce a new mechanism for relocating virtual pages to a new physical 2015-12-19 18:42:50 +00:00
vm_kern.h
vm_map.c Change the type of the map entry's next_read field from a vm_pindex_t to a 2016-07-07 20:58:16 +00:00
vm_map.h Change the type of the map entry's next_read field from a vm_pindex_t to a 2016-07-07 20:58:16 +00:00
vm_meter.c Introduce a new page queue, PQ_LAUNDRY, for storing unreferenced, dirty 2016-11-09 18:48:37 +00:00
vm_mmap.c When mmap(2) is used with a vnode, capture vnode attributes in the 2016-07-10 11:49:10 +00:00
vm_object.c Introduce a new page queue, PQ_LAUNDRY, for storing unreferenced, dirty 2016-11-09 18:48:37 +00:00
vm_object.h The vmtotal sysctl handler marks active vm objects to calculate 2016-06-21 17:49:33 +00:00
vm_page.c Introduce a new page queue, PQ_LAUNDRY, for storing unreferenced, dirty 2016-11-09 18:48:37 +00:00
vm_page.h Introduce a new page queue, PQ_LAUNDRY, for storing unreferenced, dirty 2016-11-09 18:48:37 +00:00
vm_pageout.c Introduce a new page queue, PQ_LAUNDRY, for storing unreferenced, dirty 2016-11-09 18:48:37 +00:00
vm_pageout.h The flag "vm_pages_needed" has long served two distinct purposes: (1) to 2016-05-27 19:15:45 +00:00
vm_pager.c Add BUF_TRACKING and FULL_BUF_TRACKING buffer debugging 2016-10-31 23:09:52 +00:00
vm_pager.h Remove vm_pager_has_page() declaration. It is not too useful since 2016-10-30 20:38:57 +00:00
vm_param.h Remove the v_cache_min and v_cache_max sysctls. They are unused and have 2015-09-11 03:00:20 +00:00
vm_phys.c Remove support for idle page zeroing. 2016-09-03 20:38:13 +00:00
vm_phys.h Remove support for idle page zeroing. 2016-09-03 20:38:13 +00:00
vm_radix.c Cleanup redundant parenthesis from existing howmany()/roundup() macro uses. 2016-04-22 16:57:42 +00:00
vm_radix.h
vm_reserv.c Introduce a new mechanism for relocating virtual pages to a new physical 2015-12-19 18:42:50 +00:00
vm_reserv.h Introduce a new mechanism for relocating virtual pages to a new physical 2015-12-19 18:42:50 +00:00
vm_unix.c Implement lockless resource limits. 2015-06-10 10:48:12 +00:00
vm.h Add new bus methods for mapping resources. 2016-05-20 17:57:47 +00:00
vnode_pager.c Fix incorrect assertion that could miss overflows. 2016-10-19 19:50:09 +00:00
vnode_pager.h A change to KPI of vm_pager_get_pages() and underlying VOP_GETPAGES(). 2015-12-16 21:30:45 +00:00