Add a tunable which changes mincore(2) algorithm to only report data
from the local mapping. Enable the setting by default. The article behind the change: https://arxiv.org/abs/1901.01161 Reviewed by: markj Discussed with: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D18764
This commit is contained in:
parent
bba9cbe374
commit
3fbc2e00d1
|
@ -28,7 +28,7 @@
|
|||
.\" @(#)mincore.2 8.1 (Berkeley) 6/9/93
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd June 1, 2018
|
||||
.Dd January 7, 2019
|
||||
.Dt MINCORE 2
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -47,7 +47,8 @@ system call determines whether each of the pages in the region beginning at
|
|||
.Fa addr
|
||||
and continuing for
|
||||
.Fa len
|
||||
bytes is resident.
|
||||
bytes is resident or mapped, depending on the value of sysctl
|
||||
.Va vm.mincore_mapped .
|
||||
.\"The beginning address,
|
||||
.\".Fa addr ,
|
||||
.\"is first rounded down to a multiple of the page size (see
|
||||
|
@ -85,6 +86,18 @@ The only way to ensure that a page is resident is to lock it into memory
|
|||
with the
|
||||
.Xr mlock 2
|
||||
system call.
|
||||
.Pp
|
||||
If the
|
||||
.Va vm.mincore_mapped
|
||||
sysctl is set to a non-zero value (default), only the current process'
|
||||
mappings of the pages in the specified virtual address range are examined.
|
||||
This does not preclude the system from returning
|
||||
.Dv MINCORE_REFERENCED_OTHER
|
||||
and
|
||||
.Dv MINCORE_MODIFIED_OTHER
|
||||
statuses.
|
||||
Otherwise, if the sysctl value is zero, all resident pages backing the
|
||||
specified address range are examined, regardless of the mapping state.
|
||||
.Sh RETURN VALUES
|
||||
.Rv -std mincore
|
||||
.Sh ERRORS
|
||||
|
|
|
@ -97,6 +97,9 @@ __FBSDID("$FreeBSD$");
|
|||
int old_mlock = 0;
|
||||
SYSCTL_INT(_vm, OID_AUTO, old_mlock, CTLFLAG_RWTUN, &old_mlock, 0,
|
||||
"Do not apply RLIMIT_MEMLOCK on mlockall");
|
||||
static int mincore_mapped = 1;
|
||||
SYSCTL_INT(_vm, OID_AUTO, mincore_mapped, CTLFLAG_RWTUN, &mincore_mapped, 0,
|
||||
"mincore reports mappings, not residency");
|
||||
|
||||
#ifdef MAP_32BIT
|
||||
#define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31)
|
||||
|
@ -808,7 +811,16 @@ RestartScan:
|
|||
retry:
|
||||
m = NULL;
|
||||
mincoreinfo = pmap_mincore(pmap, addr, &locked_pa);
|
||||
if (locked_pa != 0) {
|
||||
if (mincore_mapped) {
|
||||
/*
|
||||
* We only care about this pmap's
|
||||
* mapping of the page, if any.
|
||||
*/
|
||||
if (locked_pa != 0) {
|
||||
vm_page_unlock(PHYS_TO_VM_PAGE(
|
||||
locked_pa));
|
||||
}
|
||||
} else if (locked_pa != 0) {
|
||||
/*
|
||||
* The page is mapped by this process but not
|
||||
* both accessed and modified. It is also
|
||||
|
|
Loading…
Reference in New Issue