xref: /OK3568_Linux_fs/kernel/Documentation/filesystems/proc.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun====================
4*4882a593SmuzhiyunThe /proc Filesystem
5*4882a593Smuzhiyun====================
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun=====================  =======================================  ================
8*4882a593Smuzhiyun/proc/sys              Terrehon Bowden <terrehon@pacbell.net>,  October 7 1999
9*4882a593Smuzhiyun                       Bodo Bauer <bb@ricochet.net>
10*4882a593Smuzhiyun2.4.x update	       Jorge Nerin <comandante@zaralinux.com>   November 14 2000
11*4882a593Smuzhiyunmove /proc/sys	       Shen Feng <shen@cn.fujitsu.com>	        April 1 2009
12*4882a593Smuzhiyunfixes/update part 1.1  Stefani Seibold <stefani@seibold.net>    June 9 2009
13*4882a593Smuzhiyun=====================  =======================================  ================
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun.. Table of Contents
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun  0     Preface
20*4882a593Smuzhiyun  0.1	Introduction/Credits
21*4882a593Smuzhiyun  0.2	Legal Stuff
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun  1	Collecting System Information
24*4882a593Smuzhiyun  1.1	Process-Specific Subdirectories
25*4882a593Smuzhiyun  1.2	Kernel data
26*4882a593Smuzhiyun  1.3	IDE devices in /proc/ide
27*4882a593Smuzhiyun  1.4	Networking info in /proc/net
28*4882a593Smuzhiyun  1.5	SCSI info
29*4882a593Smuzhiyun  1.6	Parallel port info in /proc/parport
30*4882a593Smuzhiyun  1.7	TTY info in /proc/tty
31*4882a593Smuzhiyun  1.8	Miscellaneous kernel statistics in /proc/stat
32*4882a593Smuzhiyun  1.9	Ext4 file system parameters
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun  2	Modifying System Parameters
35*4882a593Smuzhiyun
36*4882a593Smuzhiyun  3	Per-Process Parameters
37*4882a593Smuzhiyun  3.1	/proc/<pid>/oom_adj & /proc/<pid>/oom_score_adj - Adjust the oom-killer
38*4882a593Smuzhiyun								score
39*4882a593Smuzhiyun  3.2	/proc/<pid>/oom_score - Display current oom-killer score
40*4882a593Smuzhiyun  3.3	/proc/<pid>/io - Display the IO accounting fields
41*4882a593Smuzhiyun  3.4	/proc/<pid>/coredump_filter - Core dump filtering settings
42*4882a593Smuzhiyun  3.5	/proc/<pid>/mountinfo - Information about mounts
43*4882a593Smuzhiyun  3.6	/proc/<pid>/comm  & /proc/<pid>/task/<tid>/comm
44*4882a593Smuzhiyun  3.7   /proc/<pid>/task/<tid>/children - Information about task children
45*4882a593Smuzhiyun  3.8   /proc/<pid>/fdinfo/<fd> - Information about opened file
46*4882a593Smuzhiyun  3.9   /proc/<pid>/map_files - Information about memory mapped files
47*4882a593Smuzhiyun  3.10  /proc/<pid>/timerslack_ns - Task timerslack value
48*4882a593Smuzhiyun  3.11	/proc/<pid>/patch_state - Livepatch patch operation state
49*4882a593Smuzhiyun  3.12	/proc/<pid>/arch_status - Task architecture specific information
50*4882a593Smuzhiyun
51*4882a593Smuzhiyun  4	Configuring procfs
52*4882a593Smuzhiyun  4.1	Mount options
53*4882a593Smuzhiyun
54*4882a593Smuzhiyun  5	Filesystem behavior
55*4882a593Smuzhiyun
56*4882a593SmuzhiyunPreface
57*4882a593Smuzhiyun=======
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun0.1 Introduction/Credits
60*4882a593Smuzhiyun------------------------
61*4882a593Smuzhiyun
62*4882a593SmuzhiyunThis documentation is  part of a soon (or  so we hope) to be  released book on
63*4882a593Smuzhiyunthe SuSE  Linux distribution. As  there is  no complete documentation  for the
64*4882a593Smuzhiyun/proc file system and we've used  many freely available sources to write these
65*4882a593Smuzhiyunchapters, it  seems only fair  to give the work  back to the  Linux community.
66*4882a593SmuzhiyunThis work is  based on the 2.2.*  kernel version and the  upcoming 2.4.*. I'm
67*4882a593Smuzhiyunafraid it's still far from complete, but we  hope it will be useful. As far as
68*4882a593Smuzhiyunwe know, it is the first 'all-in-one' document about the /proc file system. It
69*4882a593Smuzhiyunis focused  on the Intel  x86 hardware,  so if you  are looking for  PPC, ARM,
70*4882a593SmuzhiyunSPARC, AXP, etc., features, you probably  won't find what you are looking for.
71*4882a593SmuzhiyunIt also only covers IPv4 networking, not IPv6 nor other protocols - sorry. But
72*4882a593Smuzhiyunadditions and patches  are welcome and will  be added to this  document if you
73*4882a593Smuzhiyunmail them to Bodo.
74*4882a593Smuzhiyun
75*4882a593SmuzhiyunWe'd like  to  thank Alan Cox, Rik van Riel, and Alexey Kuznetsov and a lot of
76*4882a593Smuzhiyunother people for help compiling this documentation. We'd also like to extend a
77*4882a593Smuzhiyunspecial thank  you to Andi Kleen for documentation, which we relied on heavily
78*4882a593Smuzhiyunto create  this  document,  as well as the additional information he provided.
79*4882a593SmuzhiyunThanks to  everybody  else  who contributed source or docs to the Linux kernel
80*4882a593Smuzhiyunand helped create a great piece of software... :)
81*4882a593Smuzhiyun
82*4882a593SmuzhiyunIf you  have  any comments, corrections or additions, please don't hesitate to
83*4882a593Smuzhiyuncontact Bodo  Bauer  at  bb@ricochet.net.  We'll  be happy to add them to this
84*4882a593Smuzhiyundocument.
85*4882a593Smuzhiyun
86*4882a593SmuzhiyunThe   latest   version    of   this   document   is    available   online   at
87*4882a593Smuzhiyunhttp://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html
88*4882a593Smuzhiyun
89*4882a593SmuzhiyunIf  the above  direction does  not works  for you,  you could  try the  kernel
90*4882a593Smuzhiyunmailing  list  at  linux-kernel@vger.kernel.org  and/or try  to  reach  me  at
91*4882a593Smuzhiyuncomandante@zaralinux.com.
92*4882a593Smuzhiyun
93*4882a593Smuzhiyun0.2 Legal Stuff
94*4882a593Smuzhiyun---------------
95*4882a593Smuzhiyun
96*4882a593SmuzhiyunWe don't  guarantee  the  correctness  of this document, and if you come to us
97*4882a593Smuzhiyuncomplaining about  how  you  screwed  up  your  system  because  of  incorrect
98*4882a593Smuzhiyundocumentation, we won't feel responsible...
99*4882a593Smuzhiyun
100*4882a593SmuzhiyunChapter 1: Collecting System Information
101*4882a593Smuzhiyun========================================
102*4882a593Smuzhiyun
103*4882a593SmuzhiyunIn This Chapter
104*4882a593Smuzhiyun---------------
105*4882a593Smuzhiyun* Investigating  the  properties  of  the  pseudo  file  system  /proc and its
106*4882a593Smuzhiyun  ability to provide information on the running Linux system
107*4882a593Smuzhiyun* Examining /proc's structure
108*4882a593Smuzhiyun* Uncovering  various  information  about the kernel and the processes running
109*4882a593Smuzhiyun  on the system
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun------------------------------------------------------------------------------
112*4882a593Smuzhiyun
113*4882a593SmuzhiyunThe proc  file  system acts as an interface to internal data structures in the
114*4882a593Smuzhiyunkernel. It  can  be  used to obtain information about the system and to change
115*4882a593Smuzhiyuncertain kernel parameters at runtime (sysctl).
116*4882a593Smuzhiyun
117*4882a593SmuzhiyunFirst, we'll  take  a  look  at the read-only parts of /proc. In Chapter 2, we
118*4882a593Smuzhiyunshow you how you can use /proc/sys to change settings.
119*4882a593Smuzhiyun
120*4882a593Smuzhiyun1.1 Process-Specific Subdirectories
121*4882a593Smuzhiyun-----------------------------------
122*4882a593Smuzhiyun
123*4882a593SmuzhiyunThe directory  /proc  contains  (among other things) one subdirectory for each
124*4882a593Smuzhiyunprocess running on the system, which is named after the process ID (PID).
125*4882a593Smuzhiyun
126*4882a593SmuzhiyunThe link  'self'  points to  the process reading the file system. Each process
127*4882a593Smuzhiyunsubdirectory has the entries listed in Table 1-1.
128*4882a593Smuzhiyun
129*4882a593SmuzhiyunNote that an open file descriptor to /proc/<pid> or to any of its
130*4882a593Smuzhiyuncontained files or subdirectories does not prevent <pid> being reused
131*4882a593Smuzhiyunfor some other process in the event that <pid> exits. Operations on
132*4882a593Smuzhiyunopen /proc/<pid> file descriptors corresponding to dead processes
133*4882a593Smuzhiyunnever act on any new process that the kernel may, through chance, have
134*4882a593Smuzhiyunalso assigned the process ID <pid>. Instead, operations on these FDs
135*4882a593Smuzhiyunusually fail with ESRCH.
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun.. table:: Table 1-1: Process specific entries in /proc
138*4882a593Smuzhiyun
139*4882a593Smuzhiyun =============  ===============================================================
140*4882a593Smuzhiyun File		Content
141*4882a593Smuzhiyun =============  ===============================================================
142*4882a593Smuzhiyun clear_refs	Clears page referenced bits shown in smaps output
143*4882a593Smuzhiyun cmdline	Command line arguments
144*4882a593Smuzhiyun cpu		Current and last cpu in which it was executed	(2.4)(smp)
145*4882a593Smuzhiyun cwd		Link to the current working directory
146*4882a593Smuzhiyun environ	Values of environment variables
147*4882a593Smuzhiyun exe		Link to the executable of this process
148*4882a593Smuzhiyun fd		Directory, which contains all file descriptors
149*4882a593Smuzhiyun maps		Memory maps to executables and library files	(2.4)
150*4882a593Smuzhiyun mem		Memory held by this process
151*4882a593Smuzhiyun root		Link to the root directory of this process
152*4882a593Smuzhiyun stat		Process status
153*4882a593Smuzhiyun statm		Process memory status information
154*4882a593Smuzhiyun status		Process status in human readable form
155*4882a593Smuzhiyun wchan		Present with CONFIG_KALLSYMS=y: it shows the kernel function
156*4882a593Smuzhiyun		symbol the task is blocked in - or "0" if not blocked.
157*4882a593Smuzhiyun pagemap	Page table
158*4882a593Smuzhiyun stack		Report full stack trace, enable via CONFIG_STACKTRACE
159*4882a593Smuzhiyun smaps		An extension based on maps, showing the memory consumption of
160*4882a593Smuzhiyun		each mapping and flags associated with it
161*4882a593Smuzhiyun smaps_rollup	Accumulated smaps stats for all mappings of the process.  This
162*4882a593Smuzhiyun		can be derived from smaps, but is faster and more convenient
163*4882a593Smuzhiyun numa_maps	An extension based on maps, showing the memory locality and
164*4882a593Smuzhiyun		binding policy as well as mem usage (in pages) of each mapping.
165*4882a593Smuzhiyun =============  ===============================================================
166*4882a593Smuzhiyun
167*4882a593SmuzhiyunFor example, to get the status information of a process, all you have to do is
168*4882a593Smuzhiyunread the file /proc/PID/status::
169*4882a593Smuzhiyun
170*4882a593Smuzhiyun  >cat /proc/self/status
171*4882a593Smuzhiyun  Name:   cat
172*4882a593Smuzhiyun  State:  R (running)
173*4882a593Smuzhiyun  Tgid:   5452
174*4882a593Smuzhiyun  Pid:    5452
175*4882a593Smuzhiyun  PPid:   743
176*4882a593Smuzhiyun  TracerPid:      0						(2.4)
177*4882a593Smuzhiyun  Uid:    501     501     501     501
178*4882a593Smuzhiyun  Gid:    100     100     100     100
179*4882a593Smuzhiyun  FDSize: 256
180*4882a593Smuzhiyun  Groups: 100 14 16
181*4882a593Smuzhiyun  VmPeak:     5004 kB
182*4882a593Smuzhiyun  VmSize:     5004 kB
183*4882a593Smuzhiyun  VmLck:         0 kB
184*4882a593Smuzhiyun  VmHWM:       476 kB
185*4882a593Smuzhiyun  VmRSS:       476 kB
186*4882a593Smuzhiyun  RssAnon:             352 kB
187*4882a593Smuzhiyun  RssFile:             120 kB
188*4882a593Smuzhiyun  RssShmem:              4 kB
189*4882a593Smuzhiyun  VmData:      156 kB
190*4882a593Smuzhiyun  VmStk:        88 kB
191*4882a593Smuzhiyun  VmExe:        68 kB
192*4882a593Smuzhiyun  VmLib:      1412 kB
193*4882a593Smuzhiyun  VmPTE:        20 kb
194*4882a593Smuzhiyun  VmSwap:        0 kB
195*4882a593Smuzhiyun  HugetlbPages:          0 kB
196*4882a593Smuzhiyun  CoreDumping:    0
197*4882a593Smuzhiyun  THP_enabled:	  1
198*4882a593Smuzhiyun  Threads:        1
199*4882a593Smuzhiyun  SigQ:   0/28578
200*4882a593Smuzhiyun  SigPnd: 0000000000000000
201*4882a593Smuzhiyun  ShdPnd: 0000000000000000
202*4882a593Smuzhiyun  SigBlk: 0000000000000000
203*4882a593Smuzhiyun  SigIgn: 0000000000000000
204*4882a593Smuzhiyun  SigCgt: 0000000000000000
205*4882a593Smuzhiyun  CapInh: 00000000fffffeff
206*4882a593Smuzhiyun  CapPrm: 0000000000000000
207*4882a593Smuzhiyun  CapEff: 0000000000000000
208*4882a593Smuzhiyun  CapBnd: ffffffffffffffff
209*4882a593Smuzhiyun  CapAmb: 0000000000000000
210*4882a593Smuzhiyun  NoNewPrivs:     0
211*4882a593Smuzhiyun  Seccomp:        0
212*4882a593Smuzhiyun  Speculation_Store_Bypass:       thread vulnerable
213*4882a593Smuzhiyun  voluntary_ctxt_switches:        0
214*4882a593Smuzhiyun  nonvoluntary_ctxt_switches:     1
215*4882a593Smuzhiyun
216*4882a593SmuzhiyunThis shows you nearly the same information you would get if you viewed it with
217*4882a593Smuzhiyunthe ps  command.  In  fact,  ps  uses  the  proc  file  system  to  obtain its
218*4882a593Smuzhiyuninformation.  But you get a more detailed  view of the  process by reading the
219*4882a593Smuzhiyunfile /proc/PID/status. It fields are described in table 1-2.
220*4882a593Smuzhiyun
221*4882a593SmuzhiyunThe  statm  file  contains  more  detailed  information about the process
222*4882a593Smuzhiyunmemory usage. Its seven fields are explained in Table 1-3.  The stat file
223*4882a593Smuzhiyuncontains detailed information about the process itself.  Its fields are
224*4882a593Smuzhiyunexplained in Table 1-4.
225*4882a593Smuzhiyun
226*4882a593Smuzhiyun(for SMP CONFIG users)
227*4882a593Smuzhiyun
228*4882a593SmuzhiyunFor making accounting scalable, RSS related information are handled in an
229*4882a593Smuzhiyunasynchronous manner and the value may not be very precise. To see a precise
230*4882a593Smuzhiyunsnapshot of a moment, you can see /proc/<pid>/smaps file and scan page table.
231*4882a593SmuzhiyunIt's slow but very precise.
232*4882a593Smuzhiyun
233*4882a593Smuzhiyun.. table:: Table 1-2: Contents of the status files (as of 4.19)
234*4882a593Smuzhiyun
235*4882a593Smuzhiyun ==========================  ===================================================
236*4882a593Smuzhiyun Field                       Content
237*4882a593Smuzhiyun ==========================  ===================================================
238*4882a593Smuzhiyun Name                        filename of the executable
239*4882a593Smuzhiyun Umask                       file mode creation mask
240*4882a593Smuzhiyun State                       state (R is running, S is sleeping, D is sleeping
241*4882a593Smuzhiyun                             in an uninterruptible wait, Z is zombie,
242*4882a593Smuzhiyun			     T is traced or stopped)
243*4882a593Smuzhiyun Tgid                        thread group ID
244*4882a593Smuzhiyun Ngid                        NUMA group ID (0 if none)
245*4882a593Smuzhiyun Pid                         process id
246*4882a593Smuzhiyun PPid                        process id of the parent process
247*4882a593Smuzhiyun TracerPid                   PID of process tracing this process (0 if not)
248*4882a593Smuzhiyun Uid                         Real, effective, saved set, and  file system UIDs
249*4882a593Smuzhiyun Gid                         Real, effective, saved set, and  file system GIDs
250*4882a593Smuzhiyun FDSize                      number of file descriptor slots currently allocated
251*4882a593Smuzhiyun Groups                      supplementary group list
252*4882a593Smuzhiyun NStgid                      descendant namespace thread group ID hierarchy
253*4882a593Smuzhiyun NSpid                       descendant namespace process ID hierarchy
254*4882a593Smuzhiyun NSpgid                      descendant namespace process group ID hierarchy
255*4882a593Smuzhiyun NSsid                       descendant namespace session ID hierarchy
256*4882a593Smuzhiyun VmPeak                      peak virtual memory size
257*4882a593Smuzhiyun VmSize                      total program size
258*4882a593Smuzhiyun VmLck                       locked memory size
259*4882a593Smuzhiyun VmPin                       pinned memory size
260*4882a593Smuzhiyun VmHWM                       peak resident set size ("high water mark")
261*4882a593Smuzhiyun VmRSS                       size of memory portions. It contains the three
262*4882a593Smuzhiyun                             following parts
263*4882a593Smuzhiyun                             (VmRSS = RssAnon + RssFile + RssShmem)
264*4882a593Smuzhiyun RssAnon                     size of resident anonymous memory
265*4882a593Smuzhiyun RssFile                     size of resident file mappings
266*4882a593Smuzhiyun RssShmem                    size of resident shmem memory (includes SysV shm,
267*4882a593Smuzhiyun                             mapping of tmpfs and shared anonymous mappings)
268*4882a593Smuzhiyun VmData                      size of private data segments
269*4882a593Smuzhiyun VmStk                       size of stack segments
270*4882a593Smuzhiyun VmExe                       size of text segment
271*4882a593Smuzhiyun VmLib                       size of shared library code
272*4882a593Smuzhiyun VmPTE                       size of page table entries
273*4882a593Smuzhiyun VmSwap                      amount of swap used by anonymous private data
274*4882a593Smuzhiyun                             (shmem swap usage is not included)
275*4882a593Smuzhiyun HugetlbPages                size of hugetlb memory portions
276*4882a593Smuzhiyun CoreDumping                 process's memory is currently being dumped
277*4882a593Smuzhiyun                             (killing the process may lead to a corrupted core)
278*4882a593Smuzhiyun THP_enabled		     process is allowed to use THP (returns 0 when
279*4882a593Smuzhiyun			     PR_SET_THP_DISABLE is set on the process
280*4882a593Smuzhiyun Threads                     number of threads
281*4882a593Smuzhiyun SigQ                        number of signals queued/max. number for queue
282*4882a593Smuzhiyun SigPnd                      bitmap of pending signals for the thread
283*4882a593Smuzhiyun ShdPnd                      bitmap of shared pending signals for the process
284*4882a593Smuzhiyun SigBlk                      bitmap of blocked signals
285*4882a593Smuzhiyun SigIgn                      bitmap of ignored signals
286*4882a593Smuzhiyun SigCgt                      bitmap of caught signals
287*4882a593Smuzhiyun CapInh                      bitmap of inheritable capabilities
288*4882a593Smuzhiyun CapPrm                      bitmap of permitted capabilities
289*4882a593Smuzhiyun CapEff                      bitmap of effective capabilities
290*4882a593Smuzhiyun CapBnd                      bitmap of capabilities bounding set
291*4882a593Smuzhiyun CapAmb                      bitmap of ambient capabilities
292*4882a593Smuzhiyun NoNewPrivs                  no_new_privs, like prctl(PR_GET_NO_NEW_PRIV, ...)
293*4882a593Smuzhiyun Seccomp                     seccomp mode, like prctl(PR_GET_SECCOMP, ...)
294*4882a593Smuzhiyun Speculation_Store_Bypass    speculative store bypass mitigation status
295*4882a593Smuzhiyun Cpus_allowed                mask of CPUs on which this process may run
296*4882a593Smuzhiyun Cpus_allowed_list           Same as previous, but in "list format"
297*4882a593Smuzhiyun Mems_allowed                mask of memory nodes allowed to this process
298*4882a593Smuzhiyun Mems_allowed_list           Same as previous, but in "list format"
299*4882a593Smuzhiyun voluntary_ctxt_switches     number of voluntary context switches
300*4882a593Smuzhiyun nonvoluntary_ctxt_switches  number of non voluntary context switches
301*4882a593Smuzhiyun ==========================  ===================================================
302*4882a593Smuzhiyun
303*4882a593Smuzhiyun
304*4882a593Smuzhiyun.. table:: Table 1-3: Contents of the statm files (as of 2.6.8-rc3)
305*4882a593Smuzhiyun
306*4882a593Smuzhiyun ======== ===============================	==============================
307*4882a593Smuzhiyun Field    Content
308*4882a593Smuzhiyun ======== ===============================	==============================
309*4882a593Smuzhiyun size     total program size (pages)		(same as VmSize in status)
310*4882a593Smuzhiyun resident size of memory portions (pages)	(same as VmRSS in status)
311*4882a593Smuzhiyun shared   number of pages that are shared	(i.e. backed by a file, same
312*4882a593Smuzhiyun						as RssFile+RssShmem in status)
313*4882a593Smuzhiyun trs      number of pages that are 'code'	(not including libs; broken,
314*4882a593Smuzhiyun						includes data segment)
315*4882a593Smuzhiyun lrs      number of pages of library		(always 0 on 2.6)
316*4882a593Smuzhiyun drs      number of pages of data/stack		(including libs; broken,
317*4882a593Smuzhiyun						includes library text)
318*4882a593Smuzhiyun dt       number of dirty pages			(always 0 on 2.6)
319*4882a593Smuzhiyun ======== ===============================	==============================
320*4882a593Smuzhiyun
321*4882a593Smuzhiyun
322*4882a593Smuzhiyun.. table:: Table 1-4: Contents of the stat files (as of 2.6.30-rc7)
323*4882a593Smuzhiyun
324*4882a593Smuzhiyun  ============= ===============================================================
325*4882a593Smuzhiyun  Field         Content
326*4882a593Smuzhiyun  ============= ===============================================================
327*4882a593Smuzhiyun  pid           process id
328*4882a593Smuzhiyun  tcomm         filename of the executable
329*4882a593Smuzhiyun  state         state (R is running, S is sleeping, D is sleeping in an
330*4882a593Smuzhiyun                uninterruptible wait, Z is zombie, T is traced or stopped)
331*4882a593Smuzhiyun  ppid          process id of the parent process
332*4882a593Smuzhiyun  pgrp          pgrp of the process
333*4882a593Smuzhiyun  sid           session id
334*4882a593Smuzhiyun  tty_nr        tty the process uses
335*4882a593Smuzhiyun  tty_pgrp      pgrp of the tty
336*4882a593Smuzhiyun  flags         task flags
337*4882a593Smuzhiyun  min_flt       number of minor faults
338*4882a593Smuzhiyun  cmin_flt      number of minor faults with child's
339*4882a593Smuzhiyun  maj_flt       number of major faults
340*4882a593Smuzhiyun  cmaj_flt      number of major faults with child's
341*4882a593Smuzhiyun  utime         user mode jiffies
342*4882a593Smuzhiyun  stime         kernel mode jiffies
343*4882a593Smuzhiyun  cutime        user mode jiffies with child's
344*4882a593Smuzhiyun  cstime        kernel mode jiffies with child's
345*4882a593Smuzhiyun  priority      priority level
346*4882a593Smuzhiyun  nice          nice level
347*4882a593Smuzhiyun  num_threads   number of threads
348*4882a593Smuzhiyun  it_real_value	(obsolete, always 0)
349*4882a593Smuzhiyun  start_time    time the process started after system boot
350*4882a593Smuzhiyun  vsize         virtual memory size
351*4882a593Smuzhiyun  rss           resident set memory size
352*4882a593Smuzhiyun  rsslim        current limit in bytes on the rss
353*4882a593Smuzhiyun  start_code    address above which program text can run
354*4882a593Smuzhiyun  end_code      address below which program text can run
355*4882a593Smuzhiyun  start_stack   address of the start of the main process stack
356*4882a593Smuzhiyun  esp           current value of ESP
357*4882a593Smuzhiyun  eip           current value of EIP
358*4882a593Smuzhiyun  pending       bitmap of pending signals
359*4882a593Smuzhiyun  blocked       bitmap of blocked signals
360*4882a593Smuzhiyun  sigign        bitmap of ignored signals
361*4882a593Smuzhiyun  sigcatch      bitmap of caught signals
362*4882a593Smuzhiyun  0		(place holder, used to be the wchan address,
363*4882a593Smuzhiyun		use /proc/PID/wchan instead)
364*4882a593Smuzhiyun  0             (place holder)
365*4882a593Smuzhiyun  0             (place holder)
366*4882a593Smuzhiyun  exit_signal   signal to send to parent thread on exit
367*4882a593Smuzhiyun  task_cpu      which CPU the task is scheduled on
368*4882a593Smuzhiyun  rt_priority   realtime priority
369*4882a593Smuzhiyun  policy        scheduling policy (man sched_setscheduler)
370*4882a593Smuzhiyun  blkio_ticks   time spent waiting for block IO
371*4882a593Smuzhiyun  gtime         guest time of the task in jiffies
372*4882a593Smuzhiyun  cgtime        guest time of the task children in jiffies
373*4882a593Smuzhiyun  start_data    address above which program data+bss is placed
374*4882a593Smuzhiyun  end_data      address below which program data+bss is placed
375*4882a593Smuzhiyun  start_brk     address above which program heap can be expanded with brk()
376*4882a593Smuzhiyun  arg_start     address above which program command line is placed
377*4882a593Smuzhiyun  arg_end       address below which program command line is placed
378*4882a593Smuzhiyun  env_start     address above which program environment is placed
379*4882a593Smuzhiyun  env_end       address below which program environment is placed
380*4882a593Smuzhiyun  exit_code     the thread's exit_code in the form reported by the waitpid
381*4882a593Smuzhiyun		system call
382*4882a593Smuzhiyun  ============= ===============================================================
383*4882a593Smuzhiyun
384*4882a593SmuzhiyunThe /proc/PID/maps file contains the currently mapped memory regions and
385*4882a593Smuzhiyuntheir access permissions.
386*4882a593Smuzhiyun
387*4882a593SmuzhiyunThe format is::
388*4882a593Smuzhiyun
389*4882a593Smuzhiyun    address           perms offset  dev   inode      pathname
390*4882a593Smuzhiyun
391*4882a593Smuzhiyun    08048000-08049000 r-xp 00000000 03:00 8312       /opt/test
392*4882a593Smuzhiyun    08049000-0804a000 rw-p 00001000 03:00 8312       /opt/test
393*4882a593Smuzhiyun    0804a000-0806b000 rw-p 00000000 00:00 0          [heap]
394*4882a593Smuzhiyun    a7cb1000-a7cb2000 ---p 00000000 00:00 0
395*4882a593Smuzhiyun    a7cb2000-a7eb2000 rw-p 00000000 00:00 0
396*4882a593Smuzhiyun    a7eb2000-a7eb3000 ---p 00000000 00:00 0
397*4882a593Smuzhiyun    a7eb3000-a7ed5000 rw-p 00000000 00:00 0
398*4882a593Smuzhiyun    a7ed5000-a8008000 r-xp 00000000 03:00 4222       /lib/libc.so.6
399*4882a593Smuzhiyun    a8008000-a800a000 r--p 00133000 03:00 4222       /lib/libc.so.6
400*4882a593Smuzhiyun    a800a000-a800b000 rw-p 00135000 03:00 4222       /lib/libc.so.6
401*4882a593Smuzhiyun    a800b000-a800e000 rw-p 00000000 00:00 0
402*4882a593Smuzhiyun    a800e000-a8022000 r-xp 00000000 03:00 14462      /lib/libpthread.so.0
403*4882a593Smuzhiyun    a8022000-a8023000 r--p 00013000 03:00 14462      /lib/libpthread.so.0
404*4882a593Smuzhiyun    a8023000-a8024000 rw-p 00014000 03:00 14462      /lib/libpthread.so.0
405*4882a593Smuzhiyun    a8024000-a8027000 rw-p 00000000 00:00 0
406*4882a593Smuzhiyun    a8027000-a8043000 r-xp 00000000 03:00 8317       /lib/ld-linux.so.2
407*4882a593Smuzhiyun    a8043000-a8044000 r--p 0001b000 03:00 8317       /lib/ld-linux.so.2
408*4882a593Smuzhiyun    a8044000-a8045000 rw-p 0001c000 03:00 8317       /lib/ld-linux.so.2
409*4882a593Smuzhiyun    aff35000-aff4a000 rw-p 00000000 00:00 0          [stack]
410*4882a593Smuzhiyun    ffffe000-fffff000 r-xp 00000000 00:00 0          [vdso]
411*4882a593Smuzhiyun
412*4882a593Smuzhiyunwhere "address" is the address space in the process that it occupies, "perms"
413*4882a593Smuzhiyunis a set of permissions::
414*4882a593Smuzhiyun
415*4882a593Smuzhiyun r = read
416*4882a593Smuzhiyun w = write
417*4882a593Smuzhiyun x = execute
418*4882a593Smuzhiyun s = shared
419*4882a593Smuzhiyun p = private (copy on write)
420*4882a593Smuzhiyun
421*4882a593Smuzhiyun"offset" is the offset into the mapping, "dev" is the device (major:minor), and
422*4882a593Smuzhiyun"inode" is the inode  on that device.  0 indicates that  no inode is associated
423*4882a593Smuzhiyunwith the memory region, as the case would be with BSS (uninitialized data).
424*4882a593SmuzhiyunThe "pathname" shows the name associated file for this mapping.  If the mapping
425*4882a593Smuzhiyunis not associated with a file:
426*4882a593Smuzhiyun
427*4882a593Smuzhiyun =======                    ====================================
428*4882a593Smuzhiyun [heap]                     the heap of the program
429*4882a593Smuzhiyun [stack]                    the stack of the main process
430*4882a593Smuzhiyun [vdso]                     the "virtual dynamic shared object",
431*4882a593Smuzhiyun                            the kernel system call handler
432*4882a593Smuzhiyun [anon:<name>]              an anonymous mapping that has been
433*4882a593Smuzhiyun                            named by userspace
434*4882a593Smuzhiyun =======                    ====================================
435*4882a593Smuzhiyun
436*4882a593Smuzhiyun or if empty, the mapping is anonymous.
437*4882a593Smuzhiyun
438*4882a593SmuzhiyunThe /proc/PID/smaps is an extension based on maps, showing the memory
439*4882a593Smuzhiyunconsumption for each of the process's mappings. For each mapping (aka Virtual
440*4882a593SmuzhiyunMemory Area, or VMA) there is a series of lines such as the following::
441*4882a593Smuzhiyun
442*4882a593Smuzhiyun    08048000-080bc000 r-xp 00000000 03:02 13130      /bin/bash
443*4882a593Smuzhiyun
444*4882a593Smuzhiyun    Size:               1084 kB
445*4882a593Smuzhiyun    KernelPageSize:        4 kB
446*4882a593Smuzhiyun    MMUPageSize:           4 kB
447*4882a593Smuzhiyun    Rss:                 892 kB
448*4882a593Smuzhiyun    Pss:                 374 kB
449*4882a593Smuzhiyun    Shared_Clean:        892 kB
450*4882a593Smuzhiyun    Shared_Dirty:          0 kB
451*4882a593Smuzhiyun    Private_Clean:         0 kB
452*4882a593Smuzhiyun    Private_Dirty:         0 kB
453*4882a593Smuzhiyun    Referenced:          892 kB
454*4882a593Smuzhiyun    Anonymous:             0 kB
455*4882a593Smuzhiyun    LazyFree:              0 kB
456*4882a593Smuzhiyun    AnonHugePages:         0 kB
457*4882a593Smuzhiyun    ShmemPmdMapped:        0 kB
458*4882a593Smuzhiyun    Shared_Hugetlb:        0 kB
459*4882a593Smuzhiyun    Private_Hugetlb:       0 kB
460*4882a593Smuzhiyun    Swap:                  0 kB
461*4882a593Smuzhiyun    SwapPss:               0 kB
462*4882a593Smuzhiyun    KernelPageSize:        4 kB
463*4882a593Smuzhiyun    MMUPageSize:           4 kB
464*4882a593Smuzhiyun    Locked:                0 kB
465*4882a593Smuzhiyun    THPeligible:           0
466*4882a593Smuzhiyun    VmFlags: rd ex mr mw me dw
467*4882a593Smuzhiyun    Name: name from userspace
468*4882a593Smuzhiyun
469*4882a593SmuzhiyunThe first of these lines shows the same information as is displayed for the
470*4882a593Smuzhiyunmapping in /proc/PID/maps.  Following lines show the size of the mapping
471*4882a593Smuzhiyun(size); the size of each page allocated when backing a VMA (KernelPageSize),
472*4882a593Smuzhiyunwhich is usually the same as the size in the page table entries; the page size
473*4882a593Smuzhiyunused by the MMU when backing a VMA (in most cases, the same as KernelPageSize);
474*4882a593Smuzhiyunthe amount of the mapping that is currently resident in RAM (RSS); the
475*4882a593Smuzhiyunprocess' proportional share of this mapping (PSS); and the number of clean and
476*4882a593Smuzhiyundirty shared and private pages in the mapping.
477*4882a593Smuzhiyun
478*4882a593SmuzhiyunThe "proportional set size" (PSS) of a process is the count of pages it has
479*4882a593Smuzhiyunin memory, where each page is divided by the number of processes sharing it.
480*4882a593SmuzhiyunSo if a process has 1000 pages all to itself, and 1000 shared with one other
481*4882a593Smuzhiyunprocess, its PSS will be 1500.
482*4882a593Smuzhiyun
483*4882a593SmuzhiyunNote that even a page which is part of a MAP_SHARED mapping, but has only
484*4882a593Smuzhiyuna single pte mapped, i.e.  is currently used by only one process, is accounted
485*4882a593Smuzhiyunas private and not as shared.
486*4882a593Smuzhiyun
487*4882a593Smuzhiyun"Referenced" indicates the amount of memory currently marked as referenced or
488*4882a593Smuzhiyunaccessed.
489*4882a593Smuzhiyun
490*4882a593Smuzhiyun"Anonymous" shows the amount of memory that does not belong to any file.  Even
491*4882a593Smuzhiyuna mapping associated with a file may contain anonymous pages: when MAP_PRIVATE
492*4882a593Smuzhiyunand a page is modified, the file page is replaced by a private anonymous copy.
493*4882a593Smuzhiyun
494*4882a593Smuzhiyun"LazyFree" shows the amount of memory which is marked by madvise(MADV_FREE).
495*4882a593SmuzhiyunThe memory isn't freed immediately with madvise(). It's freed in memory
496*4882a593Smuzhiyunpressure if the memory is clean. Please note that the printed value might
497*4882a593Smuzhiyunbe lower than the real value due to optimizations used in the current
498*4882a593Smuzhiyunimplementation. If this is not desirable please file a bug report.
499*4882a593Smuzhiyun
500*4882a593Smuzhiyun"AnonHugePages" shows the ammount of memory backed by transparent hugepage.
501*4882a593Smuzhiyun
502*4882a593Smuzhiyun"ShmemPmdMapped" shows the ammount of shared (shmem/tmpfs) memory backed by
503*4882a593Smuzhiyunhuge pages.
504*4882a593Smuzhiyun
505*4882a593Smuzhiyun"Shared_Hugetlb" and "Private_Hugetlb" show the ammounts of memory backed by
506*4882a593Smuzhiyunhugetlbfs page which is *not* counted in "RSS" or "PSS" field for historical
507*4882a593Smuzhiyunreasons. And these are not included in {Shared,Private}_{Clean,Dirty} field.
508*4882a593Smuzhiyun
509*4882a593Smuzhiyun"Swap" shows how much would-be-anonymous memory is also used, but out on swap.
510*4882a593Smuzhiyun
511*4882a593SmuzhiyunFor shmem mappings, "Swap" includes also the size of the mapped (and not
512*4882a593Smuzhiyunreplaced by copy-on-write) part of the underlying shmem object out on swap.
513*4882a593Smuzhiyun"SwapPss" shows proportional swap share of this mapping. Unlike "Swap", this
514*4882a593Smuzhiyundoes not take into account swapped out page of underlying shmem objects.
515*4882a593Smuzhiyun"Locked" indicates whether the mapping is locked in memory or not.
516*4882a593Smuzhiyun"THPeligible" indicates whether the mapping is eligible for allocating THP
517*4882a593Smuzhiyunpages - 1 if true, 0 otherwise. It just shows the current status.
518*4882a593Smuzhiyun
519*4882a593Smuzhiyun"VmFlags" field deserves a separate description. This member represents the
520*4882a593Smuzhiyunkernel flags associated with the particular virtual memory area in two letter
521*4882a593Smuzhiyunencoded manner. The codes are the following:
522*4882a593Smuzhiyun
523*4882a593Smuzhiyun    ==    =======================================
524*4882a593Smuzhiyun    rd    readable
525*4882a593Smuzhiyun    wr    writeable
526*4882a593Smuzhiyun    ex    executable
527*4882a593Smuzhiyun    sh    shared
528*4882a593Smuzhiyun    mr    may read
529*4882a593Smuzhiyun    mw    may write
530*4882a593Smuzhiyun    me    may execute
531*4882a593Smuzhiyun    ms    may share
532*4882a593Smuzhiyun    gd    stack segment growns down
533*4882a593Smuzhiyun    pf    pure PFN range
534*4882a593Smuzhiyun    dw    disabled write to the mapped file
535*4882a593Smuzhiyun    lo    pages are locked in memory
536*4882a593Smuzhiyun    io    memory mapped I/O area
537*4882a593Smuzhiyun    sr    sequential read advise provided
538*4882a593Smuzhiyun    rr    random read advise provided
539*4882a593Smuzhiyun    dc    do not copy area on fork
540*4882a593Smuzhiyun    de    do not expand area on remapping
541*4882a593Smuzhiyun    ac    area is accountable
542*4882a593Smuzhiyun    nr    swap space is not reserved for the area
543*4882a593Smuzhiyun    ht    area uses huge tlb pages
544*4882a593Smuzhiyun    ar    architecture specific flag
545*4882a593Smuzhiyun    dd    do not include area into core dump
546*4882a593Smuzhiyun    sd    soft dirty flag
547*4882a593Smuzhiyun    mm    mixed map area
548*4882a593Smuzhiyun    hg    huge page advise flag
549*4882a593Smuzhiyun    nh    no huge page advise flag
550*4882a593Smuzhiyun    mg    mergable advise flag
551*4882a593Smuzhiyun    bt    arm64 BTI guarded page
552*4882a593Smuzhiyun    mt    arm64 MTE allocation tags are enabled
553*4882a593Smuzhiyun    ==    =======================================
554*4882a593Smuzhiyun
555*4882a593SmuzhiyunNote that there is no guarantee that every flag and associated mnemonic will
556*4882a593Smuzhiyunbe present in all further kernel releases. Things get changed, the flags may
557*4882a593Smuzhiyunbe vanished or the reverse -- new added. Interpretation of their meaning
558*4882a593Smuzhiyunmight change in future as well. So each consumer of these flags has to
559*4882a593Smuzhiyunfollow each specific kernel version for the exact semantic.
560*4882a593Smuzhiyun
561*4882a593SmuzhiyunThe "Name" field will only be present on a mapping that has been named by
562*4882a593Smuzhiyunuserspace, and will show the name passed in by userspace.
563*4882a593Smuzhiyun
564*4882a593SmuzhiyunThis file is only present if the CONFIG_MMU kernel configuration option is
565*4882a593Smuzhiyunenabled.
566*4882a593Smuzhiyun
567*4882a593SmuzhiyunNote: reading /proc/PID/maps or /proc/PID/smaps is inherently racy (consistent
568*4882a593Smuzhiyunoutput can be achieved only in the single read call).
569*4882a593Smuzhiyun
570*4882a593SmuzhiyunThis typically manifests when doing partial reads of these files while the
571*4882a593Smuzhiyunmemory map is being modified.  Despite the races, we do provide the following
572*4882a593Smuzhiyunguarantees:
573*4882a593Smuzhiyun
574*4882a593Smuzhiyun1) The mapped addresses never go backwards, which implies no two
575*4882a593Smuzhiyun   regions will ever overlap.
576*4882a593Smuzhiyun2) If there is something at a given vaddr during the entirety of the
577*4882a593Smuzhiyun   life of the smaps/maps walk, there will be some output for it.
578*4882a593Smuzhiyun
579*4882a593SmuzhiyunThe /proc/PID/smaps_rollup file includes the same fields as /proc/PID/smaps,
580*4882a593Smuzhiyunbut their values are the sums of the corresponding values for all mappings of
581*4882a593Smuzhiyunthe process.  Additionally, it contains these fields:
582*4882a593Smuzhiyun
583*4882a593Smuzhiyun- Pss_Anon
584*4882a593Smuzhiyun- Pss_File
585*4882a593Smuzhiyun- Pss_Shmem
586*4882a593Smuzhiyun
587*4882a593SmuzhiyunThey represent the proportional shares of anonymous, file, and shmem pages, as
588*4882a593Smuzhiyundescribed for smaps above.  These fields are omitted in smaps since each
589*4882a593Smuzhiyunmapping identifies the type (anon, file, or shmem) of all pages it contains.
590*4882a593SmuzhiyunThus all information in smaps_rollup can be derived from smaps, but at a
591*4882a593Smuzhiyunsignificantly higher cost.
592*4882a593Smuzhiyun
593*4882a593SmuzhiyunThe /proc/PID/clear_refs is used to reset the PG_Referenced and ACCESSED/YOUNG
594*4882a593Smuzhiyunbits on both physical and virtual pages associated with a process, and the
595*4882a593Smuzhiyunsoft-dirty bit on pte (see Documentation/admin-guide/mm/soft-dirty.rst
596*4882a593Smuzhiyunfor details).
597*4882a593SmuzhiyunTo clear the bits for all the pages associated with the process::
598*4882a593Smuzhiyun
599*4882a593Smuzhiyun    > echo 1 > /proc/PID/clear_refs
600*4882a593Smuzhiyun
601*4882a593SmuzhiyunTo clear the bits for the anonymous pages associated with the process::
602*4882a593Smuzhiyun
603*4882a593Smuzhiyun    > echo 2 > /proc/PID/clear_refs
604*4882a593Smuzhiyun
605*4882a593SmuzhiyunTo clear the bits for the file mapped pages associated with the process::
606*4882a593Smuzhiyun
607*4882a593Smuzhiyun    > echo 3 > /proc/PID/clear_refs
608*4882a593Smuzhiyun
609*4882a593SmuzhiyunTo clear the soft-dirty bit::
610*4882a593Smuzhiyun
611*4882a593Smuzhiyun    > echo 4 > /proc/PID/clear_refs
612*4882a593Smuzhiyun
613*4882a593SmuzhiyunTo reset the peak resident set size ("high water mark") to the process's
614*4882a593Smuzhiyuncurrent value::
615*4882a593Smuzhiyun
616*4882a593Smuzhiyun    > echo 5 > /proc/PID/clear_refs
617*4882a593Smuzhiyun
618*4882a593SmuzhiyunAny other value written to /proc/PID/clear_refs will have no effect.
619*4882a593Smuzhiyun
620*4882a593SmuzhiyunThe /proc/pid/pagemap gives the PFN, which can be used to find the pageflags
621*4882a593Smuzhiyunusing /proc/kpageflags and number of times a page is mapped using
622*4882a593Smuzhiyun/proc/kpagecount. For detailed explanation, see
623*4882a593SmuzhiyunDocumentation/admin-guide/mm/pagemap.rst.
624*4882a593Smuzhiyun
625*4882a593SmuzhiyunThe /proc/pid/numa_maps is an extension based on maps, showing the memory
626*4882a593Smuzhiyunlocality and binding policy, as well as the memory usage (in pages) of
627*4882a593Smuzhiyuneach mapping. The output follows a general format where mapping details get
628*4882a593Smuzhiyunsummarized separated by blank spaces, one mapping per each file line::
629*4882a593Smuzhiyun
630*4882a593Smuzhiyun    address   policy    mapping details
631*4882a593Smuzhiyun
632*4882a593Smuzhiyun    00400000 default file=/usr/local/bin/app mapped=1 active=0 N3=1 kernelpagesize_kB=4
633*4882a593Smuzhiyun    00600000 default file=/usr/local/bin/app anon=1 dirty=1 N3=1 kernelpagesize_kB=4
634*4882a593Smuzhiyun    3206000000 default file=/lib64/ld-2.12.so mapped=26 mapmax=6 N0=24 N3=2 kernelpagesize_kB=4
635*4882a593Smuzhiyun    320621f000 default file=/lib64/ld-2.12.so anon=1 dirty=1 N3=1 kernelpagesize_kB=4
636*4882a593Smuzhiyun    3206220000 default file=/lib64/ld-2.12.so anon=1 dirty=1 N3=1 kernelpagesize_kB=4
637*4882a593Smuzhiyun    3206221000 default anon=1 dirty=1 N3=1 kernelpagesize_kB=4
638*4882a593Smuzhiyun    3206800000 default file=/lib64/libc-2.12.so mapped=59 mapmax=21 active=55 N0=41 N3=18 kernelpagesize_kB=4
639*4882a593Smuzhiyun    320698b000 default file=/lib64/libc-2.12.so
640*4882a593Smuzhiyun    3206b8a000 default file=/lib64/libc-2.12.so anon=2 dirty=2 N3=2 kernelpagesize_kB=4
641*4882a593Smuzhiyun    3206b8e000 default file=/lib64/libc-2.12.so anon=1 dirty=1 N3=1 kernelpagesize_kB=4
642*4882a593Smuzhiyun    3206b8f000 default anon=3 dirty=3 active=1 N3=3 kernelpagesize_kB=4
643*4882a593Smuzhiyun    7f4dc10a2000 default anon=3 dirty=3 N3=3 kernelpagesize_kB=4
644*4882a593Smuzhiyun    7f4dc10b4000 default anon=2 dirty=2 active=1 N3=2 kernelpagesize_kB=4
645*4882a593Smuzhiyun    7f4dc1200000 default file=/anon_hugepage\040(deleted) huge anon=1 dirty=1 N3=1 kernelpagesize_kB=2048
646*4882a593Smuzhiyun    7fff335f0000 default stack anon=3 dirty=3 N3=3 kernelpagesize_kB=4
647*4882a593Smuzhiyun    7fff3369d000 default mapped=1 mapmax=35 active=0 N3=1 kernelpagesize_kB=4
648*4882a593Smuzhiyun
649*4882a593SmuzhiyunWhere:
650*4882a593Smuzhiyun
651*4882a593Smuzhiyun"address" is the starting address for the mapping;
652*4882a593Smuzhiyun
653*4882a593Smuzhiyun"policy" reports the NUMA memory policy set for the mapping (see Documentation/admin-guide/mm/numa_memory_policy.rst);
654*4882a593Smuzhiyun
655*4882a593Smuzhiyun"mapping details" summarizes mapping data such as mapping type, page usage counters,
656*4882a593Smuzhiyunnode locality page counters (N0 == node0, N1 == node1, ...) and the kernel page
657*4882a593Smuzhiyunsize, in KB, that is backing the mapping up.
658*4882a593Smuzhiyun
659*4882a593Smuzhiyun1.2 Kernel data
660*4882a593Smuzhiyun---------------
661*4882a593Smuzhiyun
662*4882a593SmuzhiyunSimilar to  the  process entries, the kernel data files give information about
663*4882a593Smuzhiyunthe running kernel. The files used to obtain this information are contained in
664*4882a593Smuzhiyun/proc and  are  listed  in Table 1-5. Not all of these will be present in your
665*4882a593Smuzhiyunsystem. It  depends  on the kernel configuration and the loaded modules, which
666*4882a593Smuzhiyunfiles are there, and which are missing.
667*4882a593Smuzhiyun
668*4882a593Smuzhiyun.. table:: Table 1-5: Kernel info in /proc
669*4882a593Smuzhiyun
670*4882a593Smuzhiyun ============ ===============================================================
671*4882a593Smuzhiyun File         Content
672*4882a593Smuzhiyun ============ ===============================================================
673*4882a593Smuzhiyun apm          Advanced power management info
674*4882a593Smuzhiyun buddyinfo    Kernel memory allocator information (see text)	(2.5)
675*4882a593Smuzhiyun bus          Directory containing bus specific information
676*4882a593Smuzhiyun cmdline      Kernel command line
677*4882a593Smuzhiyun cpuinfo      Info about the CPU
678*4882a593Smuzhiyun devices      Available devices (block and character)
679*4882a593Smuzhiyun dma          Used DMS channels
680*4882a593Smuzhiyun filesystems  Supported filesystems
681*4882a593Smuzhiyun driver       Various drivers grouped here, currently rtc	(2.4)
682*4882a593Smuzhiyun execdomains  Execdomains, related to security			(2.4)
683*4882a593Smuzhiyun fb 	      Frame Buffer devices				(2.4)
684*4882a593Smuzhiyun fs 	      File system parameters, currently nfs/exports	(2.4)
685*4882a593Smuzhiyun ide          Directory containing info about the IDE subsystem
686*4882a593Smuzhiyun interrupts   Interrupt usage
687*4882a593Smuzhiyun iomem 	      Memory map					(2.4)
688*4882a593Smuzhiyun ioports      I/O port usage
689*4882a593Smuzhiyun irq 	      Masks for irq to cpu affinity			(2.4)(smp?)
690*4882a593Smuzhiyun isapnp       ISA PnP (Plug&Play) Info				(2.4)
691*4882a593Smuzhiyun kcore        Kernel core image (can be ELF or A.OUT(deprecated in 2.4))
692*4882a593Smuzhiyun kmsg         Kernel messages
693*4882a593Smuzhiyun ksyms        Kernel symbol table
694*4882a593Smuzhiyun loadavg      Load average of last 1, 5 & 15 minutes
695*4882a593Smuzhiyun locks        Kernel locks
696*4882a593Smuzhiyun meminfo      Memory info
697*4882a593Smuzhiyun misc         Miscellaneous
698*4882a593Smuzhiyun modules      List of loaded modules
699*4882a593Smuzhiyun mounts       Mounted filesystems
700*4882a593Smuzhiyun net          Networking info (see text)
701*4882a593Smuzhiyun pagetypeinfo Additional page allocator information (see text)  (2.5)
702*4882a593Smuzhiyun partitions   Table of partitions known to the system
703*4882a593Smuzhiyun pci 	      Deprecated info of PCI bus (new way -> /proc/bus/pci/,
704*4882a593Smuzhiyun              decoupled by lspci				(2.4)
705*4882a593Smuzhiyun rtc          Real time clock
706*4882a593Smuzhiyun scsi         SCSI info (see text)
707*4882a593Smuzhiyun slabinfo     Slab pool info
708*4882a593Smuzhiyun softirqs     softirq usage
709*4882a593Smuzhiyun stat         Overall statistics
710*4882a593Smuzhiyun swaps        Swap space utilization
711*4882a593Smuzhiyun sys          See chapter 2
712*4882a593Smuzhiyun sysvipc      Info of SysVIPC Resources (msg, sem, shm)		(2.4)
713*4882a593Smuzhiyun tty 	      Info of tty drivers
714*4882a593Smuzhiyun uptime       Wall clock since boot, combined idle time of all cpus
715*4882a593Smuzhiyun version      Kernel version
716*4882a593Smuzhiyun video 	      bttv info of video resources			(2.4)
717*4882a593Smuzhiyun vmallocinfo  Show vmalloced areas
718*4882a593Smuzhiyun ============ ===============================================================
719*4882a593Smuzhiyun
720*4882a593SmuzhiyunYou can,  for  example,  check  which interrupts are currently in use and what
721*4882a593Smuzhiyunthey are used for by looking in the file /proc/interrupts::
722*4882a593Smuzhiyun
723*4882a593Smuzhiyun  > cat /proc/interrupts
724*4882a593Smuzhiyun             CPU0
725*4882a593Smuzhiyun    0:    8728810          XT-PIC  timer
726*4882a593Smuzhiyun    1:        895          XT-PIC  keyboard
727*4882a593Smuzhiyun    2:          0          XT-PIC  cascade
728*4882a593Smuzhiyun    3:     531695          XT-PIC  aha152x
729*4882a593Smuzhiyun    4:    2014133          XT-PIC  serial
730*4882a593Smuzhiyun    5:      44401          XT-PIC  pcnet_cs
731*4882a593Smuzhiyun    8:          2          XT-PIC  rtc
732*4882a593Smuzhiyun   11:          8          XT-PIC  i82365
733*4882a593Smuzhiyun   12:     182918          XT-PIC  PS/2 Mouse
734*4882a593Smuzhiyun   13:          1          XT-PIC  fpu
735*4882a593Smuzhiyun   14:    1232265          XT-PIC  ide0
736*4882a593Smuzhiyun   15:          7          XT-PIC  ide1
737*4882a593Smuzhiyun  NMI:          0
738*4882a593Smuzhiyun
739*4882a593SmuzhiyunIn 2.4.* a couple of lines where added to this file LOC & ERR (this time is the
740*4882a593Smuzhiyunoutput of a SMP machine)::
741*4882a593Smuzhiyun
742*4882a593Smuzhiyun  > cat /proc/interrupts
743*4882a593Smuzhiyun
744*4882a593Smuzhiyun             CPU0       CPU1
745*4882a593Smuzhiyun    0:    1243498    1214548    IO-APIC-edge  timer
746*4882a593Smuzhiyun    1:       8949       8958    IO-APIC-edge  keyboard
747*4882a593Smuzhiyun    2:          0          0          XT-PIC  cascade
748*4882a593Smuzhiyun    5:      11286      10161    IO-APIC-edge  soundblaster
749*4882a593Smuzhiyun    8:          1          0    IO-APIC-edge  rtc
750*4882a593Smuzhiyun    9:      27422      27407    IO-APIC-edge  3c503
751*4882a593Smuzhiyun   12:     113645     113873    IO-APIC-edge  PS/2 Mouse
752*4882a593Smuzhiyun   13:          0          0          XT-PIC  fpu
753*4882a593Smuzhiyun   14:      22491      24012    IO-APIC-edge  ide0
754*4882a593Smuzhiyun   15:       2183       2415    IO-APIC-edge  ide1
755*4882a593Smuzhiyun   17:      30564      30414   IO-APIC-level  eth0
756*4882a593Smuzhiyun   18:        177        164   IO-APIC-level  bttv
757*4882a593Smuzhiyun  NMI:    2457961    2457959
758*4882a593Smuzhiyun  LOC:    2457882    2457881
759*4882a593Smuzhiyun  ERR:       2155
760*4882a593Smuzhiyun
761*4882a593SmuzhiyunNMI is incremented in this case because every timer interrupt generates a NMI
762*4882a593Smuzhiyun(Non Maskable Interrupt) which is used by the NMI Watchdog to detect lockups.
763*4882a593Smuzhiyun
764*4882a593SmuzhiyunLOC is the local interrupt counter of the internal APIC of every CPU.
765*4882a593Smuzhiyun
766*4882a593SmuzhiyunERR is incremented in the case of errors in the IO-APIC bus (the bus that
767*4882a593Smuzhiyunconnects the CPUs in a SMP system. This means that an error has been detected,
768*4882a593Smuzhiyunthe IO-APIC automatically retry the transmission, so it should not be a big
769*4882a593Smuzhiyunproblem, but you should read the SMP-FAQ.
770*4882a593Smuzhiyun
771*4882a593SmuzhiyunIn 2.6.2* /proc/interrupts was expanded again.  This time the goal was for
772*4882a593Smuzhiyun/proc/interrupts to display every IRQ vector in use by the system, not
773*4882a593Smuzhiyunjust those considered 'most important'.  The new vectors are:
774*4882a593Smuzhiyun
775*4882a593SmuzhiyunTHR
776*4882a593Smuzhiyun  interrupt raised when a machine check threshold counter
777*4882a593Smuzhiyun  (typically counting ECC corrected errors of memory or cache) exceeds
778*4882a593Smuzhiyun  a configurable threshold.  Only available on some systems.
779*4882a593Smuzhiyun
780*4882a593SmuzhiyunTRM
781*4882a593Smuzhiyun  a thermal event interrupt occurs when a temperature threshold
782*4882a593Smuzhiyun  has been exceeded for the CPU.  This interrupt may also be generated
783*4882a593Smuzhiyun  when the temperature drops back to normal.
784*4882a593Smuzhiyun
785*4882a593SmuzhiyunSPU
786*4882a593Smuzhiyun  a spurious interrupt is some interrupt that was raised then lowered
787*4882a593Smuzhiyun  by some IO device before it could be fully processed by the APIC.  Hence
788*4882a593Smuzhiyun  the APIC sees the interrupt but does not know what device it came from.
789*4882a593Smuzhiyun  For this case the APIC will generate the interrupt with a IRQ vector
790*4882a593Smuzhiyun  of 0xff. This might also be generated by chipset bugs.
791*4882a593Smuzhiyun
792*4882a593SmuzhiyunRES, CAL, TLB
793*4882a593Smuzhiyun  rescheduling, call and TLB flush interrupts are
794*4882a593Smuzhiyun  sent from one CPU to another per the needs of the OS.  Typically,
795*4882a593Smuzhiyun  their statistics are used by kernel developers and interested users to
796*4882a593Smuzhiyun  determine the occurrence of interrupts of the given type.
797*4882a593Smuzhiyun
798*4882a593SmuzhiyunThe above IRQ vectors are displayed only when relevant.  For example,
799*4882a593Smuzhiyunthe threshold vector does not exist on x86_64 platforms.  Others are
800*4882a593Smuzhiyunsuppressed when the system is a uniprocessor.  As of this writing, only
801*4882a593Smuzhiyuni386 and x86_64 platforms support the new IRQ vector displays.
802*4882a593Smuzhiyun
803*4882a593SmuzhiyunOf some interest is the introduction of the /proc/irq directory to 2.4.
804*4882a593SmuzhiyunIt could be used to set IRQ to CPU affinity. This means that you can "hook" an
805*4882a593SmuzhiyunIRQ to only one CPU, or to exclude a CPU of handling IRQs. The contents of the
806*4882a593Smuzhiyunirq subdir is one subdir for each IRQ, and two files; default_smp_affinity and
807*4882a593Smuzhiyunprof_cpu_mask.
808*4882a593Smuzhiyun
809*4882a593SmuzhiyunFor example::
810*4882a593Smuzhiyun
811*4882a593Smuzhiyun  > ls /proc/irq/
812*4882a593Smuzhiyun  0  10  12  14  16  18  2  4  6  8  prof_cpu_mask
813*4882a593Smuzhiyun  1  11  13  15  17  19  3  5  7  9  default_smp_affinity
814*4882a593Smuzhiyun  > ls /proc/irq/0/
815*4882a593Smuzhiyun  smp_affinity
816*4882a593Smuzhiyun
817*4882a593Smuzhiyunsmp_affinity is a bitmask, in which you can specify which CPUs can handle the
818*4882a593SmuzhiyunIRQ. You can set it by doing::
819*4882a593Smuzhiyun
820*4882a593Smuzhiyun  > echo 1 > /proc/irq/10/smp_affinity
821*4882a593Smuzhiyun
822*4882a593SmuzhiyunThis means that only the first CPU will handle the IRQ, but you can also echo
823*4882a593Smuzhiyun5 which means that only the first and third CPU can handle the IRQ.
824*4882a593Smuzhiyun
825*4882a593SmuzhiyunThe contents of each smp_affinity file is the same by default::
826*4882a593Smuzhiyun
827*4882a593Smuzhiyun  > cat /proc/irq/0/smp_affinity
828*4882a593Smuzhiyun  ffffffff
829*4882a593Smuzhiyun
830*4882a593SmuzhiyunThere is an alternate interface, smp_affinity_list which allows specifying
831*4882a593Smuzhiyuna CPU range instead of a bitmask::
832*4882a593Smuzhiyun
833*4882a593Smuzhiyun  > cat /proc/irq/0/smp_affinity_list
834*4882a593Smuzhiyun  1024-1031
835*4882a593Smuzhiyun
836*4882a593SmuzhiyunThe default_smp_affinity mask applies to all non-active IRQs, which are the
837*4882a593SmuzhiyunIRQs which have not yet been allocated/activated, and hence which lack a
838*4882a593Smuzhiyun/proc/irq/[0-9]* directory.
839*4882a593Smuzhiyun
840*4882a593SmuzhiyunThe node file on an SMP system shows the node to which the device using the IRQ
841*4882a593Smuzhiyunreports itself as being attached. This hardware locality information does not
842*4882a593Smuzhiyuninclude information about any possible driver locality preference.
843*4882a593Smuzhiyun
844*4882a593Smuzhiyunprof_cpu_mask specifies which CPUs are to be profiled by the system wide
845*4882a593Smuzhiyunprofiler. Default value is ffffffff (all CPUs if there are only 32 of them).
846*4882a593Smuzhiyun
847*4882a593SmuzhiyunThe way IRQs are routed is handled by the IO-APIC, and it's Round Robin
848*4882a593Smuzhiyunbetween all the CPUs which are allowed to handle it. As usual the kernel has
849*4882a593Smuzhiyunmore info than you and does a better job than you, so the defaults are the
850*4882a593Smuzhiyunbest choice for almost everyone.  [Note this applies only to those IO-APIC's
851*4882a593Smuzhiyunthat support "Round Robin" interrupt distribution.]
852*4882a593Smuzhiyun
853*4882a593SmuzhiyunThere are  three  more  important subdirectories in /proc: net, scsi, and sys.
854*4882a593SmuzhiyunThe general  rule  is  that  the  contents,  or  even  the  existence of these
855*4882a593Smuzhiyundirectories, depend  on your kernel configuration. If SCSI is not enabled, the
856*4882a593Smuzhiyundirectory scsi  may  not  exist. The same is true with the net, which is there
857*4882a593Smuzhiyunonly when networking support is present in the running kernel.
858*4882a593Smuzhiyun
859*4882a593SmuzhiyunThe slabinfo  file  gives  information  about  memory usage at the slab level.
860*4882a593SmuzhiyunLinux uses  slab  pools for memory management above page level in version 2.2.
861*4882a593SmuzhiyunCommonly used  objects  have  their  own  slab  pool (such as network buffers,
862*4882a593Smuzhiyundirectory cache, and so on).
863*4882a593Smuzhiyun
864*4882a593Smuzhiyun::
865*4882a593Smuzhiyun
866*4882a593Smuzhiyun    > cat /proc/buddyinfo
867*4882a593Smuzhiyun
868*4882a593Smuzhiyun    Node 0, zone      DMA      0      4      5      4      4      3 ...
869*4882a593Smuzhiyun    Node 0, zone   Normal      1      0      0      1    101      8 ...
870*4882a593Smuzhiyun    Node 0, zone  HighMem      2      0      0      1      1      0 ...
871*4882a593Smuzhiyun
872*4882a593SmuzhiyunExternal fragmentation is a problem under some workloads, and buddyinfo is a
873*4882a593Smuzhiyunuseful tool for helping diagnose these problems.  Buddyinfo will give you a
874*4882a593Smuzhiyunclue as to how big an area you can safely allocate, or why a previous
875*4882a593Smuzhiyunallocation failed.
876*4882a593Smuzhiyun
877*4882a593SmuzhiyunEach column represents the number of pages of a certain order which are
878*4882a593Smuzhiyunavailable.  In this case, there are 0 chunks of 2^0*PAGE_SIZE available in
879*4882a593SmuzhiyunZONE_DMA, 4 chunks of 2^1*PAGE_SIZE in ZONE_DMA, 101 chunks of 2^4*PAGE_SIZE
880*4882a593Smuzhiyunavailable in ZONE_NORMAL, etc...
881*4882a593Smuzhiyun
882*4882a593SmuzhiyunMore information relevant to external fragmentation can be found in
883*4882a593Smuzhiyunpagetypeinfo::
884*4882a593Smuzhiyun
885*4882a593Smuzhiyun    > cat /proc/pagetypeinfo
886*4882a593Smuzhiyun    Page block order: 9
887*4882a593Smuzhiyun    Pages per block:  512
888*4882a593Smuzhiyun
889*4882a593Smuzhiyun    Free pages count per migrate type at order       0      1      2      3      4      5      6      7      8      9     10
890*4882a593Smuzhiyun    Node    0, zone      DMA, type    Unmovable      0      0      0      1      1      1      1      1      1      1      0
891*4882a593Smuzhiyun    Node    0, zone      DMA, type  Reclaimable      0      0      0      0      0      0      0      0      0      0      0
892*4882a593Smuzhiyun    Node    0, zone      DMA, type      Movable      1      1      2      1      2      1      1      0      1      0      2
893*4882a593Smuzhiyun    Node    0, zone      DMA, type      Reserve      0      0      0      0      0      0      0      0      0      1      0
894*4882a593Smuzhiyun    Node    0, zone      DMA, type      Isolate      0      0      0      0      0      0      0      0      0      0      0
895*4882a593Smuzhiyun    Node    0, zone    DMA32, type    Unmovable    103     54     77      1      1      1     11      8      7      1      9
896*4882a593Smuzhiyun    Node    0, zone    DMA32, type  Reclaimable      0      0      2      1      0      0      0      0      1      0      0
897*4882a593Smuzhiyun    Node    0, zone    DMA32, type      Movable    169    152    113     91     77     54     39     13      6      1    452
898*4882a593Smuzhiyun    Node    0, zone    DMA32, type      Reserve      1      2      2      2      2      0      1      1      1      1      0
899*4882a593Smuzhiyun    Node    0, zone    DMA32, type      Isolate      0      0      0      0      0      0      0      0      0      0      0
900*4882a593Smuzhiyun
901*4882a593Smuzhiyun    Number of blocks type     Unmovable  Reclaimable      Movable      Reserve      Isolate
902*4882a593Smuzhiyun    Node 0, zone      DMA            2            0            5            1            0
903*4882a593Smuzhiyun    Node 0, zone    DMA32           41            6          967            2            0
904*4882a593Smuzhiyun
905*4882a593SmuzhiyunFragmentation avoidance in the kernel works by grouping pages of different
906*4882a593Smuzhiyunmigrate types into the same contiguous regions of memory called page blocks.
907*4882a593SmuzhiyunA page block is typically the size of the default hugepage size, e.g. 2MB on
908*4882a593SmuzhiyunX86-64. By keeping pages grouped based on their ability to move, the kernel
909*4882a593Smuzhiyuncan reclaim pages within a page block to satisfy a high-order allocation.
910*4882a593Smuzhiyun
911*4882a593SmuzhiyunThe pagetypinfo begins with information on the size of a page block. It
912*4882a593Smuzhiyunthen gives the same type of information as buddyinfo except broken down
913*4882a593Smuzhiyunby migrate-type and finishes with details on how many page blocks of each
914*4882a593Smuzhiyuntype exist.
915*4882a593Smuzhiyun
916*4882a593SmuzhiyunIf min_free_kbytes has been tuned correctly (recommendations made by hugeadm
917*4882a593Smuzhiyunfrom libhugetlbfs https://github.com/libhugetlbfs/libhugetlbfs/), one can
918*4882a593Smuzhiyunmake an estimate of the likely number of huge pages that can be allocated
919*4882a593Smuzhiyunat a given point in time. All the "Movable" blocks should be allocatable
920*4882a593Smuzhiyununless memory has been mlock()'d. Some of the Reclaimable blocks should
921*4882a593Smuzhiyunalso be allocatable although a lot of filesystem metadata may have to be
922*4882a593Smuzhiyunreclaimed to achieve this.
923*4882a593Smuzhiyun
924*4882a593Smuzhiyun
925*4882a593Smuzhiyunmeminfo
926*4882a593Smuzhiyun~~~~~~~
927*4882a593Smuzhiyun
928*4882a593SmuzhiyunProvides information about distribution and utilization of memory.  This
929*4882a593Smuzhiyunvaries by architecture and compile options.  The following is from a
930*4882a593Smuzhiyun16GB PIII, which has highmem enabled.  You may not have all of these fields.
931*4882a593Smuzhiyun
932*4882a593Smuzhiyun::
933*4882a593Smuzhiyun
934*4882a593Smuzhiyun    > cat /proc/meminfo
935*4882a593Smuzhiyun
936*4882a593Smuzhiyun    MemTotal:     16344972 kB
937*4882a593Smuzhiyun    MemFree:      13634064 kB
938*4882a593Smuzhiyun    MemAvailable: 14836172 kB
939*4882a593Smuzhiyun    Buffers:          3656 kB
940*4882a593Smuzhiyun    Cached:        1195708 kB
941*4882a593Smuzhiyun    SwapCached:          0 kB
942*4882a593Smuzhiyun    Active:         891636 kB
943*4882a593Smuzhiyun    Inactive:      1077224 kB
944*4882a593Smuzhiyun    HighTotal:    15597528 kB
945*4882a593Smuzhiyun    HighFree:     13629632 kB
946*4882a593Smuzhiyun    LowTotal:       747444 kB
947*4882a593Smuzhiyun    LowFree:          4432 kB
948*4882a593Smuzhiyun    SwapTotal:           0 kB
949*4882a593Smuzhiyun    SwapFree:            0 kB
950*4882a593Smuzhiyun    Dirty:             968 kB
951*4882a593Smuzhiyun    Writeback:           0 kB
952*4882a593Smuzhiyun    AnonPages:      861800 kB
953*4882a593Smuzhiyun    Mapped:         280372 kB
954*4882a593Smuzhiyun    Shmem:             644 kB
955*4882a593Smuzhiyun    KReclaimable:   168048 kB
956*4882a593Smuzhiyun    Slab:           284364 kB
957*4882a593Smuzhiyun    SReclaimable:   159856 kB
958*4882a593Smuzhiyun    SUnreclaim:     124508 kB
959*4882a593Smuzhiyun    PageTables:      24448 kB
960*4882a593Smuzhiyun    NFS_Unstable:        0 kB
961*4882a593Smuzhiyun    Bounce:              0 kB
962*4882a593Smuzhiyun    WritebackTmp:        0 kB
963*4882a593Smuzhiyun    CommitLimit:   7669796 kB
964*4882a593Smuzhiyun    Committed_AS:   100056 kB
965*4882a593Smuzhiyun    VmallocTotal:   112216 kB
966*4882a593Smuzhiyun    VmallocUsed:       428 kB
967*4882a593Smuzhiyun    VmallocChunk:   111088 kB
968*4882a593Smuzhiyun    Percpu:          62080 kB
969*4882a593Smuzhiyun    HardwareCorrupted:   0 kB
970*4882a593Smuzhiyun    AnonHugePages:   49152 kB
971*4882a593Smuzhiyun    ShmemHugePages:      0 kB
972*4882a593Smuzhiyun    ShmemPmdMapped:      0 kB
973*4882a593Smuzhiyun
974*4882a593SmuzhiyunMemTotal
975*4882a593Smuzhiyun              Total usable RAM (i.e. physical RAM minus a few reserved
976*4882a593Smuzhiyun              bits and the kernel binary code)
977*4882a593SmuzhiyunMemFree
978*4882a593Smuzhiyun              The sum of LowFree+HighFree
979*4882a593SmuzhiyunMemAvailable
980*4882a593Smuzhiyun              An estimate of how much memory is available for starting new
981*4882a593Smuzhiyun              applications, without swapping. Calculated from MemFree,
982*4882a593Smuzhiyun              SReclaimable, the size of the file LRU lists, and the low
983*4882a593Smuzhiyun              watermarks in each zone.
984*4882a593Smuzhiyun              The estimate takes into account that the system needs some
985*4882a593Smuzhiyun              page cache to function well, and that not all reclaimable
986*4882a593Smuzhiyun              slab will be reclaimable, due to items being in use. The
987*4882a593Smuzhiyun              impact of those factors will vary from system to system.
988*4882a593SmuzhiyunBuffers
989*4882a593Smuzhiyun              Relatively temporary storage for raw disk blocks
990*4882a593Smuzhiyun              shouldn't get tremendously large (20MB or so)
991*4882a593SmuzhiyunCached
992*4882a593Smuzhiyun              in-memory cache for files read from the disk (the
993*4882a593Smuzhiyun              pagecache).  Doesn't include SwapCached
994*4882a593SmuzhiyunSwapCached
995*4882a593Smuzhiyun              Memory that once was swapped out, is swapped back in but
996*4882a593Smuzhiyun              still also is in the swapfile (if memory is needed it
997*4882a593Smuzhiyun              doesn't need to be swapped out AGAIN because it is already
998*4882a593Smuzhiyun              in the swapfile. This saves I/O)
999*4882a593SmuzhiyunActive
1000*4882a593Smuzhiyun              Memory that has been used more recently and usually not
1001*4882a593Smuzhiyun              reclaimed unless absolutely necessary.
1002*4882a593SmuzhiyunInactive
1003*4882a593Smuzhiyun              Memory which has been less recently used.  It is more
1004*4882a593Smuzhiyun              eligible to be reclaimed for other purposes
1005*4882a593SmuzhiyunHighTotal, HighFree
1006*4882a593Smuzhiyun              Highmem is all memory above ~860MB of physical memory.
1007*4882a593Smuzhiyun              Highmem areas are for use by userspace programs, or
1008*4882a593Smuzhiyun              for the pagecache.  The kernel must use tricks to access
1009*4882a593Smuzhiyun              this memory, making it slower to access than lowmem.
1010*4882a593SmuzhiyunLowTotal, LowFree
1011*4882a593Smuzhiyun              Lowmem is memory which can be used for everything that
1012*4882a593Smuzhiyun              highmem can be used for, but it is also available for the
1013*4882a593Smuzhiyun              kernel's use for its own data structures.  Among many
1014*4882a593Smuzhiyun              other things, it is where everything from the Slab is
1015*4882a593Smuzhiyun              allocated.  Bad things happen when you're out of lowmem.
1016*4882a593SmuzhiyunSwapTotal
1017*4882a593Smuzhiyun              total amount of swap space available
1018*4882a593SmuzhiyunSwapFree
1019*4882a593Smuzhiyun              Memory which has been evicted from RAM, and is temporarily
1020*4882a593Smuzhiyun              on the disk
1021*4882a593SmuzhiyunDirty
1022*4882a593Smuzhiyun              Memory which is waiting to get written back to the disk
1023*4882a593SmuzhiyunWriteback
1024*4882a593Smuzhiyun              Memory which is actively being written back to the disk
1025*4882a593SmuzhiyunAnonPages
1026*4882a593Smuzhiyun              Non-file backed pages mapped into userspace page tables
1027*4882a593SmuzhiyunHardwareCorrupted
1028*4882a593Smuzhiyun              The amount of RAM/memory in KB, the kernel identifies as
1029*4882a593Smuzhiyun	      corrupted.
1030*4882a593SmuzhiyunAnonHugePages
1031*4882a593Smuzhiyun              Non-file backed huge pages mapped into userspace page tables
1032*4882a593SmuzhiyunMapped
1033*4882a593Smuzhiyun              files which have been mmaped, such as libraries
1034*4882a593SmuzhiyunShmem
1035*4882a593Smuzhiyun              Total memory used by shared memory (shmem) and tmpfs
1036*4882a593SmuzhiyunShmemHugePages
1037*4882a593Smuzhiyun              Memory used by shared memory (shmem) and tmpfs allocated
1038*4882a593Smuzhiyun              with huge pages
1039*4882a593SmuzhiyunShmemPmdMapped
1040*4882a593Smuzhiyun              Shared memory mapped into userspace with huge pages
1041*4882a593SmuzhiyunKReclaimable
1042*4882a593Smuzhiyun              Kernel allocations that the kernel will attempt to reclaim
1043*4882a593Smuzhiyun              under memory pressure. Includes SReclaimable (below), and other
1044*4882a593Smuzhiyun              direct allocations with a shrinker.
1045*4882a593SmuzhiyunSlab
1046*4882a593Smuzhiyun              in-kernel data structures cache
1047*4882a593SmuzhiyunSReclaimable
1048*4882a593Smuzhiyun              Part of Slab, that might be reclaimed, such as caches
1049*4882a593SmuzhiyunSUnreclaim
1050*4882a593Smuzhiyun              Part of Slab, that cannot be reclaimed on memory pressure
1051*4882a593SmuzhiyunPageTables
1052*4882a593Smuzhiyun              amount of memory dedicated to the lowest level of page
1053*4882a593Smuzhiyun              tables.
1054*4882a593SmuzhiyunNFS_Unstable
1055*4882a593Smuzhiyun              Always zero. Previous counted pages which had been written to
1056*4882a593Smuzhiyun              the server, but has not been committed to stable storage.
1057*4882a593SmuzhiyunBounce
1058*4882a593Smuzhiyun              Memory used for block device "bounce buffers"
1059*4882a593SmuzhiyunWritebackTmp
1060*4882a593Smuzhiyun              Memory used by FUSE for temporary writeback buffers
1061*4882a593SmuzhiyunCommitLimit
1062*4882a593Smuzhiyun              Based on the overcommit ratio ('vm.overcommit_ratio'),
1063*4882a593Smuzhiyun              this is the total amount of  memory currently available to
1064*4882a593Smuzhiyun              be allocated on the system. This limit is only adhered to
1065*4882a593Smuzhiyun              if strict overcommit accounting is enabled (mode 2 in
1066*4882a593Smuzhiyun              'vm.overcommit_memory').
1067*4882a593Smuzhiyun
1068*4882a593Smuzhiyun              The CommitLimit is calculated with the following formula::
1069*4882a593Smuzhiyun
1070*4882a593Smuzhiyun                CommitLimit = ([total RAM pages] - [total huge TLB pages]) *
1071*4882a593Smuzhiyun                               overcommit_ratio / 100 + [total swap pages]
1072*4882a593Smuzhiyun
1073*4882a593Smuzhiyun              For example, on a system with 1G of physical RAM and 7G
1074*4882a593Smuzhiyun              of swap with a `vm.overcommit_ratio` of 30 it would
1075*4882a593Smuzhiyun              yield a CommitLimit of 7.3G.
1076*4882a593Smuzhiyun
1077*4882a593Smuzhiyun              For more details, see the memory overcommit documentation
1078*4882a593Smuzhiyun              in vm/overcommit-accounting.
1079*4882a593SmuzhiyunCommitted_AS
1080*4882a593Smuzhiyun              The amount of memory presently allocated on the system.
1081*4882a593Smuzhiyun              The committed memory is a sum of all of the memory which
1082*4882a593Smuzhiyun              has been allocated by processes, even if it has not been
1083*4882a593Smuzhiyun              "used" by them as of yet. A process which malloc()'s 1G
1084*4882a593Smuzhiyun              of memory, but only touches 300M of it will show up as
1085*4882a593Smuzhiyun	      using 1G. This 1G is memory which has been "committed" to
1086*4882a593Smuzhiyun              by the VM and can be used at any time by the allocating
1087*4882a593Smuzhiyun              application. With strict overcommit enabled on the system
1088*4882a593Smuzhiyun              (mode 2 in 'vm.overcommit_memory'), allocations which would
1089*4882a593Smuzhiyun              exceed the CommitLimit (detailed above) will not be permitted.
1090*4882a593Smuzhiyun              This is useful if one needs to guarantee that processes will
1091*4882a593Smuzhiyun              not fail due to lack of memory once that memory has been
1092*4882a593Smuzhiyun              successfully allocated.
1093*4882a593SmuzhiyunVmallocTotal
1094*4882a593Smuzhiyun              total size of vmalloc memory area
1095*4882a593SmuzhiyunVmallocUsed
1096*4882a593Smuzhiyun              amount of vmalloc area which is used
1097*4882a593SmuzhiyunVmallocChunk
1098*4882a593Smuzhiyun              largest contiguous block of vmalloc area which is free
1099*4882a593SmuzhiyunPercpu
1100*4882a593Smuzhiyun              Memory allocated to the percpu allocator used to back percpu
1101*4882a593Smuzhiyun              allocations. This stat excludes the cost of metadata.
1102*4882a593Smuzhiyun
1103*4882a593Smuzhiyunvmallocinfo
1104*4882a593Smuzhiyun~~~~~~~~~~~
1105*4882a593Smuzhiyun
1106*4882a593SmuzhiyunProvides information about vmalloced/vmaped areas. One line per area,
1107*4882a593Smuzhiyuncontaining the virtual address range of the area, size in bytes,
1108*4882a593Smuzhiyuncaller information of the creator, and optional information depending
1109*4882a593Smuzhiyunon the kind of area:
1110*4882a593Smuzhiyun
1111*4882a593Smuzhiyun ==========  ===================================================
1112*4882a593Smuzhiyun pages=nr    number of pages
1113*4882a593Smuzhiyun phys=addr   if a physical address was specified
1114*4882a593Smuzhiyun ioremap     I/O mapping (ioremap() and friends)
1115*4882a593Smuzhiyun vmalloc     vmalloc() area
1116*4882a593Smuzhiyun vmap        vmap()ed pages
1117*4882a593Smuzhiyun user        VM_USERMAP area
1118*4882a593Smuzhiyun vpages      buffer for pages pointers was vmalloced (huge area)
1119*4882a593Smuzhiyun N<node>=nr  (Only on NUMA kernels)
1120*4882a593Smuzhiyun             Number of pages allocated on memory node <node>
1121*4882a593Smuzhiyun ==========  ===================================================
1122*4882a593Smuzhiyun
1123*4882a593Smuzhiyun::
1124*4882a593Smuzhiyun
1125*4882a593Smuzhiyun    > cat /proc/vmallocinfo
1126*4882a593Smuzhiyun    0xffffc20000000000-0xffffc20000201000 2101248 alloc_large_system_hash+0x204 ...
1127*4882a593Smuzhiyun    /0x2c0 pages=512 vmalloc N0=128 N1=128 N2=128 N3=128
1128*4882a593Smuzhiyun    0xffffc20000201000-0xffffc20000302000 1052672 alloc_large_system_hash+0x204 ...
1129*4882a593Smuzhiyun    /0x2c0 pages=256 vmalloc N0=64 N1=64 N2=64 N3=64
1130*4882a593Smuzhiyun    0xffffc20000302000-0xffffc20000304000    8192 acpi_tb_verify_table+0x21/0x4f...
1131*4882a593Smuzhiyun    phys=7fee8000 ioremap
1132*4882a593Smuzhiyun    0xffffc20000304000-0xffffc20000307000   12288 acpi_tb_verify_table+0x21/0x4f...
1133*4882a593Smuzhiyun    phys=7fee7000 ioremap
1134*4882a593Smuzhiyun    0xffffc2000031d000-0xffffc2000031f000    8192 init_vdso_vars+0x112/0x210
1135*4882a593Smuzhiyun    0xffffc2000031f000-0xffffc2000032b000   49152 cramfs_uncompress_init+0x2e ...
1136*4882a593Smuzhiyun    /0x80 pages=11 vmalloc N0=3 N1=3 N2=2 N3=3
1137*4882a593Smuzhiyun    0xffffc2000033a000-0xffffc2000033d000   12288 sys_swapon+0x640/0xac0      ...
1138*4882a593Smuzhiyun    pages=2 vmalloc N1=2
1139*4882a593Smuzhiyun    0xffffc20000347000-0xffffc2000034c000   20480 xt_alloc_table_info+0xfe ...
1140*4882a593Smuzhiyun    /0x130 [x_tables] pages=4 vmalloc N0=4
1141*4882a593Smuzhiyun    0xffffffffa0000000-0xffffffffa000f000   61440 sys_init_module+0xc27/0x1d00 ...
1142*4882a593Smuzhiyun    pages=14 vmalloc N2=14
1143*4882a593Smuzhiyun    0xffffffffa000f000-0xffffffffa0014000   20480 sys_init_module+0xc27/0x1d00 ...
1144*4882a593Smuzhiyun    pages=4 vmalloc N1=4
1145*4882a593Smuzhiyun    0xffffffffa0014000-0xffffffffa0017000   12288 sys_init_module+0xc27/0x1d00 ...
1146*4882a593Smuzhiyun    pages=2 vmalloc N1=2
1147*4882a593Smuzhiyun    0xffffffffa0017000-0xffffffffa0022000   45056 sys_init_module+0xc27/0x1d00 ...
1148*4882a593Smuzhiyun    pages=10 vmalloc N0=10
1149*4882a593Smuzhiyun
1150*4882a593Smuzhiyun
1151*4882a593Smuzhiyunsoftirqs
1152*4882a593Smuzhiyun~~~~~~~~
1153*4882a593Smuzhiyun
1154*4882a593SmuzhiyunProvides counts of softirq handlers serviced since boot time, for each CPU.
1155*4882a593Smuzhiyun
1156*4882a593Smuzhiyun::
1157*4882a593Smuzhiyun
1158*4882a593Smuzhiyun    > cat /proc/softirqs
1159*4882a593Smuzhiyun		  CPU0       CPU1       CPU2       CPU3
1160*4882a593Smuzhiyun	HI:          0          0          0          0
1161*4882a593Smuzhiyun    TIMER:       27166      27120      27097      27034
1162*4882a593Smuzhiyun    NET_TX:          0          0          0         17
1163*4882a593Smuzhiyun    NET_RX:         42          0          0         39
1164*4882a593Smuzhiyun    BLOCK:           0          0        107       1121
1165*4882a593Smuzhiyun    TASKLET:         0          0          0        290
1166*4882a593Smuzhiyun    SCHED:       27035      26983      26971      26746
1167*4882a593Smuzhiyun    HRTIMER:         0          0          0          0
1168*4882a593Smuzhiyun	RCU:      1678       1769       2178       2250
1169*4882a593Smuzhiyun
1170*4882a593Smuzhiyun
1171*4882a593Smuzhiyun1.3 IDE devices in /proc/ide
1172*4882a593Smuzhiyun----------------------------
1173*4882a593Smuzhiyun
1174*4882a593SmuzhiyunThe subdirectory /proc/ide contains information about all IDE devices of which
1175*4882a593Smuzhiyunthe kernel  is  aware.  There is one subdirectory for each IDE controller, the
1176*4882a593Smuzhiyunfile drivers  and a link for each IDE device, pointing to the device directory
1177*4882a593Smuzhiyunin the controller specific subtree.
1178*4882a593Smuzhiyun
1179*4882a593SmuzhiyunThe file 'drivers' contains general information about the drivers used for the
1180*4882a593SmuzhiyunIDE devices::
1181*4882a593Smuzhiyun
1182*4882a593Smuzhiyun  > cat /proc/ide/drivers
1183*4882a593Smuzhiyun  ide-cdrom version 4.53
1184*4882a593Smuzhiyun  ide-disk version 1.08
1185*4882a593Smuzhiyun
1186*4882a593SmuzhiyunMore detailed  information  can  be  found  in  the  controller  specific
1187*4882a593Smuzhiyunsubdirectories. These  are  named  ide0,  ide1  and  so  on.  Each  of  these
1188*4882a593Smuzhiyundirectories contains the files shown in table 1-6.
1189*4882a593Smuzhiyun
1190*4882a593Smuzhiyun
1191*4882a593Smuzhiyun.. table:: Table 1-6: IDE controller info in  /proc/ide/ide?
1192*4882a593Smuzhiyun
1193*4882a593Smuzhiyun ======= =======================================
1194*4882a593Smuzhiyun File    Content
1195*4882a593Smuzhiyun ======= =======================================
1196*4882a593Smuzhiyun channel IDE channel (0 or 1)
1197*4882a593Smuzhiyun config  Configuration (only for PCI/IDE bridge)
1198*4882a593Smuzhiyun mate    Mate name
1199*4882a593Smuzhiyun model   Type/Chipset of IDE controller
1200*4882a593Smuzhiyun ======= =======================================
1201*4882a593Smuzhiyun
1202*4882a593SmuzhiyunEach device  connected  to  a  controller  has  a separate subdirectory in the
1203*4882a593Smuzhiyuncontrollers directory.  The  files  listed in table 1-7 are contained in these
1204*4882a593Smuzhiyundirectories.
1205*4882a593Smuzhiyun
1206*4882a593Smuzhiyun
1207*4882a593Smuzhiyun.. table:: Table 1-7: IDE device information
1208*4882a593Smuzhiyun
1209*4882a593Smuzhiyun ================ ==========================================
1210*4882a593Smuzhiyun File             Content
1211*4882a593Smuzhiyun ================ ==========================================
1212*4882a593Smuzhiyun cache            The cache
1213*4882a593Smuzhiyun capacity         Capacity of the medium (in 512Byte blocks)
1214*4882a593Smuzhiyun driver           driver and version
1215*4882a593Smuzhiyun geometry         physical and logical geometry
1216*4882a593Smuzhiyun identify         device identify block
1217*4882a593Smuzhiyun media            media type
1218*4882a593Smuzhiyun model            device identifier
1219*4882a593Smuzhiyun settings         device setup
1220*4882a593Smuzhiyun smart_thresholds IDE disk management thresholds
1221*4882a593Smuzhiyun smart_values     IDE disk management values
1222*4882a593Smuzhiyun ================ ==========================================
1223*4882a593Smuzhiyun
1224*4882a593SmuzhiyunThe most  interesting  file is ``settings``. This file contains a nice
1225*4882a593Smuzhiyunoverview of the drive parameters::
1226*4882a593Smuzhiyun
1227*4882a593Smuzhiyun  # cat /proc/ide/ide0/hda/settings
1228*4882a593Smuzhiyun  name                    value           min             max             mode
1229*4882a593Smuzhiyun  ----                    -----           ---             ---             ----
1230*4882a593Smuzhiyun  bios_cyl                526             0               65535           rw
1231*4882a593Smuzhiyun  bios_head               255             0               255             rw
1232*4882a593Smuzhiyun  bios_sect               63              0               63              rw
1233*4882a593Smuzhiyun  breada_readahead        4               0               127             rw
1234*4882a593Smuzhiyun  bswap                   0               0               1               r
1235*4882a593Smuzhiyun  file_readahead          72              0               2097151         rw
1236*4882a593Smuzhiyun  io_32bit                0               0               3               rw
1237*4882a593Smuzhiyun  keepsettings            0               0               1               rw
1238*4882a593Smuzhiyun  max_kb_per_request      122             1               127             rw
1239*4882a593Smuzhiyun  multcount               0               0               8               rw
1240*4882a593Smuzhiyun  nice1                   1               0               1               rw
1241*4882a593Smuzhiyun  nowerr                  0               0               1               rw
1242*4882a593Smuzhiyun  pio_mode                write-only      0               255             w
1243*4882a593Smuzhiyun  slow                    0               0               1               rw
1244*4882a593Smuzhiyun  unmaskirq               0               0               1               rw
1245*4882a593Smuzhiyun  using_dma               0               0               1               rw
1246*4882a593Smuzhiyun
1247*4882a593Smuzhiyun
1248*4882a593Smuzhiyun1.4 Networking info in /proc/net
1249*4882a593Smuzhiyun--------------------------------
1250*4882a593Smuzhiyun
1251*4882a593SmuzhiyunThe subdirectory  /proc/net  follows  the  usual  pattern. Table 1-8 shows the
1252*4882a593Smuzhiyunadditional values  you  get  for  IP  version 6 if you configure the kernel to
1253*4882a593Smuzhiyunsupport this. Table 1-9 lists the files and their meaning.
1254*4882a593Smuzhiyun
1255*4882a593Smuzhiyun
1256*4882a593Smuzhiyun.. table:: Table 1-8: IPv6 info in /proc/net
1257*4882a593Smuzhiyun
1258*4882a593Smuzhiyun ========== =====================================================
1259*4882a593Smuzhiyun File       Content
1260*4882a593Smuzhiyun ========== =====================================================
1261*4882a593Smuzhiyun udp6       UDP sockets (IPv6)
1262*4882a593Smuzhiyun tcp6       TCP sockets (IPv6)
1263*4882a593Smuzhiyun raw6       Raw device statistics (IPv6)
1264*4882a593Smuzhiyun igmp6      IP multicast addresses, which this host joined (IPv6)
1265*4882a593Smuzhiyun if_inet6   List of IPv6 interface addresses
1266*4882a593Smuzhiyun ipv6_route Kernel routing table for IPv6
1267*4882a593Smuzhiyun rt6_stats  Global IPv6 routing tables statistics
1268*4882a593Smuzhiyun sockstat6  Socket statistics (IPv6)
1269*4882a593Smuzhiyun snmp6      Snmp data (IPv6)
1270*4882a593Smuzhiyun ========== =====================================================
1271*4882a593Smuzhiyun
1272*4882a593Smuzhiyun.. table:: Table 1-9: Network info in /proc/net
1273*4882a593Smuzhiyun
1274*4882a593Smuzhiyun ============= ================================================================
1275*4882a593Smuzhiyun File          Content
1276*4882a593Smuzhiyun ============= ================================================================
1277*4882a593Smuzhiyun arp           Kernel  ARP table
1278*4882a593Smuzhiyun dev           network devices with statistics
1279*4882a593Smuzhiyun dev_mcast     the Layer2 multicast groups a device is listening too
1280*4882a593Smuzhiyun               (interface index, label, number of references, number of bound
1281*4882a593Smuzhiyun               addresses).
1282*4882a593Smuzhiyun dev_stat      network device status
1283*4882a593Smuzhiyun ip_fwchains   Firewall chain linkage
1284*4882a593Smuzhiyun ip_fwnames    Firewall chain names
1285*4882a593Smuzhiyun ip_masq       Directory containing the masquerading tables
1286*4882a593Smuzhiyun ip_masquerade Major masquerading table
1287*4882a593Smuzhiyun netstat       Network statistics
1288*4882a593Smuzhiyun raw           raw device statistics
1289*4882a593Smuzhiyun route         Kernel routing table
1290*4882a593Smuzhiyun rpc           Directory containing rpc info
1291*4882a593Smuzhiyun rt_cache      Routing cache
1292*4882a593Smuzhiyun snmp          SNMP data
1293*4882a593Smuzhiyun sockstat      Socket statistics
1294*4882a593Smuzhiyun tcp           TCP  sockets
1295*4882a593Smuzhiyun udp           UDP sockets
1296*4882a593Smuzhiyun unix          UNIX domain sockets
1297*4882a593Smuzhiyun wireless      Wireless interface data (Wavelan etc)
1298*4882a593Smuzhiyun igmp          IP multicast addresses, which this host joined
1299*4882a593Smuzhiyun psched        Global packet scheduler parameters.
1300*4882a593Smuzhiyun netlink       List of PF_NETLINK sockets
1301*4882a593Smuzhiyun ip_mr_vifs    List of multicast virtual interfaces
1302*4882a593Smuzhiyun ip_mr_cache   List of multicast routing cache
1303*4882a593Smuzhiyun ============= ================================================================
1304*4882a593Smuzhiyun
1305*4882a593SmuzhiyunYou can  use  this  information  to see which network devices are available in
1306*4882a593Smuzhiyunyour system and how much traffic was routed over those devices::
1307*4882a593Smuzhiyun
1308*4882a593Smuzhiyun  > cat /proc/net/dev
1309*4882a593Smuzhiyun  Inter-|Receive                                                   |[...
1310*4882a593Smuzhiyun   face |bytes    packets errs drop fifo frame compressed multicast|[...
1311*4882a593Smuzhiyun      lo:  908188   5596     0    0    0     0          0         0 [...
1312*4882a593Smuzhiyun    ppp0:15475140  20721   410    0    0   410          0         0 [...
1313*4882a593Smuzhiyun    eth0:  614530   7085     0    0    0     0          0         1 [...
1314*4882a593Smuzhiyun
1315*4882a593Smuzhiyun  ...] Transmit
1316*4882a593Smuzhiyun  ...] bytes    packets errs drop fifo colls carrier compressed
1317*4882a593Smuzhiyun  ...]  908188     5596    0    0    0     0       0          0
1318*4882a593Smuzhiyun  ...] 1375103    17405    0    0    0     0       0          0
1319*4882a593Smuzhiyun  ...] 1703981     5535    0    0    0     3       0          0
1320*4882a593Smuzhiyun
1321*4882a593SmuzhiyunIn addition, each Channel Bond interface has its own directory.  For
1322*4882a593Smuzhiyunexample, the bond0 device will have a directory called /proc/net/bond0/.
1323*4882a593SmuzhiyunIt will contain information that is specific to that bond, such as the
1324*4882a593Smuzhiyuncurrent slaves of the bond, the link status of the slaves, and how
1325*4882a593Smuzhiyunmany times the slaves link has failed.
1326*4882a593Smuzhiyun
1327*4882a593Smuzhiyun1.5 SCSI info
1328*4882a593Smuzhiyun-------------
1329*4882a593Smuzhiyun
1330*4882a593SmuzhiyunIf you  have  a  SCSI  host adapter in your system, you'll find a subdirectory
1331*4882a593Smuzhiyunnamed after  the driver for this adapter in /proc/scsi. You'll also see a list
1332*4882a593Smuzhiyunof all recognized SCSI devices in /proc/scsi::
1333*4882a593Smuzhiyun
1334*4882a593Smuzhiyun  >cat /proc/scsi/scsi
1335*4882a593Smuzhiyun  Attached devices:
1336*4882a593Smuzhiyun  Host: scsi0 Channel: 00 Id: 00 Lun: 00
1337*4882a593Smuzhiyun    Vendor: IBM      Model: DGHS09U          Rev: 03E0
1338*4882a593Smuzhiyun    Type:   Direct-Access                    ANSI SCSI revision: 03
1339*4882a593Smuzhiyun  Host: scsi0 Channel: 00 Id: 06 Lun: 00
1340*4882a593Smuzhiyun    Vendor: PIONEER  Model: CD-ROM DR-U06S   Rev: 1.04
1341*4882a593Smuzhiyun    Type:   CD-ROM                           ANSI SCSI revision: 02
1342*4882a593Smuzhiyun
1343*4882a593Smuzhiyun
1344*4882a593SmuzhiyunThe directory  named  after  the driver has one file for each adapter found in
1345*4882a593Smuzhiyunthe system.  These  files  contain information about the controller, including
1346*4882a593Smuzhiyunthe used  IRQ  and  the  IO  address range. The amount of information shown is
1347*4882a593Smuzhiyundependent on  the adapter you use. The example shows the output for an Adaptec
1348*4882a593SmuzhiyunAHA-2940 SCSI adapter::
1349*4882a593Smuzhiyun
1350*4882a593Smuzhiyun  > cat /proc/scsi/aic7xxx/0
1351*4882a593Smuzhiyun
1352*4882a593Smuzhiyun  Adaptec AIC7xxx driver version: 5.1.19/3.2.4
1353*4882a593Smuzhiyun  Compile Options:
1354*4882a593Smuzhiyun    TCQ Enabled By Default : Disabled
1355*4882a593Smuzhiyun    AIC7XXX_PROC_STATS     : Disabled
1356*4882a593Smuzhiyun    AIC7XXX_RESET_DELAY    : 5
1357*4882a593Smuzhiyun  Adapter Configuration:
1358*4882a593Smuzhiyun             SCSI Adapter: Adaptec AHA-294X Ultra SCSI host adapter
1359*4882a593Smuzhiyun                             Ultra Wide Controller
1360*4882a593Smuzhiyun      PCI MMAPed I/O Base: 0xeb001000
1361*4882a593Smuzhiyun   Adapter SEEPROM Config: SEEPROM found and used.
1362*4882a593Smuzhiyun        Adaptec SCSI BIOS: Enabled
1363*4882a593Smuzhiyun                      IRQ: 10
1364*4882a593Smuzhiyun                     SCBs: Active 0, Max Active 2,
1365*4882a593Smuzhiyun                           Allocated 15, HW 16, Page 255
1366*4882a593Smuzhiyun               Interrupts: 160328
1367*4882a593Smuzhiyun        BIOS Control Word: 0x18b6
1368*4882a593Smuzhiyun     Adapter Control Word: 0x005b
1369*4882a593Smuzhiyun     Extended Translation: Enabled
1370*4882a593Smuzhiyun  Disconnect Enable Flags: 0xffff
1371*4882a593Smuzhiyun       Ultra Enable Flags: 0x0001
1372*4882a593Smuzhiyun   Tag Queue Enable Flags: 0x0000
1373*4882a593Smuzhiyun  Ordered Queue Tag Flags: 0x0000
1374*4882a593Smuzhiyun  Default Tag Queue Depth: 8
1375*4882a593Smuzhiyun      Tagged Queue By Device array for aic7xxx host instance 0:
1376*4882a593Smuzhiyun        {255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255}
1377*4882a593Smuzhiyun      Actual queue depth per device for aic7xxx host instance 0:
1378*4882a593Smuzhiyun        {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
1379*4882a593Smuzhiyun  Statistics:
1380*4882a593Smuzhiyun  (scsi0:0:0:0)
1381*4882a593Smuzhiyun    Device using Wide/Sync transfers at 40.0 MByte/sec, offset 8
1382*4882a593Smuzhiyun    Transinfo settings: current(12/8/1/0), goal(12/8/1/0), user(12/15/1/0)
1383*4882a593Smuzhiyun    Total transfers 160151 (74577 reads and 85574 writes)
1384*4882a593Smuzhiyun  (scsi0:0:6:0)
1385*4882a593Smuzhiyun    Device using Narrow/Sync transfers at 5.0 MByte/sec, offset 15
1386*4882a593Smuzhiyun    Transinfo settings: current(50/15/0/0), goal(50/15/0/0), user(50/15/0/0)
1387*4882a593Smuzhiyun    Total transfers 0 (0 reads and 0 writes)
1388*4882a593Smuzhiyun
1389*4882a593Smuzhiyun
1390*4882a593Smuzhiyun1.6 Parallel port info in /proc/parport
1391*4882a593Smuzhiyun---------------------------------------
1392*4882a593Smuzhiyun
1393*4882a593SmuzhiyunThe directory  /proc/parport  contains information about the parallel ports of
1394*4882a593Smuzhiyunyour system.  It  has  one  subdirectory  for  each port, named after the port
1395*4882a593Smuzhiyunnumber (0,1,2,...).
1396*4882a593Smuzhiyun
1397*4882a593SmuzhiyunThese directories contain the four files shown in Table 1-10.
1398*4882a593Smuzhiyun
1399*4882a593Smuzhiyun
1400*4882a593Smuzhiyun.. table:: Table 1-10: Files in /proc/parport
1401*4882a593Smuzhiyun
1402*4882a593Smuzhiyun ========= ====================================================================
1403*4882a593Smuzhiyun File      Content
1404*4882a593Smuzhiyun ========= ====================================================================
1405*4882a593Smuzhiyun autoprobe Any IEEE-1284 device ID information that has been acquired.
1406*4882a593Smuzhiyun devices   list of the device drivers using that port. A + will appear by the
1407*4882a593Smuzhiyun           name of the device currently using the port (it might not appear
1408*4882a593Smuzhiyun           against any).
1409*4882a593Smuzhiyun hardware  Parallel port's base address, IRQ line and DMA channel.
1410*4882a593Smuzhiyun irq       IRQ that parport is using for that port. This is in a separate
1411*4882a593Smuzhiyun           file to allow you to alter it by writing a new value in (IRQ
1412*4882a593Smuzhiyun           number or none).
1413*4882a593Smuzhiyun ========= ====================================================================
1414*4882a593Smuzhiyun
1415*4882a593Smuzhiyun1.7 TTY info in /proc/tty
1416*4882a593Smuzhiyun-------------------------
1417*4882a593Smuzhiyun
1418*4882a593SmuzhiyunInformation about  the  available  and actually used tty's can be found in the
1419*4882a593Smuzhiyundirectory /proc/tty. You'll find  entries  for drivers and line disciplines in
1420*4882a593Smuzhiyunthis directory, as shown in Table 1-11.
1421*4882a593Smuzhiyun
1422*4882a593Smuzhiyun
1423*4882a593Smuzhiyun.. table:: Table 1-11: Files in /proc/tty
1424*4882a593Smuzhiyun
1425*4882a593Smuzhiyun ============= ==============================================
1426*4882a593Smuzhiyun File          Content
1427*4882a593Smuzhiyun ============= ==============================================
1428*4882a593Smuzhiyun drivers       list of drivers and their usage
1429*4882a593Smuzhiyun ldiscs        registered line disciplines
1430*4882a593Smuzhiyun driver/serial usage statistic and status of single tty lines
1431*4882a593Smuzhiyun ============= ==============================================
1432*4882a593Smuzhiyun
1433*4882a593SmuzhiyunTo see  which  tty's  are  currently in use, you can simply look into the file
1434*4882a593Smuzhiyun/proc/tty/drivers::
1435*4882a593Smuzhiyun
1436*4882a593Smuzhiyun  > cat /proc/tty/drivers
1437*4882a593Smuzhiyun  pty_slave            /dev/pts      136   0-255 pty:slave
1438*4882a593Smuzhiyun  pty_master           /dev/ptm      128   0-255 pty:master
1439*4882a593Smuzhiyun  pty_slave            /dev/ttyp       3   0-255 pty:slave
1440*4882a593Smuzhiyun  pty_master           /dev/pty        2   0-255 pty:master
1441*4882a593Smuzhiyun  serial               /dev/cua        5   64-67 serial:callout
1442*4882a593Smuzhiyun  serial               /dev/ttyS       4   64-67 serial
1443*4882a593Smuzhiyun  /dev/tty0            /dev/tty0       4       0 system:vtmaster
1444*4882a593Smuzhiyun  /dev/ptmx            /dev/ptmx       5       2 system
1445*4882a593Smuzhiyun  /dev/console         /dev/console    5       1 system:console
1446*4882a593Smuzhiyun  /dev/tty             /dev/tty        5       0 system:/dev/tty
1447*4882a593Smuzhiyun  unknown              /dev/tty        4    1-63 console
1448*4882a593Smuzhiyun
1449*4882a593Smuzhiyun
1450*4882a593Smuzhiyun1.8 Miscellaneous kernel statistics in /proc/stat
1451*4882a593Smuzhiyun-------------------------------------------------
1452*4882a593Smuzhiyun
1453*4882a593SmuzhiyunVarious pieces   of  information about  kernel activity  are  available in the
1454*4882a593Smuzhiyun/proc/stat file.  All  of  the numbers reported  in  this file are  aggregates
1455*4882a593Smuzhiyunsince the system first booted.  For a quick look, simply cat the file::
1456*4882a593Smuzhiyun
1457*4882a593Smuzhiyun  > cat /proc/stat
1458*4882a593Smuzhiyun  cpu  2255 34 2290 22625563 6290 127 456 0 0 0
1459*4882a593Smuzhiyun  cpu0 1132 34 1441 11311718 3675 127 438 0 0 0
1460*4882a593Smuzhiyun  cpu1 1123 0 849 11313845 2614 0 18 0 0 0
1461*4882a593Smuzhiyun  intr 114930548 113199788 3 0 5 263 0 4 [... lots more numbers ...]
1462*4882a593Smuzhiyun  ctxt 1990473
1463*4882a593Smuzhiyun  btime 1062191376
1464*4882a593Smuzhiyun  processes 2915
1465*4882a593Smuzhiyun  procs_running 1
1466*4882a593Smuzhiyun  procs_blocked 0
1467*4882a593Smuzhiyun  softirq 183433 0 21755 12 39 1137 231 21459 2263
1468*4882a593Smuzhiyun
1469*4882a593SmuzhiyunThe very first  "cpu" line aggregates the  numbers in all  of the other "cpuN"
1470*4882a593Smuzhiyunlines.  These numbers identify the amount of time the CPU has spent performing
1471*4882a593Smuzhiyundifferent kinds of work.  Time units are in USER_HZ (typically hundredths of a
1472*4882a593Smuzhiyunsecond).  The meanings of the columns are as follows, from left to right:
1473*4882a593Smuzhiyun
1474*4882a593Smuzhiyun- user: normal processes executing in user mode
1475*4882a593Smuzhiyun- nice: niced processes executing in user mode
1476*4882a593Smuzhiyun- system: processes executing in kernel mode
1477*4882a593Smuzhiyun- idle: twiddling thumbs
1478*4882a593Smuzhiyun- iowait: In a word, iowait stands for waiting for I/O to complete. But there
1479*4882a593Smuzhiyun  are several problems:
1480*4882a593Smuzhiyun
1481*4882a593Smuzhiyun  1. CPU will not wait for I/O to complete, iowait is the time that a task is
1482*4882a593Smuzhiyun     waiting for I/O to complete. When CPU goes into idle state for
1483*4882a593Smuzhiyun     outstanding task I/O, another task will be scheduled on this CPU.
1484*4882a593Smuzhiyun  2. In a multi-core CPU, the task waiting for I/O to complete is not running
1485*4882a593Smuzhiyun     on any CPU, so the iowait of each CPU is difficult to calculate.
1486*4882a593Smuzhiyun  3. The value of iowait field in /proc/stat will decrease in certain
1487*4882a593Smuzhiyun     conditions.
1488*4882a593Smuzhiyun
1489*4882a593Smuzhiyun  So, the iowait is not reliable by reading from /proc/stat.
1490*4882a593Smuzhiyun- irq: servicing interrupts
1491*4882a593Smuzhiyun- softirq: servicing softirqs
1492*4882a593Smuzhiyun- steal: involuntary wait
1493*4882a593Smuzhiyun- guest: running a normal guest
1494*4882a593Smuzhiyun- guest_nice: running a niced guest
1495*4882a593Smuzhiyun
1496*4882a593SmuzhiyunThe "intr" line gives counts of interrupts  serviced since boot time, for each
1497*4882a593Smuzhiyunof the  possible system interrupts.   The first  column  is the  total of  all
1498*4882a593Smuzhiyuninterrupts serviced  including  unnumbered  architecture specific  interrupts;
1499*4882a593Smuzhiyuneach  subsequent column is the  total for that particular numbered interrupt.
1500*4882a593SmuzhiyunUnnumbered interrupts are not shown, only summed into the total.
1501*4882a593Smuzhiyun
1502*4882a593SmuzhiyunThe "ctxt" line gives the total number of context switches across all CPUs.
1503*4882a593Smuzhiyun
1504*4882a593SmuzhiyunThe "btime" line gives  the time at which the  system booted, in seconds since
1505*4882a593Smuzhiyunthe Unix epoch.
1506*4882a593Smuzhiyun
1507*4882a593SmuzhiyunThe "processes" line gives the number  of processes and threads created, which
1508*4882a593Smuzhiyunincludes (but  is not limited  to) those  created by  calls to the  fork() and
1509*4882a593Smuzhiyunclone() system calls.
1510*4882a593Smuzhiyun
1511*4882a593SmuzhiyunThe "procs_running" line gives the total number of threads that are
1512*4882a593Smuzhiyunrunning or ready to run (i.e., the total number of runnable threads).
1513*4882a593Smuzhiyun
1514*4882a593SmuzhiyunThe   "procs_blocked" line gives  the  number of  processes currently blocked,
1515*4882a593Smuzhiyunwaiting for I/O to complete.
1516*4882a593Smuzhiyun
1517*4882a593SmuzhiyunThe "softirq" line gives counts of softirqs serviced since boot time, for each
1518*4882a593Smuzhiyunof the possible system softirqs. The first column is the total of all
1519*4882a593Smuzhiyunsoftirqs serviced; each subsequent column is the total for that particular
1520*4882a593Smuzhiyunsoftirq.
1521*4882a593Smuzhiyun
1522*4882a593Smuzhiyun
1523*4882a593Smuzhiyun1.9 Ext4 file system parameters
1524*4882a593Smuzhiyun-------------------------------
1525*4882a593Smuzhiyun
1526*4882a593SmuzhiyunInformation about mounted ext4 file systems can be found in
1527*4882a593Smuzhiyun/proc/fs/ext4.  Each mounted filesystem will have a directory in
1528*4882a593Smuzhiyun/proc/fs/ext4 based on its device name (i.e., /proc/fs/ext4/hdc or
1529*4882a593Smuzhiyun/proc/fs/ext4/dm-0).   The files in each per-device directory are shown
1530*4882a593Smuzhiyunin Table 1-12, below.
1531*4882a593Smuzhiyun
1532*4882a593Smuzhiyun.. table:: Table 1-12: Files in /proc/fs/ext4/<devname>
1533*4882a593Smuzhiyun
1534*4882a593Smuzhiyun ==============  ==========================================================
1535*4882a593Smuzhiyun File            Content
1536*4882a593Smuzhiyun mb_groups       details of multiblock allocator buddy cache of free blocks
1537*4882a593Smuzhiyun ==============  ==========================================================
1538*4882a593Smuzhiyun
1539*4882a593Smuzhiyun1.10 /proc/consoles
1540*4882a593Smuzhiyun-------------------
1541*4882a593SmuzhiyunShows registered system console lines.
1542*4882a593Smuzhiyun
1543*4882a593SmuzhiyunTo see which character device lines are currently used for the system console
1544*4882a593Smuzhiyun/dev/console, you may simply look into the file /proc/consoles::
1545*4882a593Smuzhiyun
1546*4882a593Smuzhiyun  > cat /proc/consoles
1547*4882a593Smuzhiyun  tty0                 -WU (ECp)       4:7
1548*4882a593Smuzhiyun  ttyS0                -W- (Ep)        4:64
1549*4882a593Smuzhiyun
1550*4882a593SmuzhiyunThe columns are:
1551*4882a593Smuzhiyun
1552*4882a593Smuzhiyun+--------------------+-------------------------------------------------------+
1553*4882a593Smuzhiyun| device             | name of the device                                    |
1554*4882a593Smuzhiyun+====================+=======================================================+
1555*4882a593Smuzhiyun| operations         | * R = can do read operations                          |
1556*4882a593Smuzhiyun|                    | * W = can do write operations                         |
1557*4882a593Smuzhiyun|                    | * U = can do unblank                                  |
1558*4882a593Smuzhiyun+--------------------+-------------------------------------------------------+
1559*4882a593Smuzhiyun| flags              | * E = it is enabled                                   |
1560*4882a593Smuzhiyun|                    | * C = it is preferred console                         |
1561*4882a593Smuzhiyun|                    | * B = it is primary boot console                      |
1562*4882a593Smuzhiyun|                    | * p = it is used for printk buffer                    |
1563*4882a593Smuzhiyun|                    | * b = it is not a TTY but a Braille device            |
1564*4882a593Smuzhiyun|                    | * a = it is safe to use when cpu is offline           |
1565*4882a593Smuzhiyun+--------------------+-------------------------------------------------------+
1566*4882a593Smuzhiyun| major:minor        | major and minor number of the device separated by a   |
1567*4882a593Smuzhiyun|                    | colon                                                 |
1568*4882a593Smuzhiyun+--------------------+-------------------------------------------------------+
1569*4882a593Smuzhiyun
1570*4882a593SmuzhiyunSummary
1571*4882a593Smuzhiyun-------
1572*4882a593Smuzhiyun
1573*4882a593SmuzhiyunThe /proc file system serves information about the running system. It not only
1574*4882a593Smuzhiyunallows access to process data but also allows you to request the kernel status
1575*4882a593Smuzhiyunby reading files in the hierarchy.
1576*4882a593Smuzhiyun
1577*4882a593SmuzhiyunThe directory  structure  of /proc reflects the types of information and makes
1578*4882a593Smuzhiyunit easy, if not obvious, where to look for specific data.
1579*4882a593Smuzhiyun
1580*4882a593SmuzhiyunChapter 2: Modifying System Parameters
1581*4882a593Smuzhiyun======================================
1582*4882a593Smuzhiyun
1583*4882a593SmuzhiyunIn This Chapter
1584*4882a593Smuzhiyun---------------
1585*4882a593Smuzhiyun
1586*4882a593Smuzhiyun* Modifying kernel parameters by writing into files found in /proc/sys
1587*4882a593Smuzhiyun* Exploring the files which modify certain parameters
1588*4882a593Smuzhiyun* Review of the /proc/sys file tree
1589*4882a593Smuzhiyun
1590*4882a593Smuzhiyun------------------------------------------------------------------------------
1591*4882a593Smuzhiyun
1592*4882a593SmuzhiyunA very  interesting part of /proc is the directory /proc/sys. This is not only
1593*4882a593Smuzhiyuna source  of  information,  it also allows you to change parameters within the
1594*4882a593Smuzhiyunkernel. Be  very  careful  when attempting this. You can optimize your system,
1595*4882a593Smuzhiyunbut you  can  also  cause  it  to  crash.  Never  alter kernel parameters on a
1596*4882a593Smuzhiyunproduction system.  Set  up  a  development machine and test to make sure that
1597*4882a593Smuzhiyuneverything works  the  way  you want it to. You may have no alternative but to
1598*4882a593Smuzhiyunreboot the machine once an error has been made.
1599*4882a593Smuzhiyun
1600*4882a593SmuzhiyunTo change  a  value,  simply  echo  the new value into the file.
1601*4882a593SmuzhiyunYou need to be root to do this. You  can  create  your  own  boot script
1602*4882a593Smuzhiyunto perform this every time your system boots.
1603*4882a593Smuzhiyun
1604*4882a593SmuzhiyunThe files  in /proc/sys can be used to fine tune and monitor miscellaneous and
1605*4882a593Smuzhiyungeneral things  in  the operation of the Linux kernel. Since some of the files
1606*4882a593Smuzhiyuncan inadvertently  disrupt  your  system,  it  is  advisable  to  read  both
1607*4882a593Smuzhiyundocumentation and  source  before actually making adjustments. In any case, be
1608*4882a593Smuzhiyunvery careful  when  writing  to  any  of these files. The entries in /proc may
1609*4882a593Smuzhiyunchange slightly between the 2.1.* and the 2.2 kernel, so if there is any doubt
1610*4882a593Smuzhiyunreview the kernel documentation in the directory /usr/src/linux/Documentation.
1611*4882a593SmuzhiyunThis chapter  is  heavily  based  on the documentation included in the pre 2.2
1612*4882a593Smuzhiyunkernels, and became part of it in version 2.2.1 of the Linux kernel.
1613*4882a593Smuzhiyun
1614*4882a593SmuzhiyunPlease see: Documentation/admin-guide/sysctl/ directory for descriptions of these
1615*4882a593Smuzhiyunentries.
1616*4882a593Smuzhiyun
1617*4882a593SmuzhiyunSummary
1618*4882a593Smuzhiyun-------
1619*4882a593Smuzhiyun
1620*4882a593SmuzhiyunCertain aspects  of  kernel  behavior  can be modified at runtime, without the
1621*4882a593Smuzhiyunneed to  recompile  the kernel, or even to reboot the system. The files in the
1622*4882a593Smuzhiyun/proc/sys tree  can  not only be read, but also modified. You can use the echo
1623*4882a593Smuzhiyuncommand to write value into these files, thereby changing the default settings
1624*4882a593Smuzhiyunof the kernel.
1625*4882a593Smuzhiyun
1626*4882a593Smuzhiyun
1627*4882a593SmuzhiyunChapter 3: Per-process Parameters
1628*4882a593Smuzhiyun=================================
1629*4882a593Smuzhiyun
1630*4882a593Smuzhiyun3.1 /proc/<pid>/oom_adj & /proc/<pid>/oom_score_adj- Adjust the oom-killer score
1631*4882a593Smuzhiyun--------------------------------------------------------------------------------
1632*4882a593Smuzhiyun
1633*4882a593SmuzhiyunThese files can be used to adjust the badness heuristic used to select which
1634*4882a593Smuzhiyunprocess gets killed in out of memory (oom) conditions.
1635*4882a593Smuzhiyun
1636*4882a593SmuzhiyunThe badness heuristic assigns a value to each candidate task ranging from 0
1637*4882a593Smuzhiyun(never kill) to 1000 (always kill) to determine which process is targeted.  The
1638*4882a593Smuzhiyununits are roughly a proportion along that range of allowed memory the process
1639*4882a593Smuzhiyunmay allocate from based on an estimation of its current memory and swap use.
1640*4882a593SmuzhiyunFor example, if a task is using all allowed memory, its badness score will be
1641*4882a593Smuzhiyun1000.  If it is using half of its allowed memory, its score will be 500.
1642*4882a593Smuzhiyun
1643*4882a593SmuzhiyunThe amount of "allowed" memory depends on the context in which the oom killer
1644*4882a593Smuzhiyunwas called.  If it is due to the memory assigned to the allocating task's cpuset
1645*4882a593Smuzhiyunbeing exhausted, the allowed memory represents the set of mems assigned to that
1646*4882a593Smuzhiyuncpuset.  If it is due to a mempolicy's node(s) being exhausted, the allowed
1647*4882a593Smuzhiyunmemory represents the set of mempolicy nodes.  If it is due to a memory
1648*4882a593Smuzhiyunlimit (or swap limit) being reached, the allowed memory is that configured
1649*4882a593Smuzhiyunlimit.  Finally, if it is due to the entire system being out of memory, the
1650*4882a593Smuzhiyunallowed memory represents all allocatable resources.
1651*4882a593Smuzhiyun
1652*4882a593SmuzhiyunThe value of /proc/<pid>/oom_score_adj is added to the badness score before it
1653*4882a593Smuzhiyunis used to determine which task to kill.  Acceptable values range from -1000
1654*4882a593Smuzhiyun(OOM_SCORE_ADJ_MIN) to +1000 (OOM_SCORE_ADJ_MAX).  This allows userspace to
1655*4882a593Smuzhiyunpolarize the preference for oom killing either by always preferring a certain
1656*4882a593Smuzhiyuntask or completely disabling it.  The lowest possible value, -1000, is
1657*4882a593Smuzhiyunequivalent to disabling oom killing entirely for that task since it will always
1658*4882a593Smuzhiyunreport a badness score of 0.
1659*4882a593Smuzhiyun
1660*4882a593SmuzhiyunConsequently, it is very simple for userspace to define the amount of memory to
1661*4882a593Smuzhiyunconsider for each task.  Setting a /proc/<pid>/oom_score_adj value of +500, for
1662*4882a593Smuzhiyunexample, is roughly equivalent to allowing the remainder of tasks sharing the
1663*4882a593Smuzhiyunsame system, cpuset, mempolicy, or memory controller resources to use at least
1664*4882a593Smuzhiyun50% more memory.  A value of -500, on the other hand, would be roughly
1665*4882a593Smuzhiyunequivalent to discounting 50% of the task's allowed memory from being considered
1666*4882a593Smuzhiyunas scoring against the task.
1667*4882a593Smuzhiyun
1668*4882a593SmuzhiyunFor backwards compatibility with previous kernels, /proc/<pid>/oom_adj may also
1669*4882a593Smuzhiyunbe used to tune the badness score.  Its acceptable values range from -16
1670*4882a593Smuzhiyun(OOM_ADJUST_MIN) to +15 (OOM_ADJUST_MAX) and a special value of -17
1671*4882a593Smuzhiyun(OOM_DISABLE) to disable oom killing entirely for that task.  Its value is
1672*4882a593Smuzhiyunscaled linearly with /proc/<pid>/oom_score_adj.
1673*4882a593Smuzhiyun
1674*4882a593SmuzhiyunThe value of /proc/<pid>/oom_score_adj may be reduced no lower than the last
1675*4882a593Smuzhiyunvalue set by a CAP_SYS_RESOURCE process. To reduce the value any lower
1676*4882a593Smuzhiyunrequires CAP_SYS_RESOURCE.
1677*4882a593Smuzhiyun
1678*4882a593Smuzhiyun
1679*4882a593Smuzhiyun3.2 /proc/<pid>/oom_score - Display current oom-killer score
1680*4882a593Smuzhiyun-------------------------------------------------------------
1681*4882a593Smuzhiyun
1682*4882a593SmuzhiyunThis file can be used to check the current score used by the oom-killer for
1683*4882a593Smuzhiyunany given <pid>. Use it together with /proc/<pid>/oom_score_adj to tune which
1684*4882a593Smuzhiyunprocess should be killed in an out-of-memory situation.
1685*4882a593Smuzhiyun
1686*4882a593SmuzhiyunPlease note that the exported value includes oom_score_adj so it is
1687*4882a593Smuzhiyuneffectively in range [0,2000].
1688*4882a593Smuzhiyun
1689*4882a593Smuzhiyun
1690*4882a593Smuzhiyun3.3  /proc/<pid>/io - Display the IO accounting fields
1691*4882a593Smuzhiyun-------------------------------------------------------
1692*4882a593Smuzhiyun
1693*4882a593SmuzhiyunThis file contains IO statistics for each running process.
1694*4882a593Smuzhiyun
1695*4882a593SmuzhiyunExample
1696*4882a593Smuzhiyun~~~~~~~
1697*4882a593Smuzhiyun
1698*4882a593Smuzhiyun::
1699*4882a593Smuzhiyun
1700*4882a593Smuzhiyun    test:/tmp # dd if=/dev/zero of=/tmp/test.dat &
1701*4882a593Smuzhiyun    [1] 3828
1702*4882a593Smuzhiyun
1703*4882a593Smuzhiyun    test:/tmp # cat /proc/3828/io
1704*4882a593Smuzhiyun    rchar: 323934931
1705*4882a593Smuzhiyun    wchar: 323929600
1706*4882a593Smuzhiyun    syscr: 632687
1707*4882a593Smuzhiyun    syscw: 632675
1708*4882a593Smuzhiyun    read_bytes: 0
1709*4882a593Smuzhiyun    write_bytes: 323932160
1710*4882a593Smuzhiyun    cancelled_write_bytes: 0
1711*4882a593Smuzhiyun
1712*4882a593Smuzhiyun
1713*4882a593SmuzhiyunDescription
1714*4882a593Smuzhiyun~~~~~~~~~~~
1715*4882a593Smuzhiyun
1716*4882a593Smuzhiyunrchar
1717*4882a593Smuzhiyun^^^^^
1718*4882a593Smuzhiyun
1719*4882a593SmuzhiyunI/O counter: chars read
1720*4882a593SmuzhiyunThe number of bytes which this task has caused to be read from storage. This
1721*4882a593Smuzhiyunis simply the sum of bytes which this process passed to read() and pread().
1722*4882a593SmuzhiyunIt includes things like tty IO and it is unaffected by whether or not actual
1723*4882a593Smuzhiyunphysical disk IO was required (the read might have been satisfied from
1724*4882a593Smuzhiyunpagecache).
1725*4882a593Smuzhiyun
1726*4882a593Smuzhiyun
1727*4882a593Smuzhiyunwchar
1728*4882a593Smuzhiyun^^^^^
1729*4882a593Smuzhiyun
1730*4882a593SmuzhiyunI/O counter: chars written
1731*4882a593SmuzhiyunThe number of bytes which this task has caused, or shall cause to be written
1732*4882a593Smuzhiyunto disk. Similar caveats apply here as with rchar.
1733*4882a593Smuzhiyun
1734*4882a593Smuzhiyun
1735*4882a593Smuzhiyunsyscr
1736*4882a593Smuzhiyun^^^^^
1737*4882a593Smuzhiyun
1738*4882a593SmuzhiyunI/O counter: read syscalls
1739*4882a593SmuzhiyunAttempt to count the number of read I/O operations, i.e. syscalls like read()
1740*4882a593Smuzhiyunand pread().
1741*4882a593Smuzhiyun
1742*4882a593Smuzhiyun
1743*4882a593Smuzhiyunsyscw
1744*4882a593Smuzhiyun^^^^^
1745*4882a593Smuzhiyun
1746*4882a593SmuzhiyunI/O counter: write syscalls
1747*4882a593SmuzhiyunAttempt to count the number of write I/O operations, i.e. syscalls like
1748*4882a593Smuzhiyunwrite() and pwrite().
1749*4882a593Smuzhiyun
1750*4882a593Smuzhiyun
1751*4882a593Smuzhiyunread_bytes
1752*4882a593Smuzhiyun^^^^^^^^^^
1753*4882a593Smuzhiyun
1754*4882a593SmuzhiyunI/O counter: bytes read
1755*4882a593SmuzhiyunAttempt to count the number of bytes which this process really did cause to
1756*4882a593Smuzhiyunbe fetched from the storage layer. Done at the submit_bio() level, so it is
1757*4882a593Smuzhiyunaccurate for block-backed filesystems. <please add status regarding NFS and
1758*4882a593SmuzhiyunCIFS at a later time>
1759*4882a593Smuzhiyun
1760*4882a593Smuzhiyun
1761*4882a593Smuzhiyunwrite_bytes
1762*4882a593Smuzhiyun^^^^^^^^^^^
1763*4882a593Smuzhiyun
1764*4882a593SmuzhiyunI/O counter: bytes written
1765*4882a593SmuzhiyunAttempt to count the number of bytes which this process caused to be sent to
1766*4882a593Smuzhiyunthe storage layer. This is done at page-dirtying time.
1767*4882a593Smuzhiyun
1768*4882a593Smuzhiyun
1769*4882a593Smuzhiyuncancelled_write_bytes
1770*4882a593Smuzhiyun^^^^^^^^^^^^^^^^^^^^^
1771*4882a593Smuzhiyun
1772*4882a593SmuzhiyunThe big inaccuracy here is truncate. If a process writes 1MB to a file and
1773*4882a593Smuzhiyunthen deletes the file, it will in fact perform no writeout. But it will have
1774*4882a593Smuzhiyunbeen accounted as having caused 1MB of write.
1775*4882a593SmuzhiyunIn other words: The number of bytes which this process caused to not happen,
1776*4882a593Smuzhiyunby truncating pagecache. A task can cause "negative" IO too. If this task
1777*4882a593Smuzhiyuntruncates some dirty pagecache, some IO which another task has been accounted
1778*4882a593Smuzhiyunfor (in its write_bytes) will not be happening. We _could_ just subtract that
1779*4882a593Smuzhiyunfrom the truncating task's write_bytes, but there is information loss in doing
1780*4882a593Smuzhiyunthat.
1781*4882a593Smuzhiyun
1782*4882a593Smuzhiyun
1783*4882a593Smuzhiyun.. Note::
1784*4882a593Smuzhiyun
1785*4882a593Smuzhiyun   At its current implementation state, this is a bit racy on 32-bit machines:
1786*4882a593Smuzhiyun   if process A reads process B's /proc/pid/io while process B is updating one
1787*4882a593Smuzhiyun   of those 64-bit counters, process A could see an intermediate result.
1788*4882a593Smuzhiyun
1789*4882a593Smuzhiyun
1790*4882a593SmuzhiyunMore information about this can be found within the taskstats documentation in
1791*4882a593SmuzhiyunDocumentation/accounting.
1792*4882a593Smuzhiyun
1793*4882a593Smuzhiyun3.4 /proc/<pid>/coredump_filter - Core dump filtering settings
1794*4882a593Smuzhiyun---------------------------------------------------------------
1795*4882a593SmuzhiyunWhen a process is dumped, all anonymous memory is written to a core file as
1796*4882a593Smuzhiyunlong as the size of the core file isn't limited. But sometimes we don't want
1797*4882a593Smuzhiyunto dump some memory segments, for example, huge shared memory or DAX.
1798*4882a593SmuzhiyunConversely, sometimes we want to save file-backed memory segments into a core
1799*4882a593Smuzhiyunfile, not only the individual files.
1800*4882a593Smuzhiyun
1801*4882a593Smuzhiyun/proc/<pid>/coredump_filter allows you to customize which memory segments
1802*4882a593Smuzhiyunwill be dumped when the <pid> process is dumped. coredump_filter is a bitmask
1803*4882a593Smuzhiyunof memory types. If a bit of the bitmask is set, memory segments of the
1804*4882a593Smuzhiyuncorresponding memory type are dumped, otherwise they are not dumped.
1805*4882a593Smuzhiyun
1806*4882a593SmuzhiyunThe following 9 memory types are supported:
1807*4882a593Smuzhiyun
1808*4882a593Smuzhiyun  - (bit 0) anonymous private memory
1809*4882a593Smuzhiyun  - (bit 1) anonymous shared memory
1810*4882a593Smuzhiyun  - (bit 2) file-backed private memory
1811*4882a593Smuzhiyun  - (bit 3) file-backed shared memory
1812*4882a593Smuzhiyun  - (bit 4) ELF header pages in file-backed private memory areas (it is
1813*4882a593Smuzhiyun    effective only if the bit 2 is cleared)
1814*4882a593Smuzhiyun  - (bit 5) hugetlb private memory
1815*4882a593Smuzhiyun  - (bit 6) hugetlb shared memory
1816*4882a593Smuzhiyun  - (bit 7) DAX private memory
1817*4882a593Smuzhiyun  - (bit 8) DAX shared memory
1818*4882a593Smuzhiyun
1819*4882a593Smuzhiyun  Note that MMIO pages such as frame buffer are never dumped and vDSO pages
1820*4882a593Smuzhiyun  are always dumped regardless of the bitmask status.
1821*4882a593Smuzhiyun
1822*4882a593Smuzhiyun  Note that bits 0-4 don't affect hugetlb or DAX memory. hugetlb memory is
1823*4882a593Smuzhiyun  only affected by bit 5-6, and DAX is only affected by bits 7-8.
1824*4882a593Smuzhiyun
1825*4882a593SmuzhiyunThe default value of coredump_filter is 0x33; this means all anonymous memory
1826*4882a593Smuzhiyunsegments, ELF header pages and hugetlb private memory are dumped.
1827*4882a593Smuzhiyun
1828*4882a593SmuzhiyunIf you don't want to dump all shared memory segments attached to pid 1234,
1829*4882a593Smuzhiyunwrite 0x31 to the process's proc file::
1830*4882a593Smuzhiyun
1831*4882a593Smuzhiyun  $ echo 0x31 > /proc/1234/coredump_filter
1832*4882a593Smuzhiyun
1833*4882a593SmuzhiyunWhen a new process is created, the process inherits the bitmask status from its
1834*4882a593Smuzhiyunparent. It is useful to set up coredump_filter before the program runs.
1835*4882a593SmuzhiyunFor example::
1836*4882a593Smuzhiyun
1837*4882a593Smuzhiyun  $ echo 0x7 > /proc/self/coredump_filter
1838*4882a593Smuzhiyun  $ ./some_program
1839*4882a593Smuzhiyun
1840*4882a593Smuzhiyun3.5	/proc/<pid>/mountinfo - Information about mounts
1841*4882a593Smuzhiyun--------------------------------------------------------
1842*4882a593Smuzhiyun
1843*4882a593SmuzhiyunThis file contains lines of the form::
1844*4882a593Smuzhiyun
1845*4882a593Smuzhiyun    36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue
1846*4882a593Smuzhiyun    (1)(2)(3)   (4)   (5)      (6)      (7)   (8) (9)   (10)         (11)
1847*4882a593Smuzhiyun
1848*4882a593Smuzhiyun    (1) mount ID:  unique identifier of the mount (may be reused after umount)
1849*4882a593Smuzhiyun    (2) parent ID:  ID of parent (or of self for the top of the mount tree)
1850*4882a593Smuzhiyun    (3) major:minor:  value of st_dev for files on filesystem
1851*4882a593Smuzhiyun    (4) root:  root of the mount within the filesystem
1852*4882a593Smuzhiyun    (5) mount point:  mount point relative to the process's root
1853*4882a593Smuzhiyun    (6) mount options:  per mount options
1854*4882a593Smuzhiyun    (7) optional fields:  zero or more fields of the form "tag[:value]"
1855*4882a593Smuzhiyun    (8) separator:  marks the end of the optional fields
1856*4882a593Smuzhiyun    (9) filesystem type:  name of filesystem of the form "type[.subtype]"
1857*4882a593Smuzhiyun    (10) mount source:  filesystem specific information or "none"
1858*4882a593Smuzhiyun    (11) super options:  per super block options
1859*4882a593Smuzhiyun
1860*4882a593SmuzhiyunParsers should ignore all unrecognised optional fields.  Currently the
1861*4882a593Smuzhiyunpossible optional fields are:
1862*4882a593Smuzhiyun
1863*4882a593Smuzhiyun================  ==============================================================
1864*4882a593Smuzhiyunshared:X          mount is shared in peer group X
1865*4882a593Smuzhiyunmaster:X          mount is slave to peer group X
1866*4882a593Smuzhiyunpropagate_from:X  mount is slave and receives propagation from peer group X [#]_
1867*4882a593Smuzhiyununbindable        mount is unbindable
1868*4882a593Smuzhiyun================  ==============================================================
1869*4882a593Smuzhiyun
1870*4882a593Smuzhiyun.. [#] X is the closest dominant peer group under the process's root.  If
1871*4882a593Smuzhiyun       X is the immediate master of the mount, or if there's no dominant peer
1872*4882a593Smuzhiyun       group under the same root, then only the "master:X" field is present
1873*4882a593Smuzhiyun       and not the "propagate_from:X" field.
1874*4882a593Smuzhiyun
1875*4882a593SmuzhiyunFor more information on mount propagation see:
1876*4882a593Smuzhiyun
1877*4882a593Smuzhiyun  Documentation/filesystems/sharedsubtree.rst
1878*4882a593Smuzhiyun
1879*4882a593Smuzhiyun
1880*4882a593Smuzhiyun3.6	/proc/<pid>/comm  & /proc/<pid>/task/<tid>/comm
1881*4882a593Smuzhiyun--------------------------------------------------------
1882*4882a593SmuzhiyunThese files provide a method to access a task's comm value. It also allows for
1883*4882a593Smuzhiyuna task to set its own or one of its thread siblings comm value. The comm value
1884*4882a593Smuzhiyunis limited in size compared to the cmdline value, so writing anything longer
1885*4882a593Smuzhiyunthen the kernel's TASK_COMM_LEN (currently 16 chars) will result in a truncated
1886*4882a593Smuzhiyuncomm value.
1887*4882a593Smuzhiyun
1888*4882a593Smuzhiyun
1889*4882a593Smuzhiyun3.7	/proc/<pid>/task/<tid>/children - Information about task children
1890*4882a593Smuzhiyun-------------------------------------------------------------------------
1891*4882a593SmuzhiyunThis file provides a fast way to retrieve first level children pids
1892*4882a593Smuzhiyunof a task pointed by <pid>/<tid> pair. The format is a space separated
1893*4882a593Smuzhiyunstream of pids.
1894*4882a593Smuzhiyun
1895*4882a593SmuzhiyunNote the "first level" here -- if a child has its own children they will
1896*4882a593Smuzhiyunnot be listed here; one needs to read /proc/<children-pid>/task/<tid>/children
1897*4882a593Smuzhiyunto obtain the descendants.
1898*4882a593Smuzhiyun
1899*4882a593SmuzhiyunSince this interface is intended to be fast and cheap it doesn't
1900*4882a593Smuzhiyunguarantee to provide precise results and some children might be
1901*4882a593Smuzhiyunskipped, especially if they've exited right after we printed their
1902*4882a593Smuzhiyunpids, so one needs to either stop or freeze processes being inspected
1903*4882a593Smuzhiyunif precise results are needed.
1904*4882a593Smuzhiyun
1905*4882a593Smuzhiyun
1906*4882a593Smuzhiyun3.8	/proc/<pid>/fdinfo/<fd> - Information about opened file
1907*4882a593Smuzhiyun---------------------------------------------------------------
1908*4882a593SmuzhiyunThis file provides information associated with an opened file. The regular
1909*4882a593Smuzhiyunfiles have at least four fields -- 'pos', 'flags', 'mnt_id' and 'ino'.
1910*4882a593SmuzhiyunThe 'pos' represents the current offset of the opened file in decimal
1911*4882a593Smuzhiyunform [see lseek(2) for details], 'flags' denotes the octal O_xxx mask the
1912*4882a593Smuzhiyunfile has been created with [see open(2) for details] and 'mnt_id' represents
1913*4882a593Smuzhiyunmount ID of the file system containing the opened file [see 3.5
1914*4882a593Smuzhiyun/proc/<pid>/mountinfo for details]. 'ino' represents the inode number of
1915*4882a593Smuzhiyunthe file.
1916*4882a593Smuzhiyun
1917*4882a593SmuzhiyunA typical output is::
1918*4882a593Smuzhiyun
1919*4882a593Smuzhiyun	pos:	0
1920*4882a593Smuzhiyun	flags:	0100002
1921*4882a593Smuzhiyun	mnt_id:	19
1922*4882a593Smuzhiyun	ino:	63107
1923*4882a593Smuzhiyun
1924*4882a593SmuzhiyunAll locks associated with a file descriptor are shown in its fdinfo too::
1925*4882a593Smuzhiyun
1926*4882a593Smuzhiyun    lock:       1: FLOCK  ADVISORY  WRITE 359 00:13:11691 0 EOF
1927*4882a593Smuzhiyun
1928*4882a593SmuzhiyunThe files such as eventfd, fsnotify, signalfd, epoll among the regular pos/flags
1929*4882a593Smuzhiyunpair provide additional information particular to the objects they represent.
1930*4882a593Smuzhiyun
1931*4882a593SmuzhiyunEventfd files
1932*4882a593Smuzhiyun~~~~~~~~~~~~~
1933*4882a593Smuzhiyun
1934*4882a593Smuzhiyun::
1935*4882a593Smuzhiyun
1936*4882a593Smuzhiyun	pos:	0
1937*4882a593Smuzhiyun	flags:	04002
1938*4882a593Smuzhiyun	mnt_id:	9
1939*4882a593Smuzhiyun	ino:	63107
1940*4882a593Smuzhiyun	eventfd-count:	5a
1941*4882a593Smuzhiyun
1942*4882a593Smuzhiyunwhere 'eventfd-count' is hex value of a counter.
1943*4882a593Smuzhiyun
1944*4882a593SmuzhiyunSignalfd files
1945*4882a593Smuzhiyun~~~~~~~~~~~~~~
1946*4882a593Smuzhiyun
1947*4882a593Smuzhiyun::
1948*4882a593Smuzhiyun
1949*4882a593Smuzhiyun	pos:	0
1950*4882a593Smuzhiyun	flags:	04002
1951*4882a593Smuzhiyun	mnt_id:	9
1952*4882a593Smuzhiyun	ino:	63107
1953*4882a593Smuzhiyun	sigmask:	0000000000000200
1954*4882a593Smuzhiyun
1955*4882a593Smuzhiyunwhere 'sigmask' is hex value of the signal mask associated
1956*4882a593Smuzhiyunwith a file.
1957*4882a593Smuzhiyun
1958*4882a593SmuzhiyunEpoll files
1959*4882a593Smuzhiyun~~~~~~~~~~~
1960*4882a593Smuzhiyun
1961*4882a593Smuzhiyun::
1962*4882a593Smuzhiyun
1963*4882a593Smuzhiyun	pos:	0
1964*4882a593Smuzhiyun	flags:	02
1965*4882a593Smuzhiyun	mnt_id:	9
1966*4882a593Smuzhiyun	ino:	63107
1967*4882a593Smuzhiyun	tfd:        5 events:       1d data: ffffffffffffffff pos:0 ino:61af sdev:7
1968*4882a593Smuzhiyun
1969*4882a593Smuzhiyunwhere 'tfd' is a target file descriptor number in decimal form,
1970*4882a593Smuzhiyun'events' is events mask being watched and the 'data' is data
1971*4882a593Smuzhiyunassociated with a target [see epoll(7) for more details].
1972*4882a593Smuzhiyun
1973*4882a593SmuzhiyunThe 'pos' is current offset of the target file in decimal form
1974*4882a593Smuzhiyun[see lseek(2)], 'ino' and 'sdev' are inode and device numbers
1975*4882a593Smuzhiyunwhere target file resides, all in hex format.
1976*4882a593Smuzhiyun
1977*4882a593SmuzhiyunFsnotify files
1978*4882a593Smuzhiyun~~~~~~~~~~~~~~
1979*4882a593SmuzhiyunFor inotify files the format is the following::
1980*4882a593Smuzhiyun
1981*4882a593Smuzhiyun	pos:	0
1982*4882a593Smuzhiyun	flags:	02000000
1983*4882a593Smuzhiyun	mnt_id:	9
1984*4882a593Smuzhiyun	ino:	63107
1985*4882a593Smuzhiyun	inotify wd:3 ino:9e7e sdev:800013 mask:800afce ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:7e9e0000640d1b6d
1986*4882a593Smuzhiyun
1987*4882a593Smuzhiyunwhere 'wd' is a watch descriptor in decimal form, i.e. a target file
1988*4882a593Smuzhiyundescriptor number, 'ino' and 'sdev' are inode and device where the
1989*4882a593Smuzhiyuntarget file resides and the 'mask' is the mask of events, all in hex
1990*4882a593Smuzhiyunform [see inotify(7) for more details].
1991*4882a593Smuzhiyun
1992*4882a593SmuzhiyunIf the kernel was built with exportfs support, the path to the target
1993*4882a593Smuzhiyunfile is encoded as a file handle.  The file handle is provided by three
1994*4882a593Smuzhiyunfields 'fhandle-bytes', 'fhandle-type' and 'f_handle', all in hex
1995*4882a593Smuzhiyunformat.
1996*4882a593Smuzhiyun
1997*4882a593SmuzhiyunIf the kernel is built without exportfs support the file handle won't be
1998*4882a593Smuzhiyunprinted out.
1999*4882a593Smuzhiyun
2000*4882a593SmuzhiyunIf there is no inotify mark attached yet the 'inotify' line will be omitted.
2001*4882a593Smuzhiyun
2002*4882a593SmuzhiyunFor fanotify files the format is::
2003*4882a593Smuzhiyun
2004*4882a593Smuzhiyun	pos:	0
2005*4882a593Smuzhiyun	flags:	02
2006*4882a593Smuzhiyun	mnt_id:	9
2007*4882a593Smuzhiyun	ino:	63107
2008*4882a593Smuzhiyun	fanotify flags:10 event-flags:0
2009*4882a593Smuzhiyun	fanotify mnt_id:12 mflags:40 mask:38 ignored_mask:40000003
2010*4882a593Smuzhiyun	fanotify ino:4f969 sdev:800013 mflags:0 mask:3b ignored_mask:40000000 fhandle-bytes:8 fhandle-type:1 f_handle:69f90400c275b5b4
2011*4882a593Smuzhiyun
2012*4882a593Smuzhiyunwhere fanotify 'flags' and 'event-flags' are values used in fanotify_init
2013*4882a593Smuzhiyuncall, 'mnt_id' is the mount point identifier, 'mflags' is the value of
2014*4882a593Smuzhiyunflags associated with mark which are tracked separately from events
2015*4882a593Smuzhiyunmask. 'ino' and 'sdev' are target inode and device, 'mask' is the events
2016*4882a593Smuzhiyunmask and 'ignored_mask' is the mask of events which are to be ignored.
2017*4882a593SmuzhiyunAll are in hex format. Incorporation of 'mflags', 'mask' and 'ignored_mask'
2018*4882a593Smuzhiyunprovide information about flags and mask used in fanotify_mark
2019*4882a593Smuzhiyuncall [see fsnotify manpage for details].
2020*4882a593Smuzhiyun
2021*4882a593SmuzhiyunWhile the first three lines are mandatory and always printed, the rest is
2022*4882a593Smuzhiyunoptional and may be omitted if no marks created yet.
2023*4882a593Smuzhiyun
2024*4882a593SmuzhiyunTimerfd files
2025*4882a593Smuzhiyun~~~~~~~~~~~~~
2026*4882a593Smuzhiyun
2027*4882a593Smuzhiyun::
2028*4882a593Smuzhiyun
2029*4882a593Smuzhiyun	pos:	0
2030*4882a593Smuzhiyun	flags:	02
2031*4882a593Smuzhiyun	mnt_id:	9
2032*4882a593Smuzhiyun	ino:	63107
2033*4882a593Smuzhiyun	clockid: 0
2034*4882a593Smuzhiyun	ticks: 0
2035*4882a593Smuzhiyun	settime flags: 01
2036*4882a593Smuzhiyun	it_value: (0, 49406829)
2037*4882a593Smuzhiyun	it_interval: (1, 0)
2038*4882a593Smuzhiyun
2039*4882a593Smuzhiyunwhere 'clockid' is the clock type and 'ticks' is the number of the timer expirations
2040*4882a593Smuzhiyunthat have occurred [see timerfd_create(2) for details]. 'settime flags' are
2041*4882a593Smuzhiyunflags in octal form been used to setup the timer [see timerfd_settime(2) for
2042*4882a593Smuzhiyundetails]. 'it_value' is remaining time until the timer expiration.
2043*4882a593Smuzhiyun'it_interval' is the interval for the timer. Note the timer might be set up
2044*4882a593Smuzhiyunwith TIMER_ABSTIME option which will be shown in 'settime flags', but 'it_value'
2045*4882a593Smuzhiyunstill exhibits timer's remaining time.
2046*4882a593Smuzhiyun
2047*4882a593SmuzhiyunDMA Buffer files
2048*4882a593Smuzhiyun~~~~~~~~~~~~~~~~
2049*4882a593Smuzhiyun
2050*4882a593Smuzhiyun::
2051*4882a593Smuzhiyun
2052*4882a593Smuzhiyun	pos:	0
2053*4882a593Smuzhiyun	flags:	04002
2054*4882a593Smuzhiyun	mnt_id:	9
2055*4882a593Smuzhiyun	ino:	63107
2056*4882a593Smuzhiyun	size:   32768
2057*4882a593Smuzhiyun	count:  2
2058*4882a593Smuzhiyun	exp_name:  system-heap
2059*4882a593Smuzhiyun
2060*4882a593Smuzhiyunwhere 'size' is the size of the DMA buffer in bytes. 'count' is the file count of
2061*4882a593Smuzhiyunthe DMA buffer file. 'exp_name' is the name of the DMA buffer exporter.
2062*4882a593Smuzhiyun
2063*4882a593Smuzhiyun3.9	/proc/<pid>/map_files - Information about memory mapped files
2064*4882a593Smuzhiyun---------------------------------------------------------------------
2065*4882a593SmuzhiyunThis directory contains symbolic links which represent memory mapped files
2066*4882a593Smuzhiyunthe process is maintaining.  Example output::
2067*4882a593Smuzhiyun
2068*4882a593Smuzhiyun     | lr-------- 1 root root 64 Jan 27 11:24 333c600000-333c620000 -> /usr/lib64/ld-2.18.so
2069*4882a593Smuzhiyun     | lr-------- 1 root root 64 Jan 27 11:24 333c81f000-333c820000 -> /usr/lib64/ld-2.18.so
2070*4882a593Smuzhiyun     | lr-------- 1 root root 64 Jan 27 11:24 333c820000-333c821000 -> /usr/lib64/ld-2.18.so
2071*4882a593Smuzhiyun     | ...
2072*4882a593Smuzhiyun     | lr-------- 1 root root 64 Jan 27 11:24 35d0421000-35d0422000 -> /usr/lib64/libselinux.so.1
2073*4882a593Smuzhiyun     | lr-------- 1 root root 64 Jan 27 11:24 400000-41a000 -> /usr/bin/ls
2074*4882a593Smuzhiyun
2075*4882a593SmuzhiyunThe name of a link represents the virtual memory bounds of a mapping, i.e.
2076*4882a593Smuzhiyunvm_area_struct::vm_start-vm_area_struct::vm_end.
2077*4882a593Smuzhiyun
2078*4882a593SmuzhiyunThe main purpose of the map_files is to retrieve a set of memory mapped
2079*4882a593Smuzhiyunfiles in a fast way instead of parsing /proc/<pid>/maps or
2080*4882a593Smuzhiyun/proc/<pid>/smaps, both of which contain many more records.  At the same
2081*4882a593Smuzhiyuntime one can open(2) mappings from the listings of two processes and
2082*4882a593Smuzhiyuncomparing their inode numbers to figure out which anonymous memory areas
2083*4882a593Smuzhiyunare actually shared.
2084*4882a593Smuzhiyun
2085*4882a593Smuzhiyun3.10	/proc/<pid>/timerslack_ns - Task timerslack value
2086*4882a593Smuzhiyun---------------------------------------------------------
2087*4882a593SmuzhiyunThis file provides the value of the task's timerslack value in nanoseconds.
2088*4882a593SmuzhiyunThis value specifies an amount of time that normal timers may be deferred
2089*4882a593Smuzhiyunin order to coalesce timers and avoid unnecessary wakeups.
2090*4882a593Smuzhiyun
2091*4882a593SmuzhiyunThis allows a task's interactivity vs power consumption tradeoff to be
2092*4882a593Smuzhiyunadjusted.
2093*4882a593Smuzhiyun
2094*4882a593SmuzhiyunWriting 0 to the file will set the task's timerslack to the default value.
2095*4882a593Smuzhiyun
2096*4882a593SmuzhiyunValid values are from 0 - ULLONG_MAX
2097*4882a593Smuzhiyun
2098*4882a593SmuzhiyunAn application setting the value must have PTRACE_MODE_ATTACH_FSCREDS level
2099*4882a593Smuzhiyunpermissions on the task specified to change its timerslack_ns value.
2100*4882a593Smuzhiyun
2101*4882a593Smuzhiyun3.11	/proc/<pid>/patch_state - Livepatch patch operation state
2102*4882a593Smuzhiyun-----------------------------------------------------------------
2103*4882a593SmuzhiyunWhen CONFIG_LIVEPATCH is enabled, this file displays the value of the
2104*4882a593Smuzhiyunpatch state for the task.
2105*4882a593Smuzhiyun
2106*4882a593SmuzhiyunA value of '-1' indicates that no patch is in transition.
2107*4882a593Smuzhiyun
2108*4882a593SmuzhiyunA value of '0' indicates that a patch is in transition and the task is
2109*4882a593Smuzhiyununpatched.  If the patch is being enabled, then the task hasn't been
2110*4882a593Smuzhiyunpatched yet.  If the patch is being disabled, then the task has already
2111*4882a593Smuzhiyunbeen unpatched.
2112*4882a593Smuzhiyun
2113*4882a593SmuzhiyunA value of '1' indicates that a patch is in transition and the task is
2114*4882a593Smuzhiyunpatched.  If the patch is being enabled, then the task has already been
2115*4882a593Smuzhiyunpatched.  If the patch is being disabled, then the task hasn't been
2116*4882a593Smuzhiyununpatched yet.
2117*4882a593Smuzhiyun
2118*4882a593Smuzhiyun3.12 /proc/<pid>/arch_status - task architecture specific status
2119*4882a593Smuzhiyun-------------------------------------------------------------------
2120*4882a593SmuzhiyunWhen CONFIG_PROC_PID_ARCH_STATUS is enabled, this file displays the
2121*4882a593Smuzhiyunarchitecture specific status of the task.
2122*4882a593Smuzhiyun
2123*4882a593SmuzhiyunExample
2124*4882a593Smuzhiyun~~~~~~~
2125*4882a593Smuzhiyun
2126*4882a593Smuzhiyun::
2127*4882a593Smuzhiyun
2128*4882a593Smuzhiyun $ cat /proc/6753/arch_status
2129*4882a593Smuzhiyun AVX512_elapsed_ms:      8
2130*4882a593Smuzhiyun
2131*4882a593SmuzhiyunDescription
2132*4882a593Smuzhiyun~~~~~~~~~~~
2133*4882a593Smuzhiyun
2134*4882a593Smuzhiyunx86 specific entries
2135*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~
2136*4882a593Smuzhiyun
2137*4882a593SmuzhiyunAVX512_elapsed_ms
2138*4882a593Smuzhiyun^^^^^^^^^^^^^^^^^^
2139*4882a593Smuzhiyun
2140*4882a593Smuzhiyun  If AVX512 is supported on the machine, this entry shows the milliseconds
2141*4882a593Smuzhiyun  elapsed since the last time AVX512 usage was recorded. The recording
2142*4882a593Smuzhiyun  happens on a best effort basis when a task is scheduled out. This means
2143*4882a593Smuzhiyun  that the value depends on two factors:
2144*4882a593Smuzhiyun
2145*4882a593Smuzhiyun    1) The time which the task spent on the CPU without being scheduled
2146*4882a593Smuzhiyun       out. With CPU isolation and a single runnable task this can take
2147*4882a593Smuzhiyun       several seconds.
2148*4882a593Smuzhiyun
2149*4882a593Smuzhiyun    2) The time since the task was scheduled out last. Depending on the
2150*4882a593Smuzhiyun       reason for being scheduled out (time slice exhausted, syscall ...)
2151*4882a593Smuzhiyun       this can be arbitrary long time.
2152*4882a593Smuzhiyun
2153*4882a593Smuzhiyun  As a consequence the value cannot be considered precise and authoritative
2154*4882a593Smuzhiyun  information. The application which uses this information has to be aware
2155*4882a593Smuzhiyun  of the overall scenario on the system in order to determine whether a
2156*4882a593Smuzhiyun  task is a real AVX512 user or not. Precise information can be obtained
2157*4882a593Smuzhiyun  with performance counters.
2158*4882a593Smuzhiyun
2159*4882a593Smuzhiyun  A special value of '-1' indicates that no AVX512 usage was recorded, thus
2160*4882a593Smuzhiyun  the task is unlikely an AVX512 user, but depends on the workload and the
2161*4882a593Smuzhiyun  scheduling scenario, it also could be a false negative mentioned above.
2162*4882a593Smuzhiyun
2163*4882a593SmuzhiyunChapter 4: Configuring procfs
2164*4882a593Smuzhiyun=============================
2165*4882a593Smuzhiyun
2166*4882a593Smuzhiyun4.1	Mount options
2167*4882a593Smuzhiyun---------------------
2168*4882a593Smuzhiyun
2169*4882a593SmuzhiyunThe following mount options are supported:
2170*4882a593Smuzhiyun
2171*4882a593Smuzhiyun	=========	========================================================
2172*4882a593Smuzhiyun	hidepid=	Set /proc/<pid>/ access mode.
2173*4882a593Smuzhiyun	gid=		Set the group authorized to learn processes information.
2174*4882a593Smuzhiyun	subset=		Show only the specified subset of procfs.
2175*4882a593Smuzhiyun	=========	========================================================
2176*4882a593Smuzhiyun
2177*4882a593Smuzhiyunhidepid=off or hidepid=0 means classic mode - everybody may access all
2178*4882a593Smuzhiyun/proc/<pid>/ directories (default).
2179*4882a593Smuzhiyun
2180*4882a593Smuzhiyunhidepid=noaccess or hidepid=1 means users may not access any /proc/<pid>/
2181*4882a593Smuzhiyundirectories but their own.  Sensitive files like cmdline, sched*, status are now
2182*4882a593Smuzhiyunprotected against other users.  This makes it impossible to learn whether any
2183*4882a593Smuzhiyunuser runs specific program (given the program doesn't reveal itself by its
2184*4882a593Smuzhiyunbehaviour).  As an additional bonus, as /proc/<pid>/cmdline is unaccessible for
2185*4882a593Smuzhiyunother users, poorly written programs passing sensitive information via program
2186*4882a593Smuzhiyunarguments are now protected against local eavesdroppers.
2187*4882a593Smuzhiyun
2188*4882a593Smuzhiyunhidepid=invisible or hidepid=2 means hidepid=1 plus all /proc/<pid>/ will be
2189*4882a593Smuzhiyunfully invisible to other users.  It doesn't mean that it hides a fact whether a
2190*4882a593Smuzhiyunprocess with a specific pid value exists (it can be learned by other means, e.g.
2191*4882a593Smuzhiyunby "kill -0 $PID"), but it hides process' uid and gid, which may be learned by
2192*4882a593Smuzhiyunstat()'ing /proc/<pid>/ otherwise.  It greatly complicates an intruder's task of
2193*4882a593Smuzhiyungathering information about running processes, whether some daemon runs with
2194*4882a593Smuzhiyunelevated privileges, whether other user runs some sensitive program, whether
2195*4882a593Smuzhiyunother users run any program at all, etc.
2196*4882a593Smuzhiyun
2197*4882a593Smuzhiyunhidepid=ptraceable or hidepid=4 means that procfs should only contain
2198*4882a593Smuzhiyun/proc/<pid>/ directories that the caller can ptrace.
2199*4882a593Smuzhiyun
2200*4882a593Smuzhiyungid= defines a group authorized to learn processes information otherwise
2201*4882a593Smuzhiyunprohibited by hidepid=.  If you use some daemon like identd which needs to learn
2202*4882a593Smuzhiyuninformation about processes information, just add identd to this group.
2203*4882a593Smuzhiyun
2204*4882a593Smuzhiyunsubset=pid hides all top level files and directories in the procfs that
2205*4882a593Smuzhiyunare not related to tasks.
2206*4882a593Smuzhiyun
2207*4882a593SmuzhiyunChapter 5: Filesystem behavior
2208*4882a593Smuzhiyun==============================
2209*4882a593Smuzhiyun
2210*4882a593SmuzhiyunOriginally, before the advent of pid namepsace, procfs was a global file
2211*4882a593Smuzhiyunsystem. It means that there was only one procfs instance in the system.
2212*4882a593Smuzhiyun
2213*4882a593SmuzhiyunWhen pid namespace was added, a separate procfs instance was mounted in
2214*4882a593Smuzhiyuneach pid namespace. So, procfs mount options are global among all
2215*4882a593Smuzhiyunmountpoints within the same namespace::
2216*4882a593Smuzhiyun
2217*4882a593Smuzhiyun	# grep ^proc /proc/mounts
2218*4882a593Smuzhiyun	proc /proc proc rw,relatime,hidepid=2 0 0
2219*4882a593Smuzhiyun
2220*4882a593Smuzhiyun	# strace -e mount mount -o hidepid=1 -t proc proc /tmp/proc
2221*4882a593Smuzhiyun	mount("proc", "/tmp/proc", "proc", 0, "hidepid=1") = 0
2222*4882a593Smuzhiyun	+++ exited with 0 +++
2223*4882a593Smuzhiyun
2224*4882a593Smuzhiyun	# grep ^proc /proc/mounts
2225*4882a593Smuzhiyun	proc /proc proc rw,relatime,hidepid=2 0 0
2226*4882a593Smuzhiyun	proc /tmp/proc proc rw,relatime,hidepid=2 0 0
2227*4882a593Smuzhiyun
2228*4882a593Smuzhiyunand only after remounting procfs mount options will change at all
2229*4882a593Smuzhiyunmountpoints::
2230*4882a593Smuzhiyun
2231*4882a593Smuzhiyun	# mount -o remount,hidepid=1 -t proc proc /tmp/proc
2232*4882a593Smuzhiyun
2233*4882a593Smuzhiyun	# grep ^proc /proc/mounts
2234*4882a593Smuzhiyun	proc /proc proc rw,relatime,hidepid=1 0 0
2235*4882a593Smuzhiyun	proc /tmp/proc proc rw,relatime,hidepid=1 0 0
2236*4882a593Smuzhiyun
2237*4882a593SmuzhiyunThis behavior is different from the behavior of other filesystems.
2238*4882a593Smuzhiyun
2239*4882a593SmuzhiyunThe new procfs behavior is more like other filesystems. Each procfs mount
2240*4882a593Smuzhiyuncreates a new procfs instance. Mount options affect own procfs instance.
2241*4882a593SmuzhiyunIt means that it became possible to have several procfs instances
2242*4882a593Smuzhiyundisplaying tasks with different filtering options in one pid namespace::
2243*4882a593Smuzhiyun
2244*4882a593Smuzhiyun	# mount -o hidepid=invisible -t proc proc /proc
2245*4882a593Smuzhiyun	# mount -o hidepid=noaccess -t proc proc /tmp/proc
2246*4882a593Smuzhiyun	# grep ^proc /proc/mounts
2247*4882a593Smuzhiyun	proc /proc proc rw,relatime,hidepid=invisible 0 0
2248*4882a593Smuzhiyun	proc /tmp/proc proc rw,relatime,hidepid=noaccess 0 0
2249