freebsd-dev/contrib/netbsd-tests/lib
Mark Johnston 54a3a11421 Provide separate accounting for user-wired pages.
Historically we have not distinguished between kernel wirings and user
wirings for accounting purposes.  User wirings (via mlock(2)) were
subject to a global limit on the number of wired pages, so if large
swaths of physical memory were wired by the kernel, as happens with
the ZFS ARC among other things, the limit could be exceeded, causing
user wirings to fail.

The change adds a new counter, v_user_wire_count, which counts the
number of virtual pages wired by user processes via mlock(2) and
mlockall(2).  Only user-wired pages are subject to the system-wide
limit which helps provide some safety against deadlocks.  In
particular, while sources of kernel wirings typically support some
backpressure mechanism, there is no way to reclaim user-wired pages
shorting of killing the wiring process.  The limit is exported as
vm.max_user_wired, renamed from vm.max_wired, and changed from u_int
to u_long.

The choice to count virtual user-wired pages rather than physical
pages was done for simplicity.  There are mechanisms that can cause
user-wired mappings to be destroyed while maintaining a wiring of
the backing physical page; these make it difficult to accurately
track user wirings at the physical page layer.

The change also closes some holes which allowed user wirings to succeed
even when they would cause the system limit to be exceeded.  For
instance, mmap() may now fail with ENOMEM in a process that has called
mlockall(MCL_FUTURE) if the new mapping would cause the user wiring
limit to be exceeded.

Note that bhyve -S is subject to the user wiring limit, which defaults
to 1/3 of physical RAM.  Users that wish to exceed the limit must tune
vm.max_user_wired.

Reviewed by:	kib, ngie (mlock() test changes)
Tested by:	pho (earlier version)
MFC after:	45 days
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D19908
2019-05-13 16:38:48 +00:00
..
csu
libbluetooth
libbpfjit Checkpoint initial integration work 2016-08-12 08:50:05 +00:00
libc Provide separate accounting for user-wired pages. 2019-05-13 16:38:48 +00:00
libcrypt Hack test so that it works on FreeBSD. 2015-12-01 21:22:29 +00:00
libcurses Checkpoint initial integration work 2016-08-12 08:50:05 +00:00
libdes
libevent
libexecinfo Import proper fix for misc/49356 (/usr/include/atf-c/config.h) after atf-c/config.h 2014-11-04 05:02:22 +00:00
libm Amend r343442, by only expecting the lib.msun.cbrt_test.cbrtl_powl and 2019-02-08 18:31:54 +00:00
libobjc
libposix Merge content currently under test from ^/vendor/NetBSD/tests/dist/@r312123 2017-01-14 06:49:17 +00:00
libppath
libprop
libpthread Have pthread_cond_destroy() return EBUSY if the condvar has waiters. 2019-03-08 21:07:08 +00:00
libpthread_dbg Merge content currently under test from ^/vendor/NetBSD/tests/dist/@r312123 2017-01-14 06:49:17 +00:00
librefuse Merge content currently under test from ^/vendor/NetBSD/tests/dist/@r312123 2017-01-14 06:49:17 +00:00
librt Add sem_clockwait_np() 2017-02-23 19:36:38 +00:00
librumpclient Merge content currently under test from ^/vendor/NetBSD/tests/dist/@r312123 2017-01-14 06:49:17 +00:00
librumphijack Upgrade NetBSD tests to 01.11.2017_23.20 snapshot 2017-01-13 03:33:57 +00:00
libskey
libsljit
libusbhid Upgrade NetBSD tests to 01.11.2017_23.20 snapshot 2017-01-13 03:33:57 +00:00
libutil Checkpoint initial integration work 2016-08-12 08:50:05 +00:00
semaphore Merge content currently under test from ^/vendor/NetBSD/tests/dist/@r312123 2017-01-14 06:49:17 +00:00