xref: /freebsd/lib/libc/gen/sysctl.3 (revision d74e86d9e30043893d6b308468008b65640ddcae)
1.\" Copyright (c) 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"	@(#)sysctl.3	8.4 (Berkeley) 5/9/95
33.\"
34.Dd May 9, 1995
35.Dt SYSCTL 3
36.Os
37.Sh NAME
38.Nm sysctl ,
39.Nm sysctlbyname
40.Nd get or set system information
41.Sh SYNOPSIS
42.Fd #include <sys/types.h>
43.Fd #include <sys/sysctl.h>
44.Ft int
45.Fn sysctl "int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen"
46.Ft int
47.Fn sysctlbyname "const char *name" "void *oldp" "size_t *oldlenp" "void *newp" "size_t newlen"
48.Sh DESCRIPTION
49The
50.Fn sysctl
51function retrieves system information and allows processes with
52appropriate privileges to set system information.
53The information available from
54.Fn sysctl
55consists of integers, strings, and tables.
56Information may be retrieved and set from the command interface
57using the
58.Xr sysctl 8
59utility.
60.Pp
61Unless explicitly noted below,
62.Fn sysctl
63returns a consistent snapshot of the data requested.
64Consistency is obtained by locking the destination
65buffer into memory so that the data may be copied out without blocking.
66Calls to
67.Fn sysctl
68are serialized to avoid deadlock.
69.Pp
70The state is described using a ``Management Information Base'' (MIB)
71style name, listed in
72.Fa name ,
73which is a
74.Fa namelen
75length array of integers.
76.Pp
77The
78.Fn sysctlbyname
79function accepts an ascii representation of the name and internally
80looks up the integer name vector.  Apart from that, it behaves the same
81as the standard
82.Fn sysctl
83function.
84.Pp
85The information is copied into the buffer specified by
86.Fa oldp .
87The size of the buffer is given by the location specified by
88.Fa oldlenp
89before the call,
90and that location gives the amount of data copied after a successful call
91and after a call that returns with the error code ENOMEM.
92If the amount of data available is greater
93than the size of the buffer supplied,
94the call supplies as much data as fits in the buffer provided
95and returns with the error code ENOMEM.
96If the old value is not desired,
97.Fa oldp
98and
99.Fa oldlenp
100should be set to NULL.
101.Pp
102The size of the available data can be determined by calling
103.Fn sysctl
104with a NULL parameter for
105.Fa oldp .
106The size of the available data will be returned in the location pointed to by
107.Fa oldlenp .
108For some operations, the amount of space may change often.
109For these operations,
110the system attempts to round up so that the returned size is
111large enough for a call to return the data shortly thereafter.
112.Pp
113To set a new value,
114.Fa newp
115is set to point to a buffer of length
116.Fa newlen
117from which the requested value is to be taken.
118If a new value is not to be set,
119.Fa newp
120should be set to NULL and
121.Fa newlen
122set to 0.
123.Pp
124The top level names are defined with a CTL_ prefix in
125.Pa <sys/sysctl.h> ,
126and are as follows.
127The next and subsequent levels down are found in the include files
128listed here, and described in separate sections below.
129.Pp
130.Bl -column CTLXMACHDEPXXX "Next level namesXXXXXX" -offset indent
131.It Sy Pa Name	Next level names	Description
132.It CTL\_DEBUG	sys/sysctl.h	Debugging
133.It CTL\_VFS	sys/mount.h	Filesystem
134.It CTL\_HW	sys/sysctl.h	Generic CPU, I/O
135.It CTL\_KERN	sys/sysctl.h	High kernel limits
136.It CTL\_MACHDEP	sys/sysctl.h	Machine dependent
137.It CTL\_NET	sys/socket.h	Networking
138.It CTL\_USER	sys/sysctl.h	User-level
139.It CTL\_VM	vm/vm_param.h	Virtual memory
140.El
141.Pp
142For example, the following retrieves the maximum number of processes allowed
143in the system:
144.Pp
145.Bd -literal -offset indent -compact
146int mib[2], maxproc;
147size_t len;
148
149mib[0] = CTL_KERN;
150mib[1] = KERN_MAXPROC;
151len = sizeof(maxproc);
152sysctl(mib, 2, &maxproc, &len, NULL, 0);
153.Ed
154.Pp
155To retrieve the standard search path for the system utilities:
156.Pp
157.Bd -literal -offset indent -compact
158int mib[2];
159size_t len;
160char *p;
161
162mib[0] = CTL_USER;
163mib[1] = USER_CS_PATH;
164sysctl(mib, 2, NULL, &len, NULL, 0);
165p = malloc(len);
166sysctl(mib, 2, p, &len, NULL, 0);
167.Ed
168.Sh CTL_DEBUG
169The debugging variables vary from system to system.
170A debugging variable may be added or deleted without need to recompile
171.Fn sysctl
172to know about it.
173Each time it runs,
174.Fn sysctl
175gets the list of debugging variables from the kernel and
176displays their current values.
177The system defines twenty
178.Ns ( Va struct ctldebug )
179variables named
180.Nm debug0
181through
182.Nm debug19 .
183They are declared as separate variables so that they can be
184individually initialized at the location of their associated variable.
185The loader prevents multiple use of the same variable by issuing errors
186if a variable is initialized in more than one place.
187For example, to export the variable
188.Nm dospecialcheck
189as a debugging variable, the following declaration would be used:
190.Bd -literal -offset indent -compact
191int dospecialcheck = 1;
192struct ctldebug debug5 = { "dospecialcheck", &dospecialcheck };
193.Ed
194.Sh CTL_VFS
195A distinguished second level name, VFS_GENERIC,
196is used to get general information about all filesystems.
197One of its third level identifiers is VFS_MAXTYPENUM
198that gives the highest valid filesystem type number.
199Its other third level identifier is VFS_CONF that
200returns configuration information about the filesystem
201type given as a fourth level identifier (see
202.Xr getvfsbyname 3
203as an example of its use).
204The remaining second level identifiers are the
205filesystem type number returned by a
206.Xr statfs 2
207call or from VFS_CONF.
208The third level identifiers available for each filesystem
209are given in the header file that defines the mount
210argument structure for that filesystem.
211.Sh CTL_HW
212The string and integer information available for the CTL_HW level
213is detailed below.
214The changeable column shows whether a process with appropriate
215privilege may change the value.
216.Bl -column "Second level nameXXXXXX" integerXXX -offset indent
217.It Sy Pa Second level name	Type	Changeable
218.It HW\_MACHINE	string	no
219.It HW\_MODEL	string	no
220.It HW\_NCPU	integer	no
221.It HW\_BYTEORDER	integer	no
222.It HW\_PHYSMEM	integer	no
223.It HW\_USERMEM	integer	no
224.It HW\_PAGESIZE	integer	no
225.It HW\_FLOATINGPOINT	integer	no
226.It HW\_MACHINE\_ARCH	string	no
227.\".It HW\_DISKNAMES	integer	no
228.\".It HW\_DISKSTATS	integer	no
229.El
230.Pp
231.Bl -tag -width "123456"
232.It Li HW_MACHINE
233The machine class.
234.It Li HW_MODEL
235The machine model
236.It Li HW_NCPU
237The number of cpus.
238.ne 1i
239.It Li HW_BYTEORDER
240The byteorder (4,321, or 1,234).
241.It Li HW_PHYSMEM
242The bytes of physical memory.
243.It Li HW_USERMEM
244The bytes of non-kernel memory.
245.It Li HW_PAGESIZE
246The software page size.
247.It Li HW_FLOATINGPOINT
248Nonzero if the floating point support is in hardware.
249.It Li HW_MACHINE_ARCH
250The machine dependent architecture type.
251.\".It Fa HW_DISKNAMES
252.\".It Fa HW_DISKSTATS
253.El
254.Sh CTL_KERN
255The string and integer information available for the CTL_KERN level
256is detailed below.
257The changeable column shows whether a process with appropriate
258privilege may change the value.
259The types of data currently available are process information,
260system vnodes, the open file entries, routing table entries,
261virtual memory statistics, load average history, and clock rate
262information.
263.Bl -column "KERNXMAXFILESPERPROCXXX" "struct clockrateXXX" -offset indent
264.It Sy Pa Second level name	Type	Changeable
265.It KERN\_ARGMAX	integer	no
266.It KERN\_BOOTFILE	string	yes
267.It KERN\_BOOTTIME	struct timeval	no
268.It KERN\_CLOCKRATE	struct clockinfo	no
269.It KERN\_FILE	struct file	no
270.It KERN\_HOSTID	integer	yes
271.It KERN\_HOSTNAME	string	yes
272.It KERN\_JOB\_CONTROL	integer	no
273.It KERN\_MAXFILES	integer	yes
274.It KERN\_MAXFILESPERPROC	integer	yes
275.It KERN\_MAXPROC	integer	yes
276.It KERN\_MAXPROCPERUID	integer	yes
277.It KERN\_MAXVNODES	integer	yes
278.It KERN\_NGROUPS	integer	no
279.It KERN\_NISDOMAINNAME	string	yes
280.It KERN\_OSRELDATE	integer	no
281.It KERN\_OSRELEASE	string	no
282.It KERN\_OSREV	integer	no
283.It KERN\_OSTYPE	string	no
284.It KERN\_POSIX1	integer	no
285.It KERN\_PROC	struct proc	no
286.It KERN\_PROF	node	not applicable
287.It KERN\_SAVED\_IDS	integer	no
288.It KERN\_SECURELVL	integer	raise only
289.It KERN\_UPDATEINTERVAL	integer	no
290.It KERN\_VERSION	string	no
291.It KERN\_VNODE	struct vnode	no
292.El
293.ne 1i
294.Pp
295.Bl -tag -width "123456"
296.It Li KERN_ARGMAX
297The maximum bytes of argument to
298.Xr execve 2 .
299.It Li KERN_BOOTFILE
300The full pathname of the file from which the kernel was loaded.
301.It Li KERN_BOOTTIME
302A
303.Va struct timeval
304structure is returned.
305This structure contains the time that the system was booted.
306.It Li KERN_CLOCKRATE
307A
308.Va struct clockinfo
309structure is returned.
310This structure contains the clock, statistics clock and profiling clock
311frequencies, the number of micro-seconds per hz tick and the skew rate.
312.It Li KERN_FILE
313Return the entire file table.
314The returned data consists of a single
315.Va struct filehead
316followed by an array of
317.Va struct file ,
318whose size depends on the current number of such objects in the system.
319.It Li KERN_HOSTID
320Get or set the host id.
321.It Li KERN_HOSTNAME
322Get or set the hostname.
323.It Li KERN_JOB_CONTROL
324Return 1 if job control is available on this system, otherwise 0.
325.It Li KERN_MAXFILES
326The maximum number of files that may be open in the system.
327.It Li KERN_MAXFILESPERPROC
328The maximum number of files that may be open for a single process.
329This limit only applies to processes with an effective uid of nonzero
330at the time of the open request.
331Files that have already been opened are not affected if the limit
332or the effective uid is changed.
333.It Li KERN_MAXPROC
334The maximum number of concurrent processes the system will allow.
335.It Li KERN_MAXPROCPERUID
336The maximum number of concurrent processes the system will allow
337for a single effective uid.
338This limit only applies to processes with an effective uid of nonzero
339at the time of a fork request.
340Processes that have already been started are not affected if the limit
341is changed.
342.It Li KERN_MAXVNODES
343The maximum number of vnodes available on the system.
344.It Li KERN_NGROUPS
345The maximum number of supplemental groups.
346.It Li KERN_NISDOMAINNAME
347The name of the current YP/NIS domain.
348.It Li KERN_OSRELDATE
349The system release date in YYYYMM format
350(January 1996 is encoded as 199601).
351.It Li KERN_OSRELEASE
352The system release string.
353.It Li KERN_OSREV
354The system revision string.
355.It Li KERN_OSTYPE
356The system type string.
357.It Li KERN_POSIX1
358The version of ISO/IEC 9945 (POSIX 1003.1) with which the system
359attempts to comply.
360.It Li KERN_PROC
361Return the entire process table, or a subset of it.
362An array of
363.Va struct kinfo_proc
364structures is returned,
365whose size depends on the current number of such objects in the system.
366The third and fourth level names are as follows:
367.Bl -column "Third level nameXXXXXX" "Fourth level is:XXXXXX" -offset indent
368.It Pa Third level name	Fourth level is:
369.It KERN\_PROC\_ALL	None
370.It KERN\_PROC\_PID	A process ID
371.It KERN\_PROC\_PGRP	A process group
372.It KERN\_PROC\_TTY	A tty device
373.It KERN\_PROC\_UID	A user ID
374.It KERN\_PROC\_RUID	A real user ID
375.El
376.It Li KERN_PROF
377Return profiling information about the kernel.
378If the kernel is not compiled for profiling,
379attempts to retrieve any of the KERN_PROF values will
380fail with EOPNOTSUPP.
381The third level names for the string and integer profiling information
382is detailed below.
383The changeable column shows whether a process with appropriate
384privilege may change the value.
385.Bl -column "GPROFXGMONPARAMXXX" "struct gmonparamXXX" -offset indent
386.It Sy Pa Third level name	Type	Changeable
387.It GPROF\_STATE	integer	yes
388.It GPROF\_COUNT	u_short[\|]	yes
389.It GPROF\_FROMS	u_short[\|]	yes
390.It GPROF\_TOS	struct tostruct	yes
391.It GPROF\_GMONPARAM	struct gmonparam	no
392.El
393.Pp
394The variables are as follows:
395.Bl -tag -width "123456"
396.It Li GPROF_STATE
397Returns GMON_PROF_ON or GMON_PROF_OFF to show that profiling
398is running or stopped.
399.It Li GPROF_COUNT
400Array of statistical program counter counts.
401.It Li GPROF_FROMS
402Array indexed by program counter of call-from points.
403.It Li GPROF_TOS
404Array of
405.Va struct tostruct
406describing destination of calls and their counts.
407.It Li GPROF_GMONPARAM
408Structure giving the sizes of the above arrays.
409.El
410.ne 1i
411.It Li KERN_SAVED_IDS
412Returns 1 if saved set-group and saved set-user ID is available.
413.It Li KERN_SECURELVL
414The system security level.
415This level may be raised by processes with appropriate privilege.
416It may not be lowered.
417.It Li KERN_VERSION
418The system version string.
419.It Li KERN_VNODE
420Return the entire vnode table.
421Note, the vnode table is not necessarily a consistent snapshot of
422the system.
423The returned data consists of an array whose size depends on the
424current number of such objects in the system.
425Each element of the array contains the kernel address of a vnode
426.Va struct vnode *
427followed by the vnode itself
428.Va struct vnode .
429.It Li KERN_UPDATEINTERVAL
430The interval between
431.Xr sync 2
432calls in the
433.Xr update 4
434process.
435.El
436.Sh CTL_MACHDEP
437The set of variables defined is architecture dependent.
438The following variables are defined for the i386 architecture.
439.Bl -column "CONSOLE_DEVICEXXX" "struct bootinfoXXX" -offset indent
440.It Sy Pa Second level name	Type	Changeable
441.It Li CPU_CONSDEV	dev_t	no
442.It Li CPU_ADJKERNTZ	int	yes
443.It Li CPU_DISRTCSET	int	yes
444.It Li CPU_BOOTINFO	struct bootinfo	no
445.It Li CPU_WALLCLOCK	int	yes
446.El
447.Sh CTL_NET
448The string and integer information available for the CTL_NET level
449is detailed below.
450The changeable column shows whether a process with appropriate
451privilege may change the value.
452.Bl -column "Second level nameXXXXXX" "routing messagesXXX" -offset indent
453.It Sy Pa Second level name	Type	Changeable
454.It PF\_ROUTE	routing messages	no
455.It PF\_INET	internet values	yes
456.El
457.Pp
458.Bl -tag -width "123456"
459.It Li PF_ROUTE
460Return the entire routing table or a subset of it.
461The data is returned as a sequence of routing messages (see
462.Xr route 4
463for the header file, format and meaning).
464The length of each message is contained in the message header.
465.Pp
466The third level name is a protocol number, which is currently always 0.
467The fourth level name is an address family, which may be set to 0 to
468select all address families.
469The fifth and sixth level names are as follows:
470.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
471.It Pa Fifth level name	Sixth level is:
472.It NET\_RT\_FLAGS	rtflags
473.It NET\_RT\_DUMP	None
474.It NET\_RT\_IFLIST	None
475.El
476.It Li PF_INET
477Get or set various global information about the internet protocols.
478The third level name is the protocol.
479The fourth level name is the variable name.
480The currently defined protocols and names are:
481.ne 1i
482.Bl -column ProtocolXX VariableXX TypeXX ChangeableXX
483.It Pa Protocol	Variable	Type	Changeable
484.It icmp	bmcastecho	integer	yes
485.It icmp	maskrepl	integer	yes
486.It ip	forwarding	integer	yes
487.It ip	redirect	integer	yes
488.It ip	ttl	integer	yes
489.It udp	checksum	integer	yes
490.El
491.Pp
492The variables are as follows:
493.Bl -tag -width "123456"
494.It Li icmp.bmcastecho
495Returns 1 if an ICMP echo request to a broadcast or multicast address is
496to be answered.
497.It Li icmp.maskrepl
498Returns 1 if ICMP network mask requests are to be answered.
499.It Li ip.forwarding
500Returns 1 when IP forwarding is enabled for the host,
501meaning that the host is acting as a router.
502.It Li ip.redirect
503Returns 1 when ICMP redirects may be sent by the host.
504This option is ignored unless the host is routing IP packets,
505and should normally be enabled on all systems.
506.It Li ip.ttl
507The maximum time-to-live (hop count) value for an IP packet sourced by
508the system.
509This value applies to normal transport protocols, not to ICMP.
510.It Li udp.checksum
511Returns 1 when UDP checksums are being computed and checked.
512Disabling UDP checksums is strongly discouraged.
513.El
514.Sh CTL_USER
515The string and integer information available for the CTL_USER level
516is detailed below.
517The changeable column shows whether a process with appropriate
518privilege may change the value.
519.Bl -column "USER_COLL_WEIGHTS_MAXXXX" "integerXXX" -offset indent
520.It Sy Pa Second level name	Type	Changeable
521.It USER\_BC\_BASE\_MAX	integer	no
522.It USER\_BC\_DIM\_MAX	integer	no
523.It USER\_BC\_SCALE\_MAX	integer	no
524.It USER\_BC\_STRING\_MAX	integer	no
525.It USER\_COLL\_WEIGHTS\_MAX	integer	no
526.It USER\_CS\_PATH	string	no
527.It USER\_EXPR\_NEST\_MAX	integer	no
528.It USER\_LINE\_MAX	integer	no
529.It USER\_POSIX2\_CHAR\_TERM	integer	no
530.It USER\_POSIX2\_C\_BIND	integer	no
531.It USER\_POSIX2\_C\_DEV	integer	no
532.It USER\_POSIX2\_FORT\_DEV	integer	no
533.It USER\_POSIX2\_FORT\_RUN	integer	no
534.It USER\_POSIX2\_LOCALEDEF	integer	no
535.It USER\_POSIX2\_SW\_DEV	integer	no
536.It USER\_POSIX2\_UPE	integer	no
537.It USER\_POSIX2\_VERSION	integer	no
538.It USER\_RE\_DUP\_MAX	integer	no
539.It USER\_STREAM\_MAX	integer	no
540.It USER\_TZNAME\_MAX	integer	no
541.El
542.Bl -tag -width "123456"
543.Pp
544.It Li USER_BC_BASE_MAX
545The maximum ibase/obase values in the
546.Xr bc 1
547utility.
548.It Li USER_BC_DIM_MAX
549The maximum array size in the
550.Xr bc 1
551utility.
552.It Li USER_BC_SCALE_MAX
553The maximum scale value in the
554.Xr bc 1
555utility.
556.It Li USER_BC_STRING_MAX
557The maximum string length in the
558.Xr bc 1
559utility.
560.It Li USER_COLL_WEIGHTS_MAX
561The maximum number of weights that can be assigned to any entry of
562the LC_COLLATE order keyword in the locale definition file.
563.It Li USER_CS_PATH
564Return a value for the
565.Ev PATH
566environment variable that finds all the standard utilities.
567.It Li USER_EXPR_NEST_MAX
568The maximum number of expressions that can be nested within
569parenthesis by the
570.Xr expr 1
571utility.
572.It Li USER_LINE_MAX
573The maximum length in bytes of a text-processing utility's input
574line.
575.It Li USER_POSIX2_CHAR_TERM
576Return 1 if the system supports at least one terminal type capable of
577all operations described in POSIX 1003.2, otherwise 0.
578.It Li USER_POSIX2_C_BIND
579Return 1 if the system's C-language development facilities support the
580C-Language Bindings Option, otherwise 0.
581.It Li USER_POSIX2_C_DEV
582Return 1 if the system supports the C-Language Development Utilities Option,
583otherwise 0.
584.It Li USER_POSIX2_FORT_DEV
585Return 1 if the system supports the FORTRAN Development Utilities Option,
586otherwise 0.
587.It Li USER_POSIX2_FORT_RUN
588Return 1 if the system supports the FORTRAN Runtime Utilities Option,
589otherwise 0.
590.It Li USER_POSIX2_LOCALEDEF
591Return 1 if the system supports the creation of locales, otherwise 0.
592.It Li USER_POSIX2_SW_DEV
593Return 1 if the system supports the Software Development Utilities Option,
594otherwise 0.
595.It Li USER_POSIX2_UPE
596Return 1 if the system supports the User Portability Utilities Option,
597otherwise 0.
598.It Li USER_POSIX2_VERSION
599The version of POSIX 1003.2 with which the system attempts to comply.
600.It Li USER_RE_DUP_MAX
601The maximum number of repeated occurrences of a regular expression
602permitted when using interval notation.
603.ne 1i
604.It Li USER_STREAM_MAX
605The minimum maximum number of streams that a process may have open
606at any one time.
607.It Li USER_TZNAME_MAX
608The minimum maximum number of types supported for the name of a
609timezone.
610.El
611.Sh CTL_VM
612The string and integer information available for the CTL_VM level
613is detailed below.
614The changeable column shows whether a process with appropriate
615privilege may change the value.
616.Bl -column "Second level nameXXXXXX" "struct loadavgXXX" -offset indent
617.It Sy Pa Second level name	Type	Changeable
618.It VM\_LOADAVG	struct loadavg	no
619.It VM\_METER	struct vmtotal	no
620.It VM\_PAGEOUT\_ALGORITHM	integer	yes
621.It VM\_SWAPPING\_ENABLED	integer	maybe
622.It VM\_V\_CACHE\_MAX	integer	yes
623.It VM\_V\_CACHE\_MIN	integer	yes
624.It VM\_V\_FREE\_MIN	integer	yes
625.It VM\_V\_FREE\_RESERVED	integer	yes
626.It VM\_V\_FREE\_TARGET	integer	yes
627.It VM\_V\_INACTIVE\_TARGET	integer	yes
628.It VM\_V\_PAGEOUT\_FREE\_MIN	integer	yes
629.El
630.Pp
631.Bl -tag -width "123456"
632.It Li VM_LOADAVG
633Return the load average history.
634The returned data consists of a
635.Va struct loadavg .
636.It Li VM_METER
637Return the system wide virtual memory statistics.
638The returned data consists of a
639.Va struct vmtotal .
640.It Li VM_PAGEOUT_ALGORITHM
6410 if the statistics-based page management algorithm is in use
642or 1 if the near-LRU algorithm is in use.
643.It Li VM_SWAPPING_ENABLED
6441 if process swapping is enabled or 0 if disabled.  This variable is
645permanently set to 0 if the kernel was built with swapping disabled.
646.It Li VM_V_CACHE_MAX
647Maximum desired size of the cache queue.
648.It Li VM_V_CACHE_MIN
649Minimum desired size of the cache queue.  If the cache queue size
650falls very far below this value, the pageout daemon is awakened.
651.It Li VM_V_FREE_MIN
652Minimum amount of memory (cache memory plus free memory)
653required to be available before a process waiting on memory will be
654awakened.
655.It Li VM_V_FREE_RESERVED
656Processes will awaken the pageout daemon and wait for memory if the
657number of free and cached pages drops below this value.
658.It Li VM_V_FREE_TARGET
659The total amount of free memory (including cache memory) that the
660pageout daemon tries to maintain.
661.It Li VM_V_INACTIVE_TARGET
662The desired number of inactive pages that the pageout daemon should
663achieve when it runs.  Inactive pages can be quickly inserted into
664process address space when needed.
665.It Li VM_V_PAGEOUT_FREE_MIN
666If the amount of free and cache memory falls below this value, the
667pageout daemon will enter "memory conserving mode" to avoid deadlock.
668.El
669.Sh RETURN VALUES
670If the call to
671.Fn sysctl
672is successful, the number of bytes copied out is returned.
673Otherwise \-1 is returned and
674.Va errno
675is set appropriately.
676.Sh ERRORS
677The following errors may be reported:
678.Bl -tag -width Er
679.It Bq Er EFAULT
680The buffer
681.Fa name ,
682.Fa oldp ,
683.Fa newp ,
684or length pointer
685.Fa oldlenp
686contains an invalid address.
687.It Bq Er EINVAL
688The
689.Fa name
690array is less than two or greater than CTL_MAXNAME.
691.It Bq Er EINVAL
692A non-null
693.Fa newp
694is given and its specified length in
695.Fa newlen
696is too large or too small.
697.It Bq Er ENOMEM
698The length pointed to by
699.Fa oldlenp
700is too short to hold the requested value.
701.It Bq Er ENOTDIR
702The
703.Fa name
704array specifies an intermediate rather than terminal name.
705.It Bq Er EOPNOTSUPP
706The
707.Fa name
708array specifies a value that is unknown.
709.It Bq Er EPERM
710An attempt is made to set a read-only value.
711.It Bq Er EPERM
712A process without appropriate privilege attempts to set a value.
713.El
714.Sh FILES
715.Bl -tag -width <netinet/icmpXvar.h> -compact
716.It Pa <sys/sysctl.h>
717definitions for top level identifiers, second level kernel and hardware
718identifiers, and user level identifiers
719.It Pa <sys/socket.h>
720definitions for second level network identifiers
721.It Pa <sys/gmon.h>
722definitions for third level profiling identifiers
723.It Pa <vm/vm_param.h>
724definitions for second level virtual memory identifiers
725.It Pa <netinet/in.h>
726definitions for third level Internet identifiers and
727fourth level IP identifiers
728.It Pa <netinet/icmp_var.h>
729definitions for fourth level ICMP identifiers
730.It Pa <netinet/udp_var.h>
731definitions for fourth level UDP identifiers
732.El
733.Sh SEE ALSO
734.Xr sysconf 3 ,
735.Xr sysctl 3
736.Sh HISTORY
737The
738.Fn sysctl
739function first appeared in
740.Bx 4.4 .
741