From be7d4ac586a2784996ef024f81e0937b31652a1d Mon Sep 17 00:00:00 2001 From: Edward Tomasz Napierala Date: Sun, 22 Oct 2017 10:35:29 +0000 Subject: [PATCH] Add OID for the vm.overcommit sysctl. This makes it possible to remove one call to sysctl(2) from jemalloc startup code. (That also requires changes to jemalloc, but I plan to push those to upstream first.) Reviewed by: kib MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D12745 --- lib/libc/gen/sysctl.3 | 6 +++++- sys/vm/swap_pager.c | 2 +- sys/vm/vm_param.h | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3 index 959573ec9623..ba1cd8f2a13f 100644 --- a/lib/libc/gen/sysctl.3 +++ b/lib/libc/gen/sysctl.3 @@ -28,7 +28,7 @@ .\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95 .\" $FreeBSD$ .\" -.Dd September 10, 2015 +.Dd October 22, 2017 .Dt SYSCTL 3 .Os .Sh NAME @@ -741,6 +741,7 @@ privilege may change the value. .It Dv VM_V_FREE_TARGET Ta integer Ta yes .It Dv VM_V_INACTIVE_TARGET Ta integer Ta yes .It Dv VM_V_PAGEOUT_FREE_MIN Ta integer Ta yes +.It Dv VM_OVERCOMMIT Ta integer Ta yes .El .Bl -tag -width 6n .It Li VM_LOADAVG @@ -773,6 +774,9 @@ process address space when needed. .It Li VM_V_PAGEOUT_FREE_MIN If the amount of free and cache memory falls below this value, the pageout daemon will enter "memory conserving mode" to avoid deadlock. +.It Li VM_OVERCOMMIT +Overcommit behaviour, as described in +.Xr tuning 7 . .El .Sh RETURN VALUES .Rv -std diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index d3cc1330a08d..02891e90880f 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -157,7 +157,7 @@ static vm_ooffset_t swap_reserved; SYSCTL_QUAD(_vm, OID_AUTO, swap_reserved, CTLFLAG_RD, &swap_reserved, 0, "Amount of swap storage needed to back all allocated anonymous memory."); static int overcommit = 0; -SYSCTL_INT(_vm, OID_AUTO, overcommit, CTLFLAG_RW, &overcommit, 0, +SYSCTL_INT(_vm, VM_OVERCOMMIT, overcommit, CTLFLAG_RW, &overcommit, 0, "Configure virtual memory overcommit behavior. See tuning(7) " "for details."); static unsigned long swzone; diff --git a/sys/vm/vm_param.h b/sys/vm/vm_param.h index 8ca83bf18ddf..ff36bbb6d1d8 100644 --- a/sys/vm/vm_param.h +++ b/sys/vm/vm_param.h @@ -84,7 +84,8 @@ #define VM_V_PAGEOUT_FREE_MIN 9 /* vm_cnt.v_pageout_free_min */ #define VM_OBSOLETE_10 10 /* pageout algorithm */ #define VM_SWAPPING_ENABLED 11 /* swapping enabled */ -#define VM_MAXID 12 /* number of valid vm ids */ +#define VM_OVERCOMMIT 12 /* vm.overcommit */ +#define VM_MAXID 13 /* number of valid vm ids */ /* * Structure for swap device statistics