freebsd-dev/sys/vm
Alan Cox 5268042bbd Revamp the default page clustering strategy that is used by the page fault
handler.  For roughly twenty years, the page fault handler has used the
same basic strategy: Fetch a fixed number of non-resident pages both ahead
and behind the virtual page that was faulted on.  Over the years,
alternative strategies have been implemented for optimizing the handling
of random and sequential access patterns, but the only change to the
default strategy has been to increase the number of pages read ahead to 7
and behind to 8.

The problem with the default page clustering strategy becomes apparent
when you look at how it behaves on the code section of an executable or
shared library.  (To simplify the following explanation, I'm going to
ignore the read that is performed to obtain the header and assume that no
pages are resident at the start of execution.)  Suppose that we have a
code section consisting of 32 pages.  Further, suppose that we access
pages 4, 28, and 16 in that order.  Under the default page clustering
strategy, we page fault three times and perform three I/O operations,
because the first and second page faults only read a truncated cluster of
12 pages.  In contrast, if we access pages 8, 24, and 16 in that order, we
only fault twice and perform two I/O operations, because the first and
second page faults read a full cluster of 16 pages.  In general, truncated
clusters are more common than full clusters.

To address this problem, this revision changes the default page clustering
strategy to align the start of the cluster to a page offset within the vm
object that is a multiple of the cluster size.  This results in many fewer
truncated clusters.  Returning to our example, if we now access pages 4,
28, and 16 in that order, the cluster that is read to satisfy the page
fault on page 28 will now include page 16.  So, the access to page 16 will
no longer page fault and perform an I/O operation.

Since the revised default page clustering strategy is typically reading
more pages at a time, we are likely to read a few more pages that are
never accessed.  However, for the various programs that we looked at,
including clang, emacs, firefox, and openjdk, the reduction in the number
of page faults and I/O operations far outweighed the increase in the
number of pages that are never accessed.  Moreover, the extra resident
pages allowed for many more superpage mappings.  For example, if we look
at the execution of clang during a buildworld, the number of (hard) page
faults on the code section drops by 26%, the number of superpage mappings
increases by about 29,000, but the number of never accessed pages only
increases from 30.38% to 33.66%.  Finally, this leads to a small but
measureable reduction in execution time.

In collaboration with:	Emily Pettigrew <ejp1@rice.edu>
Differential Revision:	https://reviews.freebsd.org/D1500
Reviewed by:	jhb, kib
MFC after:	6 weeks
2015-01-16 18:17:09 +00:00
..
_vm_radix.h On all the architectures, avoid to preallocate the physical memory 2013-08-09 11:28:55 +00:00
default_pager.c Fix mis-spelling of bits and types names in the 2014-11-04 19:56:04 +00:00
device_pager.c Initialize paddr to handle the case of zero size. 2014-03-12 16:38:55 +00:00
memguard.c Fix multiple incorrect SYSCTL arguments in the kernel: 2014-10-21 07:31:21 +00:00
memguard.h Replace kernel virtual address space allocation with vmem. This provides 2013-08-07 06:21:20 +00:00
phys_pager.c The soft and hard busy mechanism rely on the vm object lock to work. 2013-08-09 11:11:11 +00:00
pmap.h Change pmap_enter(9) interface to take flags parameter and superpage 2014-08-08 17:12:03 +00:00
redzone.c Pull in r267961 and r267973 again. Fix for issues reported will follow. 2014-06-28 03:56:17 +00:00
redzone.h
sg_pager.c Different consumers of the struct vm_page abuse pageq member to keep 2013-08-10 17:36:42 +00:00
swap_pager.c \n at end of panicstr is redundant. 2014-11-23 18:32:21 +00:00
swap_pager.h
uma_core.c Eliminate a stale debug message. The per-CPU cache locks were replaced 2014-12-31 17:44:57 +00:00
uma_dbg.c - Add a per-zone lock for zones without kegs. 2013-06-20 19:08:12 +00:00
uma_dbg.h
uma_int.h Implement soft pressure on UMA cache bucket sizes. 2013-11-19 10:05:53 +00:00
uma.h Create two public UMA_ZONE_PCPU zones: 64 bit sized and pointer sized. 2014-02-10 19:59:46 +00:00
vm_extern.h Handle wiring failures in vm_map_wire() with the new functions 2014-08-02 16:10:24 +00:00
vm_fault.c Revamp the default page clustering strategy that is used by the page fault 2015-01-16 18:17:09 +00:00
vm_glue.c Add kernel option KSTACK_USAGE_PROF to sample the stack depth on 2014-10-04 18:38:14 +00:00
vm_init.c Pull in r267961 and r267973 again. Fix for issues reported will follow. 2014-06-28 03:56:17 +00:00
vm_kern.c Fix multiple incorrect SYSCTL arguments in the kernel: 2014-10-21 07:31:21 +00:00
vm_kern.h - Add a statically allocated memguard arena since it is needed very early 2013-08-13 22:40:43 +00:00
vm_map.c vm_map_pmap_enter() and pmap_enter_object() are currently not aware of 2014-09-23 18:54:23 +00:00
vm_map.h Oops. vm_map_simplify_entry() is used by mac_proc_vm_revoke_recurse(), so 2014-09-08 02:25:01 +00:00
vm_meter.c Rename global cnt to vm_cnt to avoid shadowing. 2014-03-22 10:26:09 +00:00
vm_mmap.c Always ignore the deprecated MAP_RENAME and MAP_NORESERVE flags to mmap(). 2014-12-05 15:24:42 +00:00
vm_object.c When the last reference on the vnode' vm object is dropped, read the 2014-12-05 15:02:30 +00:00
vm_object.h Update a stale comment. 2014-09-11 03:16:57 +00:00
vm_page.c Add flag VM_ALLOC_NOWAIT for vm_page_grab() that prevents sleeping and 2014-12-22 09:02:21 +00:00
vm_page.h Add flag VM_ALLOC_NOWAIT for vm_page_grab() that prevents sleeping and 2014-12-22 09:02:21 +00:00
vm_pageout.c Refactor ZFS ARC reclaim checks and limits 2014-10-03 20:34:55 +00:00
vm_pageout.h
vm_pager.c Avoid an exclusive acquisition of the object lock on the expected execution 2014-09-14 18:07:55 +00:00
vm_pager.h Merge from projects/sendfile: 2014-11-23 12:01:52 +00:00
vm_param.h Rename global cnt to vm_cnt to avoid shadowing. 2014-03-22 10:26:09 +00:00
vm_phys.c The physical memory allocator supports the use of distinct free lists for 2014-12-31 00:54:38 +00:00
vm_phys.h The physical memory allocator supports the use of distinct free lists for 2014-12-31 00:54:38 +00:00
vm_radix.c Pull in r267961 and r267973 again. Fix for issues reported will follow. 2014-06-28 03:56:17 +00:00
vm_radix.h Eliminate a redundant parameter to vm_radix_replace(). 2013-12-08 20:07:02 +00:00
vm_reserv.c By the time that vm_reserv_init() runs, vm_phys_segs[] is initialized. Use 2014-11-22 17:46:30 +00:00
vm_reserv.h Refactor vm_page_alloc()'s interactions with vm_reserv_alloc_page() and 2013-05-12 16:50:18 +00:00
vm_unix.c Remove ia64. 2014-07-07 00:27:09 +00:00
vm_zeroidle.c Pull in r267961 and r267973 again. Fix for issues reported will follow. 2014-06-28 03:56:17 +00:00
vm.h rename scheduler->swapper and SI_SUB_RUN_SCHEDULER->SI_SUB_LAST 2013-07-24 09:45:31 +00:00
vnode_pager.c We already have "int i" in this scope. 2014-11-24 07:57:20 +00:00
vnode_pager.h Merge from projects/sendfile: 2014-11-23 12:01:52 +00:00