freebsd-dev/lib/libc
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
..
aarch64 Fix initial exec TLS mode for dynamically loaded shared objects. 2019-03-29 17:52:57 +00:00
amd64 Fix initial exec TLS mode for dynamically loaded shared objects. 2019-03-29 17:52:57 +00:00
arm Fix initial exec TLS mode for dynamically loaded shared objects. 2019-03-29 17:52:57 +00:00
capability Replace dot-dot relative pathing with SRCTOP-relative paths where possible 2017-01-20 03:23:24 +00:00
compat-43 General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
db Remove "All rights reserved" from my files. 2018-05-10 06:41:08 +00:00
gdtoa libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
gen directory.3: add a STANDARDS section 2019-05-02 19:59:37 +00:00
gmon mcount: tidy up ANSIfication 2018-10-20 22:39:35 +00:00
i386 Fix initial exec TLS mode for dynamically loaded shared objects. 2019-03-29 17:52:57 +00:00
iconv libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
include Fix initial exec TLS mode for dynamically loaded shared objects. 2019-03-29 17:52:57 +00:00
inet libc: fix cases of undefined behavior. 2018-08-07 15:24:19 +00:00
isc SPDX: more ISC-related files. 2017-12-08 17:52:53 +00:00
locale Fix WITHOUT_ICONV build after r340276. 2018-11-14 09:06:15 +00:00
md Replace dot-dot relative pathing with SRCTOP-relative paths where possible 2017-01-20 03:23:24 +00:00
mips Fix initial exec TLS mode for dynamically loaded shared objects. 2019-03-29 17:52:57 +00:00
nameser SPDX: license IDs for some ISC-related files. 2017-12-08 15:57:29 +00:00
net Use IN_foo() macros from sys/netinet/in.h inplace of handcrafted code 2019-04-04 19:01:13 +00:00
nls Create new EINTEGRITY error with message "Integrity check failed". 2019-01-17 06:35:45 +00:00
posix1e Remove some redundant code in _posix1e_acl_strip_np 2019-02-19 19:15:15 +00:00
powerpc Fix initial exec TLS mode for dynamically loaded shared objects. 2019-03-29 17:52:57 +00:00
powerpc64 revert r346588 for now 2019-05-11 15:17:42 +00:00
powerpcspe Fix fabs(3) for powerpcspe, this time for real 2018-07-26 14:42:20 +00:00
quad ANSIfy libc/quad 2018-10-21 00:20:40 +00:00
regex regcomp: revert part of r341838 which turned out to be unrelated 2018-12-19 23:28:56 +00:00
resolv Allow the use of TCP instead of UDP for queries by setting options usevc 2018-08-16 13:18:40 +00:00
riscv Fix initial exec TLS mode for dynamically loaded shared objects. 2019-03-29 17:52:57 +00:00
rpc Fix CONFS to append the value in this case. 2018-09-18 01:38:44 +00:00
secure Carefully update stack guard bytes inside __guard_setup(). 2018-04-24 15:59:39 +00:00
softfloat Add implementations for clog(3), clogf(3), and clog(3). 2018-05-13 09:54:34 +00:00
sparc64 Fix initial exec TLS mode for dynamically loaded shared objects. 2019-03-29 17:52:57 +00:00
stdio GC a historical artifact. 2019-02-07 23:17:44 +00:00
stdlib random.3: Remove obsolete BUGS section 2019-04-22 16:29:34 +00:00
stdtime strptime: make %k and %l specifiers match their description in 2018-11-03 23:37:13 +00:00
string libc: update strstr implementation to match musl 2019-04-09 15:52:18 +00:00
sys Provide separate accounting for user-wired pages. 2019-05-13 16:38:48 +00:00
tests Provide separate accounting for user-wired pages. 2019-05-13 16:38:48 +00:00
uuid libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
x86 pkru(3) man page. 2019-02-20 10:03:03 +00:00
xdr General further adoption of SPDX licensing ID tags. 2017-11-20 19:49:47 +00:00
yp libc: further adoption of SPDX licensing ID tags. 2017-11-25 17:12:48 +00:00
libc_nossp.ldscript Add different libc ldscript: the one without libssp -- 2016-10-12 13:19:21 +00:00
libc.ldscript
Makefile revert r341429 "disable BIND_NOW in libc, libthr, and rtld" 2019-03-28 02:12:32 +00:00
Makefile.depend
Versions.def Create namespace for the symbols added during 13-CURRENT cycle. 2018-11-12 19:12:14 +00:00