freebsd-skq/sys/dev/netmap
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
..
if_ptnet.c netmap: align if_ptnet to the changes introduced by r347233 2019-05-17 20:29:31 +00:00
if_re_netmap.h netmap: align codebase to the current upstream (commit id 3fb001303718146) 2018-04-12 07:20:50 +00:00
if_vtnet_netmap.h netmap: remove redundant call to nm_set_native_flags() 2019-02-25 09:57:06 +00:00
netmap_bdg.c netmap: refactor logging macros and pipes 2019-02-05 12:10:48 +00:00
netmap_bdg.h netmap: align codebase to the current upstream (760279cfb2730a585) 2018-12-05 11:57:16 +00:00
netmap_freebsd.c Change synchonization rules for vm_page reference counting. 2019-09-09 21:32:42 +00:00
netmap_generic.c netmap: fix bug introduced by r349752 2019-07-13 08:08:25 +00:00
netmap_kern.h netmap: import changes from upstream (SHA 137f537eae513) 2019-09-01 14:47:41 +00:00
netmap_kloop.c netmap: import changes from upstream (SHA 137f537eae513) 2019-09-01 14:47:41 +00:00
netmap_legacy.c netmap: add support for multiple host rings 2019-03-18 12:22:23 +00:00
netmap_mbq.c
netmap_mbq.h
netmap_mem2.c netmap: import changes from upstream (SHA 137f537eae513) 2019-09-01 14:47:41 +00:00
netmap_mem2.h netmap: align codebase to the current upstream (760279cfb2730a585) 2018-12-05 11:57:16 +00:00
netmap_monitor.c netmap: refactor logging macros and pipes 2019-02-05 12:10:48 +00:00
netmap_null.c netmap: refactor logging macros and pipes 2019-02-05 12:10:48 +00:00
netmap_offloadings.c netmap: refactor logging macros and pipes 2019-02-05 12:10:48 +00:00
netmap_pipe.c netmap: refactor logging macros and pipes 2019-02-05 12:10:48 +00:00
netmap_vale.c netmap: refactor logging macros and pipes 2019-02-05 12:10:48 +00:00
netmap.c netmap: import changes from upstream (SHA 137f537eae513) 2019-09-01 14:47:41 +00:00