freebsd-dev/sys/vm
Mark Johnston fee2a2fa39 Change synchonization rules for vm_page reference counting.
There are several mechanisms by which a vm_page reference is held,
preventing the page from being freed back to the page allocator.  In
particular, holding the page's object lock is sufficient to prevent the
page from being freed; holding the busy lock or a wiring is sufficent as
well.  These references are protected by the page lock, which must
therefore be acquired for many per-page operations.  This results in
false sharing since the page locks are external to the vm_page
structures themselves and each lock protects multiple structures.

Transition to using an atomically updated per-page reference counter.
The object's reference is counted using a flag bit in the counter.  A
second flag bit is used to atomically block new references via
pmap_extract_and_hold() while removing managed mappings of a page.
Thus, the reference count of a page is guaranteed not to increase if the
page is unbusied, unmapped, and the object's write lock is held.  As
a consequence of this, the page lock no longer protects a page's
identity; operations which move pages between objects are now
synchronized solely by the objects' locks.

The vm_page_wire() and vm_page_unwire() KPIs are changed.  The former
requires that either the object lock or the busy lock is held.  The
latter no longer has a return value and may free the page if it releases
the last reference to that page.  vm_page_unwire_noq() behaves the same
as before; the caller is responsible for checking its return value and
freeing or enqueuing the page as appropriate.  vm_page_wire_mapped() is
introduced for use in pmap_extract_and_hold().  It fails if the page is
concurrently being unmapped, typically triggering a fallback to the
fault handler.  vm_page_wire() no longer requires the page lock and
vm_page_unwire() now internally acquires the page lock when releasing
the last wiring of a page (since the page lock still protects a page's
queue state).  In particular, synchronization details are no longer
leaked into the caller.

The change excises the page lock from several frequently executed code
paths.  In particular, vm_object_terminate() no longer bounces between
page locks as it releases an object's pages, and direct I/O and
sendfile(SF_NOCACHE) completions no longer require the page lock.  In
these latter cases we now get linear scalability in the common scenario
where different threads are operating on different files.

__FreeBSD_version is bumped.  The DRM ports have been updated to
accomodate the KPI changes.

Reviewed by:	jeff (earlier version)
Tested by:	gallatin (earlier version), pho
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D20486
2019-09-09 21:32:42 +00:00
..
_vm_radix.h sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
default_pager.c SPDX: wrong license. 2017-11-30 15:45:42 +00:00
device_pager.c Change synchonization rules for vm_page reference counting. 2019-09-09 21:32:42 +00:00
memguard.c Add a vm_page_wired() predicate. 2019-06-02 01:00:17 +00:00
memguard.h sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
phys_pager.c sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
pmap.h correct pmap_ts_referenced return type 2019-07-03 19:59:56 +00:00
redzone.c sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
redzone.h sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
sg_pager.c Change the vm_ooffset_t type to unsigned. 2018-12-02 13:16:46 +00:00
swap_pager.c vm pager: writemapping accounting for OBJT_SWAP 2019-09-03 20:31:48 +00:00
swap_pager.h sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
uma_core.c Extend uma_reclaim() to permit different reclamation targets. 2019-09-01 22:22:43 +00:00
uma_dbg.c Fix compilation failures on different arches that have vm_machdep.c not 2019-01-15 19:33:47 +00:00
uma_dbg.h sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
uma_int.h Extend uma_reclaim() to permit different reclamation targets. 2019-09-01 22:22:43 +00:00
uma.h Extend uma_reclaim() to permit different reclamation targets. 2019-09-01 22:22:43 +00:00
vm_domainset.c Add a !NUMA definition for vm_domainset_iter_policy_ref_init(). 2018-10-24 17:09:20 +00:00
vm_domainset.h Refactor domainset iterators for use by malloc(9) and UMA. 2018-10-23 16:35:58 +00:00
vm_extern.h Add malloc_domainset(9) and _domainset variants to other allocator KPIs. 2018-10-30 18:26:34 +00:00
vm_fault.c Change synchonization rules for vm_page reference counting. 2019-09-09 21:32:42 +00:00
vm_glue.c Change synchonization rules for vm_page reference counting. 2019-09-09 21:32:42 +00:00
vm_init.c Do not reserve KVA for paging bufs in vm_ksubmap_init(), since now 2019-01-16 20:14:16 +00:00
vm_kern.c Map the vm_page array into KVA on amd64. 2019-09-03 13:18:51 +00:00
vm_kern.h Do not reserve KVA for paging bufs in vm_ksubmap_init(), since now 2019-01-16 20:14:16 +00:00
vm_map.c madvise(MADV_FREE): Quick fix to time rewind. 2019-09-04 20:28:16 +00:00
vm_map.h vm pager: writemapping accounting for OBJT_SWAP 2019-09-03 20:31:48 +00:00
vm_meter.c Provide separate accounting for user-wired pages. 2019-05-13 16:38:48 +00:00
vm_mmap.c vm pager: writemapping accounting for OBJT_SWAP 2019-09-03 20:31:48 +00:00
vm_object.c Change synchonization rules for vm_page reference counting. 2019-09-09 21:32:42 +00:00
vm_object.h vm pager: writemapping accounting for OBJT_SWAP 2019-09-03 20:31:48 +00:00
vm_page.c Change synchonization rules for vm_page reference counting. 2019-09-09 21:32:42 +00:00
vm_page.h Change synchonization rules for vm_page reference counting. 2019-09-09 21:32:42 +00:00
vm_pageout.c Change synchonization rules for vm_page reference counting. 2019-09-09 21:32:42 +00:00
vm_pageout.h Fix OOM handling of some corner cases. 2019-08-16 09:43:49 +00:00
vm_pagequeue.h Simplify vm_page_dequeue() and fix an assertion. 2019-08-21 16:11:12 +00:00
vm_pager.c Do not reserve KVA for paging bufs in vm_ksubmap_init(), since now 2019-01-16 20:14:16 +00:00
vm_pager.h vm pager: writemapping accounting for OBJT_SWAP 2019-09-03 20:31:48 +00:00
vm_param.h Move phys_avail definition into MI code. It is consumed in the MI layer and 2019-08-16 00:45:14 +00:00
vm_phys.c Remove unnecessary debugging from r351181 that caused powerpc build to fail. 2019-08-18 08:07:31 +00:00
vm_phys.h Encapsulate phys_avail manipulation in a set of simple routines. Add a 2019-08-18 07:06:31 +00:00
vm_radix.c vm: stop passing M_ZERO when allocating radix nodes 2018-06-24 13:08:05 +00:00
vm_radix.h sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
vm_reserv.c Allocate amd64's page array using pages and page directory pages from the 2019-08-18 23:07:56 +00:00
vm_reserv.h Allocate amd64's page array using pages and page directory pages from the 2019-08-18 23:07:56 +00:00
vm_swapout_dummy.c SPDX: Consider code from Carnegie-Mellon University. 2017-11-30 15:48:35 +00:00
vm_swapout.c Change synchonization rules for vm_page reference counting. 2019-09-09 21:32:42 +00:00
vm_unix.c Provide separate accounting for user-wired pages. 2019-05-13 16:38:48 +00:00
vm.h Move vm_ndomains to vm.h where it can be used with a single header include 2018-03-27 03:27:02 +00:00
vnode_pager.c vm pager: writemapping accounting for OBJT_SWAP 2019-09-03 20:31:48 +00:00
vnode_pager.h vm pager: writemapping accounting for OBJT_SWAP 2019-09-03 20:31:48 +00:00