readv2: Note preadv2(..., RWF_NOWAIT) bug in BUGS section
[man-pages.git] / man2 / sysinfo.2
bloba45211cd3ff553310a64a8bc7c4f662e211c94bf
1 .\" Copyright (C) 2016, Michael Kerrisk <mtk.manpages@gmail.com>
2 .\" Based on an earlier version of the page where a few pieces were
3 .\" copyright (C) 1993 by Dan Miner (dminer@nyx.cs.du.edu) and subsequently
4 .\" others (see old changelog below).
5 .\" The structure definitions are taken more or less straight from the kernel
6 .\" source files.
7 .\"
8 .\" %%%LICENSE_START(VERBATIM)
9 .\" Permission is granted to make and distribute verbatim copies of this
10 .\" manual provided the copyright notice and this permission notice are
11 .\" preserved on all copies.
12 .\"
13 .\" Permission is granted to copy and distribute modified versions of this
14 .\" manual under the conditions for verbatim copying, provided that the
15 .\" entire resulting derived work is distributed under the terms of a
16 .\" permission notice identical to this one.
17 .\"
18 .\" Since the Linux kernel and libraries are constantly changing, this
19 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
20 .\" responsibility for errors or omissions, or for damages resulting from
21 .\" the use of the information contained herein.  The author(s) may not
22 .\" have taken the same level of care in the production of this manual,
23 .\" which is licensed free of charge, as they might when working
24 .\" professionally.
25 .\"
26 .\" Formatted or processed versions of this manual, if unaccompanied by
27 .\" the source, must acknowledge the copyright and authors of this work.
28 .\" %%%LICENSE_END
29 .\"
30 .\"
31 .\" Modified Sat Jul 24 12:35:12 1993 by Rik Faith <faith@cs.unc.edu>
32 .\" Modified Tue Oct 22 22:29:51 1996 by Eric S. Raymond <esr@thyrsus.com>
33 .\" Modified Mon Aug 25 16:06:11 1997 by Nicolás Lichtmaier <nick@debian.org>
34 .\"
35 .TH SYSINFO 2 2021-03-22 "Linux" "Linux Programmer's Manual"
36 .SH NAME
37 sysinfo \- return system information
38 .SH SYNOPSIS
39 .nf
40 .B #include <sys/sysinfo.h>
41 .PP
42 .BI "int sysinfo(struct sysinfo *" info );
43 .fi
44 .SH DESCRIPTION
45 .BR sysinfo ()
46 returns certain statistics on memory and swap usage,
47 as well as the load average.
48 .PP
49 Until Linux 2.3.16,
50 .BR sysinfo ()
51 returned information in the following structure:
52 .PP
53 .in +4n
54 .EX
55 struct sysinfo {
56     long uptime;             /* Seconds since boot */
57     unsigned long loads[3];  /* 1, 5, and 15 minute load averages */
58     unsigned long totalram;  /* Total usable main memory size */
59     unsigned long freeram;   /* Available memory size */
60     unsigned long sharedram; /* Amount of shared memory */
61     unsigned long bufferram; /* Memory used by buffers */
62     unsigned long totalswap; /* Total swap space size */
63     unsigned long freeswap;  /* Swap space still available */
64     unsigned short procs;    /* Number of current processes */
65     char _f[22];             /* Pads structure to 64 bytes */
67 .EE
68 .in
69 .PP
70 In the above structure, the sizes of the memory and swap fields
71 are given in bytes.
72 .PP
73 Since Linux 2.3.23 (i386) and Linux 2.3.48
74 (all architectures) the structure is:
75 .PP
76 .in +4n
77 .EX
78 struct sysinfo {
79     long uptime;             /* Seconds since boot */
80     unsigned long loads[3];  /* 1, 5, and 15 minute load averages */
81     unsigned long totalram;  /* Total usable main memory size */
82     unsigned long freeram;   /* Available memory size */
83     unsigned long sharedram; /* Amount of shared memory */
84     unsigned long bufferram; /* Memory used by buffers */
85     unsigned long totalswap; /* Total swap space size */
86     unsigned long freeswap;  /* Swap space still available */
87     unsigned short procs;    /* Number of current processes */
88     unsigned long totalhigh; /* Total high memory size */
89     unsigned long freehigh;  /* Available high memory size */
90     unsigned int mem_unit;   /* Memory unit size in bytes */
91     char _f[20\-2*sizeof(long)\-sizeof(int)];
92                              /* Padding to 64 bytes */
94 .EE
95 .in
96 .PP
97 In the above structure,
98 sizes of the memory and swap fields are given as multiples of
99 .I mem_unit
100 bytes.
101 .SH RETURN VALUE
102 On success,
103 .BR sysinfo ()
104 returns zero.
105 On error, \-1 is returned, and
106 .I errno
107 is set to indicate the error.
108 .SH ERRORS
110 .B EFAULT
111 .IR info
112 is not a valid address.
113 .SH VERSIONS
114 .BR sysinfo ()
115 first appeared in Linux 0.98.pl6.
116 .SH CONFORMING TO
117 This function is Linux-specific, and should not be used in programs
118 intended to be portable.
119 .SH NOTES
120 All of the information provided by this system call is also available via
121 .IR /proc/meminfo
123 .IR /proc/loadavg .
124 .SH SEE ALSO
125 .BR proc (5)