PC-BSD/trueos ccbfa83share/man/man9 vm_page_wire.9 Makefile, sys/amd64/amd64 pmap.c efirt_machdep.c

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
DeltaFile
+347-231sys/vm/vm_page.c
+112-29sys/vm/vm_pageout.c
+69-24sys/vm/vm_page.h
+18-60sys/vm/vm_fault.c
+26-43sys/vm/vm_object.c
+34-18share/man/man9/vm_page_wire.9
+9-17sys/amd64/amd64/pmap.c
+7-18sys/i386/i386/pmap.c
+12-10sys/vm/vm_swapout.c
+8-12sys/arm/arm/pmap-v4.c
+5-10sys/arm/arm/pmap-v6.c
+4-10sys/sparc64/sparc64/pmap.c
+4-10sys/powerpc/booke/pmap.c
+5-9sys/mips/mips/pmap.c
+2-10sys/kern/kern_exec.c
+4-8sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
+2-8sys/powerpc/aim/mmu_oea64.c
+2-8sys/kern/kern_sendfile.c
+2-8sys/arm64/arm64/pmap.c
+2-7sys/powerpc/aim/mmu_oea.c
+2-7sys/riscv/riscv/pmap.c
+1-6sys/compat/linuxkpi/common/include/linux/mm.h
+0-7sys/kern/uipc_shm.c
+2-4sys/dev/xen/gntdev/gntdev.c
+0-6sys/vm/vm_glue.c
+2-4sys/dev/xen/privcmd/privcmd.c
+1-5sys/dev/agp/agp.c
+1-4sys/net/bpf_zerocopy.c
+1-4sys/kern/sys_process.c
+0-5sys/dev/cxgbe/tom/t4_cpl_io.c
+1-4sys/contrib/vchiq/interface/vchiq_arm/vchiq_2835_arm.c
+0-4sys/dev/drm2/ttm/ttm_bo_vm.c
+0-4sys/vm/device_pager.c
+3-1share/man/man9/Makefile
+0-4sys/kern/uipc_mbuf.c
+0-4sys/compat/linuxkpi/common/src/linux_page.c
+0-3sys/kern/kern_kcov.c
+1-2sys/fs/tmpfs/tmpfs_subr.c
+0-2sys/dev/drm2/ttm/ttm_tt.c
+0-2sys/dev/netmap/netmap_freebsd.c
+1-1sys/dev/drm2/ttm/ttm_page_alloc.c
+0-2sys/dev/cxgbe/tom/t4_ddp.c
+1-1sys/amd64/amd64/efirt_machdep.c
+0-2sys/dev/agp/agp_i810.c
+0-2sys/compat/linuxkpi/common/src/linux_compat.c
+1-1sys/sys/param.h
+1-1sys/arm64/arm64/efirt_machdep.c
+0-2sys/arm/nvidia/drm2/tegra_bo.c
+0-2sys/amd64/vmm/vmm.c
+0-2sys/amd64/sgx/sgx.c
+0-2sys/dev/md/md.c
+693-65051 files

UnifiedSplitRaw