162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci====================
462306a36Sopenharmony_ciThe /proc Filesystem
562306a36Sopenharmony_ci====================
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci=====================  =======================================  ================
862306a36Sopenharmony_ci/proc/sys              Terrehon Bowden <terrehon@pacbell.net>,  October 7 1999
962306a36Sopenharmony_ci                       Bodo Bauer <bb@ricochet.net>
1062306a36Sopenharmony_ci2.4.x update	       Jorge Nerin <comandante@zaralinux.com>   November 14 2000
1162306a36Sopenharmony_cimove /proc/sys	       Shen Feng <shen@cn.fujitsu.com>	        April 1 2009
1262306a36Sopenharmony_cifixes/update part 1.1  Stefani Seibold <stefani@seibold.net>    June 9 2009
1362306a36Sopenharmony_ci=====================  =======================================  ================
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci.. Table of Contents
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci  0     Preface
2062306a36Sopenharmony_ci  0.1	Introduction/Credits
2162306a36Sopenharmony_ci  0.2	Legal Stuff
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci  1	Collecting System Information
2462306a36Sopenharmony_ci  1.1	Process-Specific Subdirectories
2562306a36Sopenharmony_ci  1.2	Kernel data
2662306a36Sopenharmony_ci  1.3	IDE devices in /proc/ide
2762306a36Sopenharmony_ci  1.4	Networking info in /proc/net
2862306a36Sopenharmony_ci  1.5	SCSI info
2962306a36Sopenharmony_ci  1.6	Parallel port info in /proc/parport
3062306a36Sopenharmony_ci  1.7	TTY info in /proc/tty
3162306a36Sopenharmony_ci  1.8	Miscellaneous kernel statistics in /proc/stat
3262306a36Sopenharmony_ci  1.9	Ext4 file system parameters
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci  2	Modifying System Parameters
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci  3	Per-Process Parameters
3762306a36Sopenharmony_ci  3.1	/proc/<pid>/oom_adj & /proc/<pid>/oom_score_adj - Adjust the oom-killer
3862306a36Sopenharmony_ci								score
3962306a36Sopenharmony_ci  3.2	/proc/<pid>/oom_score - Display current oom-killer score
4062306a36Sopenharmony_ci  3.3	/proc/<pid>/io - Display the IO accounting fields
4162306a36Sopenharmony_ci  3.4	/proc/<pid>/coredump_filter - Core dump filtering settings
4262306a36Sopenharmony_ci  3.5	/proc/<pid>/mountinfo - Information about mounts
4362306a36Sopenharmony_ci  3.6	/proc/<pid>/comm  & /proc/<pid>/task/<tid>/comm
4462306a36Sopenharmony_ci  3.7   /proc/<pid>/task/<tid>/children - Information about task children
4562306a36Sopenharmony_ci  3.8   /proc/<pid>/fdinfo/<fd> - Information about opened file
4662306a36Sopenharmony_ci  3.9   /proc/<pid>/map_files - Information about memory mapped files
4762306a36Sopenharmony_ci  3.10  /proc/<pid>/timerslack_ns - Task timerslack value
4862306a36Sopenharmony_ci  3.11	/proc/<pid>/patch_state - Livepatch patch operation state
4962306a36Sopenharmony_ci  3.12	/proc/<pid>/arch_status - Task architecture specific information
5062306a36Sopenharmony_ci  3.13  /proc/<pid>/fd - List of symlinks to open files
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci  4	Configuring procfs
5362306a36Sopenharmony_ci  4.1	Mount options
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci  5	Filesystem behavior
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ciPreface
5862306a36Sopenharmony_ci=======
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci0.1 Introduction/Credits
6162306a36Sopenharmony_ci------------------------
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ciThis documentation is  part of a soon (or  so we hope) to be  released book on
6462306a36Sopenharmony_cithe SuSE  Linux distribution. As  there is  no complete documentation  for the
6562306a36Sopenharmony_ci/proc file system and we've used  many freely available sources to write these
6662306a36Sopenharmony_cichapters, it  seems only fair  to give the work  back to the  Linux community.
6762306a36Sopenharmony_ciThis work is  based on the 2.2.*  kernel version and the  upcoming 2.4.*. I'm
6862306a36Sopenharmony_ciafraid it's still far from complete, but we  hope it will be useful. As far as
6962306a36Sopenharmony_ciwe know, it is the first 'all-in-one' document about the /proc file system. It
7062306a36Sopenharmony_ciis focused  on the Intel  x86 hardware,  so if you  are looking for  PPC, ARM,
7162306a36Sopenharmony_ciSPARC, AXP, etc., features, you probably  won't find what you are looking for.
7262306a36Sopenharmony_ciIt also only covers IPv4 networking, not IPv6 nor other protocols - sorry. But
7362306a36Sopenharmony_ciadditions and patches  are welcome and will  be added to this  document if you
7462306a36Sopenharmony_cimail them to Bodo.
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ciWe'd like  to  thank Alan Cox, Rik van Riel, and Alexey Kuznetsov and a lot of
7762306a36Sopenharmony_ciother people for help compiling this documentation. We'd also like to extend a
7862306a36Sopenharmony_cispecial thank  you to Andi Kleen for documentation, which we relied on heavily
7962306a36Sopenharmony_cito create  this  document,  as well as the additional information he provided.
8062306a36Sopenharmony_ciThanks to  everybody  else  who contributed source or docs to the Linux kernel
8162306a36Sopenharmony_ciand helped create a great piece of software... :)
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ciIf you  have  any comments, corrections or additions, please don't hesitate to
8462306a36Sopenharmony_cicontact Bodo  Bauer  at  bb@ricochet.net.  We'll  be happy to add them to this
8562306a36Sopenharmony_cidocument.
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ciThe   latest   version    of   this   document   is    available   online   at
8862306a36Sopenharmony_cihttps://www.kernel.org/doc/html/latest/filesystems/proc.html
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ciIf  the above  direction does  not works  for you,  you could  try the  kernel
9162306a36Sopenharmony_cimailing  list  at  linux-kernel@vger.kernel.org  and/or try  to  reach  me  at
9262306a36Sopenharmony_cicomandante@zaralinux.com.
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci0.2 Legal Stuff
9562306a36Sopenharmony_ci---------------
9662306a36Sopenharmony_ci
9762306a36Sopenharmony_ciWe don't  guarantee  the  correctness  of this document, and if you come to us
9862306a36Sopenharmony_cicomplaining about  how  you  screwed  up  your  system  because  of  incorrect
9962306a36Sopenharmony_cidocumentation, we won't feel responsible...
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ciChapter 1: Collecting System Information
10262306a36Sopenharmony_ci========================================
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ciIn This Chapter
10562306a36Sopenharmony_ci---------------
10662306a36Sopenharmony_ci* Investigating  the  properties  of  the  pseudo  file  system  /proc and its
10762306a36Sopenharmony_ci  ability to provide information on the running Linux system
10862306a36Sopenharmony_ci* Examining /proc's structure
10962306a36Sopenharmony_ci* Uncovering  various  information  about the kernel and the processes running
11062306a36Sopenharmony_ci  on the system
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci------------------------------------------------------------------------------
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ciThe proc  file  system acts as an interface to internal data structures in the
11562306a36Sopenharmony_cikernel. It  can  be  used to obtain information about the system and to change
11662306a36Sopenharmony_cicertain kernel parameters at runtime (sysctl).
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ciFirst, we'll  take  a  look  at the read-only parts of /proc. In Chapter 2, we
11962306a36Sopenharmony_cishow you how you can use /proc/sys to change settings.
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci1.1 Process-Specific Subdirectories
12262306a36Sopenharmony_ci-----------------------------------
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ciThe directory  /proc  contains  (among other things) one subdirectory for each
12562306a36Sopenharmony_ciprocess running on the system, which is named after the process ID (PID).
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ciThe link  'self'  points to  the process reading the file system. Each process
12862306a36Sopenharmony_cisubdirectory has the entries listed in Table 1-1.
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ciNote that an open file descriptor to /proc/<pid> or to any of its
13162306a36Sopenharmony_cicontained files or subdirectories does not prevent <pid> being reused
13262306a36Sopenharmony_cifor some other process in the event that <pid> exits. Operations on
13362306a36Sopenharmony_ciopen /proc/<pid> file descriptors corresponding to dead processes
13462306a36Sopenharmony_cinever act on any new process that the kernel may, through chance, have
13562306a36Sopenharmony_cialso assigned the process ID <pid>. Instead, operations on these FDs
13662306a36Sopenharmony_ciusually fail with ESRCH.
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci.. table:: Table 1-1: Process specific entries in /proc
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci =============  ===============================================================
14162306a36Sopenharmony_ci File		Content
14262306a36Sopenharmony_ci =============  ===============================================================
14362306a36Sopenharmony_ci clear_refs	Clears page referenced bits shown in smaps output
14462306a36Sopenharmony_ci cmdline	Command line arguments
14562306a36Sopenharmony_ci cpu		Current and last cpu in which it was executed	(2.4)(smp)
14662306a36Sopenharmony_ci cwd		Link to the current working directory
14762306a36Sopenharmony_ci environ	Values of environment variables
14862306a36Sopenharmony_ci exe		Link to the executable of this process
14962306a36Sopenharmony_ci fd		Directory, which contains all file descriptors
15062306a36Sopenharmony_ci maps		Memory maps to executables and library files	(2.4)
15162306a36Sopenharmony_ci mem		Memory held by this process
15262306a36Sopenharmony_ci root		Link to the root directory of this process
15362306a36Sopenharmony_ci stat		Process status
15462306a36Sopenharmony_ci statm		Process memory status information
15562306a36Sopenharmony_ci status		Process status in human readable form
15662306a36Sopenharmony_ci wchan		Present with CONFIG_KALLSYMS=y: it shows the kernel function
15762306a36Sopenharmony_ci		symbol the task is blocked in - or "0" if not blocked.
15862306a36Sopenharmony_ci pagemap	Page table
15962306a36Sopenharmony_ci stack		Report full stack trace, enable via CONFIG_STACKTRACE
16062306a36Sopenharmony_ci smaps		An extension based on maps, showing the memory consumption of
16162306a36Sopenharmony_ci		each mapping and flags associated with it
16262306a36Sopenharmony_ci smaps_rollup	Accumulated smaps stats for all mappings of the process.  This
16362306a36Sopenharmony_ci		can be derived from smaps, but is faster and more convenient
16462306a36Sopenharmony_ci numa_maps	An extension based on maps, showing the memory locality and
16562306a36Sopenharmony_ci		binding policy as well as mem usage (in pages) of each mapping.
16662306a36Sopenharmony_ci =============  ===============================================================
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ciFor example, to get the status information of a process, all you have to do is
16962306a36Sopenharmony_ciread the file /proc/PID/status::
17062306a36Sopenharmony_ci
17162306a36Sopenharmony_ci  >cat /proc/self/status
17262306a36Sopenharmony_ci  Name:   cat
17362306a36Sopenharmony_ci  State:  R (running)
17462306a36Sopenharmony_ci  Tgid:   5452
17562306a36Sopenharmony_ci  Pid:    5452
17662306a36Sopenharmony_ci  PPid:   743
17762306a36Sopenharmony_ci  TracerPid:      0						(2.4)
17862306a36Sopenharmony_ci  Uid:    501     501     501     501
17962306a36Sopenharmony_ci  Gid:    100     100     100     100
18062306a36Sopenharmony_ci  FDSize: 256
18162306a36Sopenharmony_ci  Groups: 100 14 16
18262306a36Sopenharmony_ci  Kthread:    0
18362306a36Sopenharmony_ci  VmPeak:     5004 kB
18462306a36Sopenharmony_ci  VmSize:     5004 kB
18562306a36Sopenharmony_ci  VmLck:         0 kB
18662306a36Sopenharmony_ci  VmHWM:       476 kB
18762306a36Sopenharmony_ci  VmRSS:       476 kB
18862306a36Sopenharmony_ci  RssAnon:             352 kB
18962306a36Sopenharmony_ci  RssFile:             120 kB
19062306a36Sopenharmony_ci  RssShmem:              4 kB
19162306a36Sopenharmony_ci  VmData:      156 kB
19262306a36Sopenharmony_ci  VmStk:        88 kB
19362306a36Sopenharmony_ci  VmExe:        68 kB
19462306a36Sopenharmony_ci  VmLib:      1412 kB
19562306a36Sopenharmony_ci  VmPTE:        20 kb
19662306a36Sopenharmony_ci  VmSwap:        0 kB
19762306a36Sopenharmony_ci  HugetlbPages:          0 kB
19862306a36Sopenharmony_ci  CoreDumping:    0
19962306a36Sopenharmony_ci  THP_enabled:	  1
20062306a36Sopenharmony_ci  Threads:        1
20162306a36Sopenharmony_ci  SigQ:   0/28578
20262306a36Sopenharmony_ci  SigPnd: 0000000000000000
20362306a36Sopenharmony_ci  ShdPnd: 0000000000000000
20462306a36Sopenharmony_ci  SigBlk: 0000000000000000
20562306a36Sopenharmony_ci  SigIgn: 0000000000000000
20662306a36Sopenharmony_ci  SigCgt: 0000000000000000
20762306a36Sopenharmony_ci  CapInh: 00000000fffffeff
20862306a36Sopenharmony_ci  CapPrm: 0000000000000000
20962306a36Sopenharmony_ci  CapEff: 0000000000000000
21062306a36Sopenharmony_ci  CapBnd: ffffffffffffffff
21162306a36Sopenharmony_ci  CapAmb: 0000000000000000
21262306a36Sopenharmony_ci  NoNewPrivs:     0
21362306a36Sopenharmony_ci  Seccomp:        0
21462306a36Sopenharmony_ci  Speculation_Store_Bypass:       thread vulnerable
21562306a36Sopenharmony_ci  SpeculationIndirectBranch:      conditional enabled
21662306a36Sopenharmony_ci  voluntary_ctxt_switches:        0
21762306a36Sopenharmony_ci  nonvoluntary_ctxt_switches:     1
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_ciThis shows you nearly the same information you would get if you viewed it with
22062306a36Sopenharmony_cithe ps  command.  In  fact,  ps  uses  the  proc  file  system  to  obtain its
22162306a36Sopenharmony_ciinformation.  But you get a more detailed  view of the  process by reading the
22262306a36Sopenharmony_cifile /proc/PID/status. It fields are described in table 1-2.
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ciThe  statm  file  contains  more  detailed  information about the process
22562306a36Sopenharmony_cimemory usage. Its seven fields are explained in Table 1-3.  The stat file
22662306a36Sopenharmony_cicontains detailed information about the process itself.  Its fields are
22762306a36Sopenharmony_ciexplained in Table 1-4.
22862306a36Sopenharmony_ci
22962306a36Sopenharmony_ci(for SMP CONFIG users)
23062306a36Sopenharmony_ci
23162306a36Sopenharmony_ciFor making accounting scalable, RSS related information are handled in an
23262306a36Sopenharmony_ciasynchronous manner and the value may not be very precise. To see a precise
23362306a36Sopenharmony_cisnapshot of a moment, you can see /proc/<pid>/smaps file and scan page table.
23462306a36Sopenharmony_ciIt's slow but very precise.
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_ci.. table:: Table 1-2: Contents of the status fields (as of 4.19)
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ci ==========================  ===================================================
23962306a36Sopenharmony_ci Field                       Content
24062306a36Sopenharmony_ci ==========================  ===================================================
24162306a36Sopenharmony_ci Name                        filename of the executable
24262306a36Sopenharmony_ci Umask                       file mode creation mask
24362306a36Sopenharmony_ci State                       state (R is running, S is sleeping, D is sleeping
24462306a36Sopenharmony_ci                             in an uninterruptible wait, Z is zombie,
24562306a36Sopenharmony_ci			     T is traced or stopped)
24662306a36Sopenharmony_ci Tgid                        thread group ID
24762306a36Sopenharmony_ci Ngid                        NUMA group ID (0 if none)
24862306a36Sopenharmony_ci Pid                         process id
24962306a36Sopenharmony_ci PPid                        process id of the parent process
25062306a36Sopenharmony_ci TracerPid                   PID of process tracing this process (0 if not, or
25162306a36Sopenharmony_ci                             the tracer is outside of the current pid namespace)
25262306a36Sopenharmony_ci Uid                         Real, effective, saved set, and  file system UIDs
25362306a36Sopenharmony_ci Gid                         Real, effective, saved set, and  file system GIDs
25462306a36Sopenharmony_ci FDSize                      number of file descriptor slots currently allocated
25562306a36Sopenharmony_ci Groups                      supplementary group list
25662306a36Sopenharmony_ci NStgid                      descendant namespace thread group ID hierarchy
25762306a36Sopenharmony_ci NSpid                       descendant namespace process ID hierarchy
25862306a36Sopenharmony_ci NSpgid                      descendant namespace process group ID hierarchy
25962306a36Sopenharmony_ci NSsid                       descendant namespace session ID hierarchy
26062306a36Sopenharmony_ci Kthread                     kernel thread flag, 1 is yes, 0 is no
26162306a36Sopenharmony_ci VmPeak                      peak virtual memory size
26262306a36Sopenharmony_ci VmSize                      total program size
26362306a36Sopenharmony_ci VmLck                       locked memory size
26462306a36Sopenharmony_ci VmPin                       pinned memory size
26562306a36Sopenharmony_ci VmHWM                       peak resident set size ("high water mark")
26662306a36Sopenharmony_ci VmRSS                       size of memory portions. It contains the three
26762306a36Sopenharmony_ci                             following parts
26862306a36Sopenharmony_ci                             (VmRSS = RssAnon + RssFile + RssShmem)
26962306a36Sopenharmony_ci RssAnon                     size of resident anonymous memory
27062306a36Sopenharmony_ci RssFile                     size of resident file mappings
27162306a36Sopenharmony_ci RssShmem                    size of resident shmem memory (includes SysV shm,
27262306a36Sopenharmony_ci                             mapping of tmpfs and shared anonymous mappings)
27362306a36Sopenharmony_ci VmData                      size of private data segments
27462306a36Sopenharmony_ci VmStk                       size of stack segments
27562306a36Sopenharmony_ci VmExe                       size of text segment
27662306a36Sopenharmony_ci VmLib                       size of shared library code
27762306a36Sopenharmony_ci VmPTE                       size of page table entries
27862306a36Sopenharmony_ci VmSwap                      amount of swap used by anonymous private data
27962306a36Sopenharmony_ci                             (shmem swap usage is not included)
28062306a36Sopenharmony_ci HugetlbPages                size of hugetlb memory portions
28162306a36Sopenharmony_ci CoreDumping                 process's memory is currently being dumped
28262306a36Sopenharmony_ci                             (killing the process may lead to a corrupted core)
28362306a36Sopenharmony_ci THP_enabled		     process is allowed to use THP (returns 0 when
28462306a36Sopenharmony_ci			     PR_SET_THP_DISABLE is set on the process
28562306a36Sopenharmony_ci Threads                     number of threads
28662306a36Sopenharmony_ci SigQ                        number of signals queued/max. number for queue
28762306a36Sopenharmony_ci SigPnd                      bitmap of pending signals for the thread
28862306a36Sopenharmony_ci ShdPnd                      bitmap of shared pending signals for the process
28962306a36Sopenharmony_ci SigBlk                      bitmap of blocked signals
29062306a36Sopenharmony_ci SigIgn                      bitmap of ignored signals
29162306a36Sopenharmony_ci SigCgt                      bitmap of caught signals
29262306a36Sopenharmony_ci CapInh                      bitmap of inheritable capabilities
29362306a36Sopenharmony_ci CapPrm                      bitmap of permitted capabilities
29462306a36Sopenharmony_ci CapEff                      bitmap of effective capabilities
29562306a36Sopenharmony_ci CapBnd                      bitmap of capabilities bounding set
29662306a36Sopenharmony_ci CapAmb                      bitmap of ambient capabilities
29762306a36Sopenharmony_ci NoNewPrivs                  no_new_privs, like prctl(PR_GET_NO_NEW_PRIV, ...)
29862306a36Sopenharmony_ci Seccomp                     seccomp mode, like prctl(PR_GET_SECCOMP, ...)
29962306a36Sopenharmony_ci Speculation_Store_Bypass    speculative store bypass mitigation status
30062306a36Sopenharmony_ci SpeculationIndirectBranch   indirect branch speculation mode
30162306a36Sopenharmony_ci Cpus_allowed                mask of CPUs on which this process may run
30262306a36Sopenharmony_ci Cpus_allowed_list           Same as previous, but in "list format"
30362306a36Sopenharmony_ci Mems_allowed                mask of memory nodes allowed to this process
30462306a36Sopenharmony_ci Mems_allowed_list           Same as previous, but in "list format"
30562306a36Sopenharmony_ci voluntary_ctxt_switches     number of voluntary context switches
30662306a36Sopenharmony_ci nonvoluntary_ctxt_switches  number of non voluntary context switches
30762306a36Sopenharmony_ci ==========================  ===================================================
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_ci
31062306a36Sopenharmony_ci.. table:: Table 1-3: Contents of the statm fields (as of 2.6.8-rc3)
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_ci ======== ===============================	==============================
31362306a36Sopenharmony_ci Field    Content
31462306a36Sopenharmony_ci ======== ===============================	==============================
31562306a36Sopenharmony_ci size     total program size (pages)		(same as VmSize in status)
31662306a36Sopenharmony_ci resident size of memory portions (pages)	(same as VmRSS in status)
31762306a36Sopenharmony_ci shared   number of pages that are shared	(i.e. backed by a file, same
31862306a36Sopenharmony_ci						as RssFile+RssShmem in status)
31962306a36Sopenharmony_ci trs      number of pages that are 'code'	(not including libs; broken,
32062306a36Sopenharmony_ci						includes data segment)
32162306a36Sopenharmony_ci lrs      number of pages of library		(always 0 on 2.6)
32262306a36Sopenharmony_ci drs      number of pages of data/stack		(including libs; broken,
32362306a36Sopenharmony_ci						includes library text)
32462306a36Sopenharmony_ci dt       number of dirty pages			(always 0 on 2.6)
32562306a36Sopenharmony_ci ======== ===============================	==============================
32662306a36Sopenharmony_ci
32762306a36Sopenharmony_ci
32862306a36Sopenharmony_ci.. table:: Table 1-4: Contents of the stat fields (as of 2.6.30-rc7)
32962306a36Sopenharmony_ci
33062306a36Sopenharmony_ci  ============= ===============================================================
33162306a36Sopenharmony_ci  Field         Content
33262306a36Sopenharmony_ci  ============= ===============================================================
33362306a36Sopenharmony_ci  pid           process id
33462306a36Sopenharmony_ci  tcomm         filename of the executable
33562306a36Sopenharmony_ci  state         state (R is running, S is sleeping, D is sleeping in an
33662306a36Sopenharmony_ci                uninterruptible wait, Z is zombie, T is traced or stopped)
33762306a36Sopenharmony_ci  ppid          process id of the parent process
33862306a36Sopenharmony_ci  pgrp          pgrp of the process
33962306a36Sopenharmony_ci  sid           session id
34062306a36Sopenharmony_ci  tty_nr        tty the process uses
34162306a36Sopenharmony_ci  tty_pgrp      pgrp of the tty
34262306a36Sopenharmony_ci  flags         task flags
34362306a36Sopenharmony_ci  min_flt       number of minor faults
34462306a36Sopenharmony_ci  cmin_flt      number of minor faults with child's
34562306a36Sopenharmony_ci  maj_flt       number of major faults
34662306a36Sopenharmony_ci  cmaj_flt      number of major faults with child's
34762306a36Sopenharmony_ci  utime         user mode jiffies
34862306a36Sopenharmony_ci  stime         kernel mode jiffies
34962306a36Sopenharmony_ci  cutime        user mode jiffies with child's
35062306a36Sopenharmony_ci  cstime        kernel mode jiffies with child's
35162306a36Sopenharmony_ci  priority      priority level
35262306a36Sopenharmony_ci  nice          nice level
35362306a36Sopenharmony_ci  num_threads   number of threads
35462306a36Sopenharmony_ci  it_real_value	(obsolete, always 0)
35562306a36Sopenharmony_ci  start_time    time the process started after system boot
35662306a36Sopenharmony_ci  vsize         virtual memory size
35762306a36Sopenharmony_ci  rss           resident set memory size
35862306a36Sopenharmony_ci  rsslim        current limit in bytes on the rss
35962306a36Sopenharmony_ci  start_code    address above which program text can run
36062306a36Sopenharmony_ci  end_code      address below which program text can run
36162306a36Sopenharmony_ci  start_stack   address of the start of the main process stack
36262306a36Sopenharmony_ci  esp           current value of ESP
36362306a36Sopenharmony_ci  eip           current value of EIP
36462306a36Sopenharmony_ci  pending       bitmap of pending signals
36562306a36Sopenharmony_ci  blocked       bitmap of blocked signals
36662306a36Sopenharmony_ci  sigign        bitmap of ignored signals
36762306a36Sopenharmony_ci  sigcatch      bitmap of caught signals
36862306a36Sopenharmony_ci  0		(place holder, used to be the wchan address,
36962306a36Sopenharmony_ci		use /proc/PID/wchan instead)
37062306a36Sopenharmony_ci  0             (place holder)
37162306a36Sopenharmony_ci  0             (place holder)
37262306a36Sopenharmony_ci  exit_signal   signal to send to parent thread on exit
37362306a36Sopenharmony_ci  task_cpu      which CPU the task is scheduled on
37462306a36Sopenharmony_ci  rt_priority   realtime priority
37562306a36Sopenharmony_ci  policy        scheduling policy (man sched_setscheduler)
37662306a36Sopenharmony_ci  blkio_ticks   time spent waiting for block IO
37762306a36Sopenharmony_ci  gtime         guest time of the task in jiffies
37862306a36Sopenharmony_ci  cgtime        guest time of the task children in jiffies
37962306a36Sopenharmony_ci  start_data    address above which program data+bss is placed
38062306a36Sopenharmony_ci  end_data      address below which program data+bss is placed
38162306a36Sopenharmony_ci  start_brk     address above which program heap can be expanded with brk()
38262306a36Sopenharmony_ci  arg_start     address above which program command line is placed
38362306a36Sopenharmony_ci  arg_end       address below which program command line is placed
38462306a36Sopenharmony_ci  env_start     address above which program environment is placed
38562306a36Sopenharmony_ci  env_end       address below which program environment is placed
38662306a36Sopenharmony_ci  exit_code     the thread's exit_code in the form reported by the waitpid
38762306a36Sopenharmony_ci		system call
38862306a36Sopenharmony_ci  ============= ===============================================================
38962306a36Sopenharmony_ci
39062306a36Sopenharmony_ciThe /proc/PID/maps file contains the currently mapped memory regions and
39162306a36Sopenharmony_citheir access permissions.
39262306a36Sopenharmony_ci
39362306a36Sopenharmony_ciThe format is::
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_ci    address           perms offset  dev   inode      pathname
39662306a36Sopenharmony_ci
39762306a36Sopenharmony_ci    08048000-08049000 r-xp 00000000 03:00 8312       /opt/test
39862306a36Sopenharmony_ci    08049000-0804a000 rw-p 00001000 03:00 8312       /opt/test
39962306a36Sopenharmony_ci    0804a000-0806b000 rw-p 00000000 00:00 0          [heap]
40062306a36Sopenharmony_ci    a7cb1000-a7cb2000 ---p 00000000 00:00 0
40162306a36Sopenharmony_ci    a7cb2000-a7eb2000 rw-p 00000000 00:00 0
40262306a36Sopenharmony_ci    a7eb2000-a7eb3000 ---p 00000000 00:00 0
40362306a36Sopenharmony_ci    a7eb3000-a7ed5000 rw-p 00000000 00:00 0
40462306a36Sopenharmony_ci    a7ed5000-a8008000 r-xp 00000000 03:00 4222       /lib/libc.so.6
40562306a36Sopenharmony_ci    a8008000-a800a000 r--p 00133000 03:00 4222       /lib/libc.so.6
40662306a36Sopenharmony_ci    a800a000-a800b000 rw-p 00135000 03:00 4222       /lib/libc.so.6
40762306a36Sopenharmony_ci    a800b000-a800e000 rw-p 00000000 00:00 0
40862306a36Sopenharmony_ci    a800e000-a8022000 r-xp 00000000 03:00 14462      /lib/libpthread.so.0
40962306a36Sopenharmony_ci    a8022000-a8023000 r--p 00013000 03:00 14462      /lib/libpthread.so.0
41062306a36Sopenharmony_ci    a8023000-a8024000 rw-p 00014000 03:00 14462      /lib/libpthread.so.0
41162306a36Sopenharmony_ci    a8024000-a8027000 rw-p 00000000 00:00 0
41262306a36Sopenharmony_ci    a8027000-a8043000 r-xp 00000000 03:00 8317       /lib/ld-linux.so.2
41362306a36Sopenharmony_ci    a8043000-a8044000 r--p 0001b000 03:00 8317       /lib/ld-linux.so.2
41462306a36Sopenharmony_ci    a8044000-a8045000 rw-p 0001c000 03:00 8317       /lib/ld-linux.so.2
41562306a36Sopenharmony_ci    aff35000-aff4a000 rw-p 00000000 00:00 0          [stack]
41662306a36Sopenharmony_ci    ffffe000-fffff000 r-xp 00000000 00:00 0          [vdso]
41762306a36Sopenharmony_ci
41862306a36Sopenharmony_ciwhere "address" is the address space in the process that it occupies, "perms"
41962306a36Sopenharmony_ciis a set of permissions::
42062306a36Sopenharmony_ci
42162306a36Sopenharmony_ci r = read
42262306a36Sopenharmony_ci w = write
42362306a36Sopenharmony_ci x = execute
42462306a36Sopenharmony_ci s = shared
42562306a36Sopenharmony_ci p = private (copy on write)
42662306a36Sopenharmony_ci
42762306a36Sopenharmony_ci"offset" is the offset into the mapping, "dev" is the device (major:minor), and
42862306a36Sopenharmony_ci"inode" is the inode  on that device.  0 indicates that  no inode is associated
42962306a36Sopenharmony_ciwith the memory region, as the case would be with BSS (uninitialized data).
43062306a36Sopenharmony_ciThe "pathname" shows the name associated file for this mapping.  If the mapping
43162306a36Sopenharmony_ciis not associated with a file:
43262306a36Sopenharmony_ci
43362306a36Sopenharmony_ci ===================        ===========================================
43462306a36Sopenharmony_ci [heap]                     the heap of the program
43562306a36Sopenharmony_ci [stack]                    the stack of the main process
43662306a36Sopenharmony_ci [vdso]                     the "virtual dynamic shared object",
43762306a36Sopenharmony_ci                            the kernel system call handler
43862306a36Sopenharmony_ci [anon:<name>]              a private anonymous mapping that has been
43962306a36Sopenharmony_ci                            named by userspace
44062306a36Sopenharmony_ci [anon_shmem:<name>]        an anonymous shared memory mapping that has
44162306a36Sopenharmony_ci                            been named by userspace
44262306a36Sopenharmony_ci ===================        ===========================================
44362306a36Sopenharmony_ci
44462306a36Sopenharmony_ci or if empty, the mapping is anonymous.
44562306a36Sopenharmony_ci
44662306a36Sopenharmony_ciThe /proc/PID/smaps is an extension based on maps, showing the memory
44762306a36Sopenharmony_ciconsumption for each of the process's mappings. For each mapping (aka Virtual
44862306a36Sopenharmony_ciMemory Area, or VMA) there is a series of lines such as the following::
44962306a36Sopenharmony_ci
45062306a36Sopenharmony_ci    08048000-080bc000 r-xp 00000000 03:02 13130      /bin/bash
45162306a36Sopenharmony_ci
45262306a36Sopenharmony_ci    Size:               1084 kB
45362306a36Sopenharmony_ci    KernelPageSize:        4 kB
45462306a36Sopenharmony_ci    MMUPageSize:           4 kB
45562306a36Sopenharmony_ci    Rss:                 892 kB
45662306a36Sopenharmony_ci    Pss:                 374 kB
45762306a36Sopenharmony_ci    Pss_Dirty:             0 kB
45862306a36Sopenharmony_ci    Shared_Clean:        892 kB
45962306a36Sopenharmony_ci    Shared_Dirty:          0 kB
46062306a36Sopenharmony_ci    Private_Clean:         0 kB
46162306a36Sopenharmony_ci    Private_Dirty:         0 kB
46262306a36Sopenharmony_ci    Referenced:          892 kB
46362306a36Sopenharmony_ci    Anonymous:             0 kB
46462306a36Sopenharmony_ci    KSM:                   0 kB
46562306a36Sopenharmony_ci    LazyFree:              0 kB
46662306a36Sopenharmony_ci    AnonHugePages:         0 kB
46762306a36Sopenharmony_ci    ShmemPmdMapped:        0 kB
46862306a36Sopenharmony_ci    Shared_Hugetlb:        0 kB
46962306a36Sopenharmony_ci    Private_Hugetlb:       0 kB
47062306a36Sopenharmony_ci    Swap:                  0 kB
47162306a36Sopenharmony_ci    SwapPss:               0 kB
47262306a36Sopenharmony_ci    KernelPageSize:        4 kB
47362306a36Sopenharmony_ci    MMUPageSize:           4 kB
47462306a36Sopenharmony_ci    Locked:                0 kB
47562306a36Sopenharmony_ci    THPeligible:           0
47662306a36Sopenharmony_ci    VmFlags: rd ex mr mw me dw
47762306a36Sopenharmony_ci
47862306a36Sopenharmony_ciThe first of these lines shows the same information as is displayed for the
47962306a36Sopenharmony_cimapping in /proc/PID/maps.  Following lines show the size of the mapping
48062306a36Sopenharmony_ci(size); the size of each page allocated when backing a VMA (KernelPageSize),
48162306a36Sopenharmony_ciwhich is usually the same as the size in the page table entries; the page size
48262306a36Sopenharmony_ciused by the MMU when backing a VMA (in most cases, the same as KernelPageSize);
48362306a36Sopenharmony_cithe amount of the mapping that is currently resident in RAM (RSS); the
48462306a36Sopenharmony_ciprocess' proportional share of this mapping (PSS); and the number of clean and
48562306a36Sopenharmony_cidirty shared and private pages in the mapping.
48662306a36Sopenharmony_ci
48762306a36Sopenharmony_ciThe "proportional set size" (PSS) of a process is the count of pages it has
48862306a36Sopenharmony_ciin memory, where each page is divided by the number of processes sharing it.
48962306a36Sopenharmony_ciSo if a process has 1000 pages all to itself, and 1000 shared with one other
49062306a36Sopenharmony_ciprocess, its PSS will be 1500.  "Pss_Dirty" is the portion of PSS which
49162306a36Sopenharmony_ciconsists of dirty pages.  ("Pss_Clean" is not included, but it can be
49262306a36Sopenharmony_cicalculated by subtracting "Pss_Dirty" from "Pss".)
49362306a36Sopenharmony_ci
49462306a36Sopenharmony_ciNote that even a page which is part of a MAP_SHARED mapping, but has only
49562306a36Sopenharmony_cia single pte mapped, i.e.  is currently used by only one process, is accounted
49662306a36Sopenharmony_cias private and not as shared.
49762306a36Sopenharmony_ci
49862306a36Sopenharmony_ci"Referenced" indicates the amount of memory currently marked as referenced or
49962306a36Sopenharmony_ciaccessed.
50062306a36Sopenharmony_ci
50162306a36Sopenharmony_ci"Anonymous" shows the amount of memory that does not belong to any file.  Even
50262306a36Sopenharmony_cia mapping associated with a file may contain anonymous pages: when MAP_PRIVATE
50362306a36Sopenharmony_ciand a page is modified, the file page is replaced by a private anonymous copy.
50462306a36Sopenharmony_ci
50562306a36Sopenharmony_ci"KSM" reports how many of the pages are KSM pages. Note that KSM-placed zeropages
50662306a36Sopenharmony_ciare not included, only actual KSM pages.
50762306a36Sopenharmony_ci
50862306a36Sopenharmony_ci"LazyFree" shows the amount of memory which is marked by madvise(MADV_FREE).
50962306a36Sopenharmony_ciThe memory isn't freed immediately with madvise(). It's freed in memory
51062306a36Sopenharmony_cipressure if the memory is clean. Please note that the printed value might
51162306a36Sopenharmony_cibe lower than the real value due to optimizations used in the current
51262306a36Sopenharmony_ciimplementation. If this is not desirable please file a bug report.
51362306a36Sopenharmony_ci
51462306a36Sopenharmony_ci"AnonHugePages" shows the amount of memory backed by transparent hugepage.
51562306a36Sopenharmony_ci
51662306a36Sopenharmony_ci"ShmemPmdMapped" shows the amount of shared (shmem/tmpfs) memory backed by
51762306a36Sopenharmony_cihuge pages.
51862306a36Sopenharmony_ci
51962306a36Sopenharmony_ci"Shared_Hugetlb" and "Private_Hugetlb" show the amounts of memory backed by
52062306a36Sopenharmony_cihugetlbfs page which is *not* counted in "RSS" or "PSS" field for historical
52162306a36Sopenharmony_cireasons. And these are not included in {Shared,Private}_{Clean,Dirty} field.
52262306a36Sopenharmony_ci
52362306a36Sopenharmony_ci"Swap" shows how much would-be-anonymous memory is also used, but out on swap.
52462306a36Sopenharmony_ci
52562306a36Sopenharmony_ciFor shmem mappings, "Swap" includes also the size of the mapped (and not
52662306a36Sopenharmony_cireplaced by copy-on-write) part of the underlying shmem object out on swap.
52762306a36Sopenharmony_ci"SwapPss" shows proportional swap share of this mapping. Unlike "Swap", this
52862306a36Sopenharmony_cidoes not take into account swapped out page of underlying shmem objects.
52962306a36Sopenharmony_ci"Locked" indicates whether the mapping is locked in memory or not.
53062306a36Sopenharmony_ci
53162306a36Sopenharmony_ci"THPeligible" indicates whether the mapping is eligible for allocating THP
53262306a36Sopenharmony_cipages as well as the THP is PMD mappable or not - 1 if true, 0 otherwise.
53362306a36Sopenharmony_ciIt just shows the current status.
53462306a36Sopenharmony_ci
53562306a36Sopenharmony_ci"VmFlags" field deserves a separate description. This member represents the
53662306a36Sopenharmony_cikernel flags associated with the particular virtual memory area in two letter
53762306a36Sopenharmony_ciencoded manner. The codes are the following:
53862306a36Sopenharmony_ci
53962306a36Sopenharmony_ci    ==    =======================================
54062306a36Sopenharmony_ci    rd    readable
54162306a36Sopenharmony_ci    wr    writeable
54262306a36Sopenharmony_ci    ex    executable
54362306a36Sopenharmony_ci    sh    shared
54462306a36Sopenharmony_ci    mr    may read
54562306a36Sopenharmony_ci    mw    may write
54662306a36Sopenharmony_ci    me    may execute
54762306a36Sopenharmony_ci    ms    may share
54862306a36Sopenharmony_ci    gd    stack segment growns down
54962306a36Sopenharmony_ci    pf    pure PFN range
55062306a36Sopenharmony_ci    dw    disabled write to the mapped file
55162306a36Sopenharmony_ci    lo    pages are locked in memory
55262306a36Sopenharmony_ci    io    memory mapped I/O area
55362306a36Sopenharmony_ci    sr    sequential read advise provided
55462306a36Sopenharmony_ci    rr    random read advise provided
55562306a36Sopenharmony_ci    dc    do not copy area on fork
55662306a36Sopenharmony_ci    de    do not expand area on remapping
55762306a36Sopenharmony_ci    ac    area is accountable
55862306a36Sopenharmony_ci    nr    swap space is not reserved for the area
55962306a36Sopenharmony_ci    ht    area uses huge tlb pages
56062306a36Sopenharmony_ci    sf    synchronous page fault
56162306a36Sopenharmony_ci    ar    architecture specific flag
56262306a36Sopenharmony_ci    wf    wipe on fork
56362306a36Sopenharmony_ci    dd    do not include area into core dump
56462306a36Sopenharmony_ci    sd    soft dirty flag
56562306a36Sopenharmony_ci    mm    mixed map area
56662306a36Sopenharmony_ci    hg    huge page advise flag
56762306a36Sopenharmony_ci    nh    no huge page advise flag
56862306a36Sopenharmony_ci    mg    mergeable advise flag
56962306a36Sopenharmony_ci    bt    arm64 BTI guarded page
57062306a36Sopenharmony_ci    mt    arm64 MTE allocation tags are enabled
57162306a36Sopenharmony_ci    um    userfaultfd missing tracking
57262306a36Sopenharmony_ci    uw    userfaultfd wr-protect tracking
57362306a36Sopenharmony_ci    ss    shadow stack page
57462306a36Sopenharmony_ci    ==    =======================================
57562306a36Sopenharmony_ci
57662306a36Sopenharmony_ciNote that there is no guarantee that every flag and associated mnemonic will
57762306a36Sopenharmony_cibe present in all further kernel releases. Things get changed, the flags may
57862306a36Sopenharmony_cibe vanished or the reverse -- new added. Interpretation of their meaning
57962306a36Sopenharmony_cimight change in future as well. So each consumer of these flags has to
58062306a36Sopenharmony_cifollow each specific kernel version for the exact semantic.
58162306a36Sopenharmony_ci
58262306a36Sopenharmony_ciThis file is only present if the CONFIG_MMU kernel configuration option is
58362306a36Sopenharmony_cienabled.
58462306a36Sopenharmony_ci
58562306a36Sopenharmony_ciNote: reading /proc/PID/maps or /proc/PID/smaps is inherently racy (consistent
58662306a36Sopenharmony_cioutput can be achieved only in the single read call).
58762306a36Sopenharmony_ci
58862306a36Sopenharmony_ciThis typically manifests when doing partial reads of these files while the
58962306a36Sopenharmony_cimemory map is being modified.  Despite the races, we do provide the following
59062306a36Sopenharmony_ciguarantees:
59162306a36Sopenharmony_ci
59262306a36Sopenharmony_ci1) The mapped addresses never go backwards, which implies no two
59362306a36Sopenharmony_ci   regions will ever overlap.
59462306a36Sopenharmony_ci2) If there is something at a given vaddr during the entirety of the
59562306a36Sopenharmony_ci   life of the smaps/maps walk, there will be some output for it.
59662306a36Sopenharmony_ci
59762306a36Sopenharmony_ciThe /proc/PID/smaps_rollup file includes the same fields as /proc/PID/smaps,
59862306a36Sopenharmony_cibut their values are the sums of the corresponding values for all mappings of
59962306a36Sopenharmony_cithe process.  Additionally, it contains these fields:
60062306a36Sopenharmony_ci
60162306a36Sopenharmony_ci- Pss_Anon
60262306a36Sopenharmony_ci- Pss_File
60362306a36Sopenharmony_ci- Pss_Shmem
60462306a36Sopenharmony_ci
60562306a36Sopenharmony_ciThey represent the proportional shares of anonymous, file, and shmem pages, as
60662306a36Sopenharmony_cidescribed for smaps above.  These fields are omitted in smaps since each
60762306a36Sopenharmony_cimapping identifies the type (anon, file, or shmem) of all pages it contains.
60862306a36Sopenharmony_ciThus all information in smaps_rollup can be derived from smaps, but at a
60962306a36Sopenharmony_cisignificantly higher cost.
61062306a36Sopenharmony_ci
61162306a36Sopenharmony_ciThe /proc/PID/clear_refs is used to reset the PG_Referenced and ACCESSED/YOUNG
61262306a36Sopenharmony_cibits on both physical and virtual pages associated with a process, and the
61362306a36Sopenharmony_cisoft-dirty bit on pte (see Documentation/admin-guide/mm/soft-dirty.rst
61462306a36Sopenharmony_cifor details).
61562306a36Sopenharmony_ciTo clear the bits for all the pages associated with the process::
61662306a36Sopenharmony_ci
61762306a36Sopenharmony_ci    > echo 1 > /proc/PID/clear_refs
61862306a36Sopenharmony_ci
61962306a36Sopenharmony_ciTo clear the bits for the anonymous pages associated with the process::
62062306a36Sopenharmony_ci
62162306a36Sopenharmony_ci    > echo 2 > /proc/PID/clear_refs
62262306a36Sopenharmony_ci
62362306a36Sopenharmony_ciTo clear the bits for the file mapped pages associated with the process::
62462306a36Sopenharmony_ci
62562306a36Sopenharmony_ci    > echo 3 > /proc/PID/clear_refs
62662306a36Sopenharmony_ci
62762306a36Sopenharmony_ciTo clear the soft-dirty bit::
62862306a36Sopenharmony_ci
62962306a36Sopenharmony_ci    > echo 4 > /proc/PID/clear_refs
63062306a36Sopenharmony_ci
63162306a36Sopenharmony_ciTo reset the peak resident set size ("high water mark") to the process's
63262306a36Sopenharmony_cicurrent value::
63362306a36Sopenharmony_ci
63462306a36Sopenharmony_ci    > echo 5 > /proc/PID/clear_refs
63562306a36Sopenharmony_ci
63662306a36Sopenharmony_ciAny other value written to /proc/PID/clear_refs will have no effect.
63762306a36Sopenharmony_ci
63862306a36Sopenharmony_ciThe /proc/pid/pagemap gives the PFN, which can be used to find the pageflags
63962306a36Sopenharmony_ciusing /proc/kpageflags and number of times a page is mapped using
64062306a36Sopenharmony_ci/proc/kpagecount. For detailed explanation, see
64162306a36Sopenharmony_ciDocumentation/admin-guide/mm/pagemap.rst.
64262306a36Sopenharmony_ci
64362306a36Sopenharmony_ciThe /proc/pid/numa_maps is an extension based on maps, showing the memory
64462306a36Sopenharmony_cilocality and binding policy, as well as the memory usage (in pages) of
64562306a36Sopenharmony_cieach mapping. The output follows a general format where mapping details get
64662306a36Sopenharmony_cisummarized separated by blank spaces, one mapping per each file line::
64762306a36Sopenharmony_ci
64862306a36Sopenharmony_ci    address   policy    mapping details
64962306a36Sopenharmony_ci
65062306a36Sopenharmony_ci    00400000 default file=/usr/local/bin/app mapped=1 active=0 N3=1 kernelpagesize_kB=4
65162306a36Sopenharmony_ci    00600000 default file=/usr/local/bin/app anon=1 dirty=1 N3=1 kernelpagesize_kB=4
65262306a36Sopenharmony_ci    3206000000 default file=/lib64/ld-2.12.so mapped=26 mapmax=6 N0=24 N3=2 kernelpagesize_kB=4
65362306a36Sopenharmony_ci    320621f000 default file=/lib64/ld-2.12.so anon=1 dirty=1 N3=1 kernelpagesize_kB=4
65462306a36Sopenharmony_ci    3206220000 default file=/lib64/ld-2.12.so anon=1 dirty=1 N3=1 kernelpagesize_kB=4
65562306a36Sopenharmony_ci    3206221000 default anon=1 dirty=1 N3=1 kernelpagesize_kB=4
65662306a36Sopenharmony_ci    3206800000 default file=/lib64/libc-2.12.so mapped=59 mapmax=21 active=55 N0=41 N3=18 kernelpagesize_kB=4
65762306a36Sopenharmony_ci    320698b000 default file=/lib64/libc-2.12.so
65862306a36Sopenharmony_ci    3206b8a000 default file=/lib64/libc-2.12.so anon=2 dirty=2 N3=2 kernelpagesize_kB=4
65962306a36Sopenharmony_ci    3206b8e000 default file=/lib64/libc-2.12.so anon=1 dirty=1 N3=1 kernelpagesize_kB=4
66062306a36Sopenharmony_ci    3206b8f000 default anon=3 dirty=3 active=1 N3=3 kernelpagesize_kB=4
66162306a36Sopenharmony_ci    7f4dc10a2000 default anon=3 dirty=3 N3=3 kernelpagesize_kB=4
66262306a36Sopenharmony_ci    7f4dc10b4000 default anon=2 dirty=2 active=1 N3=2 kernelpagesize_kB=4
66362306a36Sopenharmony_ci    7f4dc1200000 default file=/anon_hugepage\040(deleted) huge anon=1 dirty=1 N3=1 kernelpagesize_kB=2048
66462306a36Sopenharmony_ci    7fff335f0000 default stack anon=3 dirty=3 N3=3 kernelpagesize_kB=4
66562306a36Sopenharmony_ci    7fff3369d000 default mapped=1 mapmax=35 active=0 N3=1 kernelpagesize_kB=4
66662306a36Sopenharmony_ci
66762306a36Sopenharmony_ciWhere:
66862306a36Sopenharmony_ci
66962306a36Sopenharmony_ci"address" is the starting address for the mapping;
67062306a36Sopenharmony_ci
67162306a36Sopenharmony_ci"policy" reports the NUMA memory policy set for the mapping (see Documentation/admin-guide/mm/numa_memory_policy.rst);
67262306a36Sopenharmony_ci
67362306a36Sopenharmony_ci"mapping details" summarizes mapping data such as mapping type, page usage counters,
67462306a36Sopenharmony_cinode locality page counters (N0 == node0, N1 == node1, ...) and the kernel page
67562306a36Sopenharmony_cisize, in KB, that is backing the mapping up.
67662306a36Sopenharmony_ci
67762306a36Sopenharmony_ci1.2 Kernel data
67862306a36Sopenharmony_ci---------------
67962306a36Sopenharmony_ci
68062306a36Sopenharmony_ciSimilar to  the  process entries, the kernel data files give information about
68162306a36Sopenharmony_cithe running kernel. The files used to obtain this information are contained in
68262306a36Sopenharmony_ci/proc and  are  listed  in Table 1-5. Not all of these will be present in your
68362306a36Sopenharmony_cisystem. It  depends  on the kernel configuration and the loaded modules, which
68462306a36Sopenharmony_cifiles are there, and which are missing.
68562306a36Sopenharmony_ci
68662306a36Sopenharmony_ci.. table:: Table 1-5: Kernel info in /proc
68762306a36Sopenharmony_ci
68862306a36Sopenharmony_ci ============ ===============================================================
68962306a36Sopenharmony_ci File         Content
69062306a36Sopenharmony_ci ============ ===============================================================
69162306a36Sopenharmony_ci apm          Advanced power management info
69262306a36Sopenharmony_ci buddyinfo    Kernel memory allocator information (see text)	(2.5)
69362306a36Sopenharmony_ci bus          Directory containing bus specific information
69462306a36Sopenharmony_ci cmdline      Kernel command line
69562306a36Sopenharmony_ci cpuinfo      Info about the CPU
69662306a36Sopenharmony_ci devices      Available devices (block and character)
69762306a36Sopenharmony_ci dma          Used DMS channels
69862306a36Sopenharmony_ci filesystems  Supported filesystems
69962306a36Sopenharmony_ci driver       Various drivers grouped here, currently rtc	(2.4)
70062306a36Sopenharmony_ci execdomains  Execdomains, related to security			(2.4)
70162306a36Sopenharmony_ci fb 	      Frame Buffer devices				(2.4)
70262306a36Sopenharmony_ci fs 	      File system parameters, currently nfs/exports	(2.4)
70362306a36Sopenharmony_ci ide          Directory containing info about the IDE subsystem
70462306a36Sopenharmony_ci interrupts   Interrupt usage
70562306a36Sopenharmony_ci iomem 	      Memory map					(2.4)
70662306a36Sopenharmony_ci ioports      I/O port usage
70762306a36Sopenharmony_ci irq 	      Masks for irq to cpu affinity			(2.4)(smp?)
70862306a36Sopenharmony_ci isapnp       ISA PnP (Plug&Play) Info				(2.4)
70962306a36Sopenharmony_ci kcore        Kernel core image (can be ELF or A.OUT(deprecated in 2.4))
71062306a36Sopenharmony_ci kmsg         Kernel messages
71162306a36Sopenharmony_ci ksyms        Kernel symbol table
71262306a36Sopenharmony_ci loadavg      Load average of last 1, 5 & 15 minutes;
71362306a36Sopenharmony_ci                number of processes currently runnable (running or on ready queue);
71462306a36Sopenharmony_ci                total number of processes in system;
71562306a36Sopenharmony_ci                last pid created.
71662306a36Sopenharmony_ci                All fields are separated by one space except "number of
71762306a36Sopenharmony_ci                processes currently runnable" and "total number of processes
71862306a36Sopenharmony_ci                in system", which are separated by a slash ('/'). Example:
71962306a36Sopenharmony_ci                0.61 0.61 0.55 3/828 22084
72062306a36Sopenharmony_ci locks        Kernel locks
72162306a36Sopenharmony_ci meminfo      Memory info
72262306a36Sopenharmony_ci misc         Miscellaneous
72362306a36Sopenharmony_ci modules      List of loaded modules
72462306a36Sopenharmony_ci mounts       Mounted filesystems
72562306a36Sopenharmony_ci net          Networking info (see text)
72662306a36Sopenharmony_ci pagetypeinfo Additional page allocator information (see text)  (2.5)
72762306a36Sopenharmony_ci partitions   Table of partitions known to the system
72862306a36Sopenharmony_ci pci 	      Deprecated info of PCI bus (new way -> /proc/bus/pci/,
72962306a36Sopenharmony_ci              decoupled by lspci				(2.4)
73062306a36Sopenharmony_ci rtc          Real time clock
73162306a36Sopenharmony_ci scsi         SCSI info (see text)
73262306a36Sopenharmony_ci slabinfo     Slab pool info
73362306a36Sopenharmony_ci softirqs     softirq usage
73462306a36Sopenharmony_ci stat         Overall statistics
73562306a36Sopenharmony_ci swaps        Swap space utilization
73662306a36Sopenharmony_ci sys          See chapter 2
73762306a36Sopenharmony_ci sysvipc      Info of SysVIPC Resources (msg, sem, shm)		(2.4)
73862306a36Sopenharmony_ci tty 	      Info of tty drivers
73962306a36Sopenharmony_ci uptime       Wall clock since boot, combined idle time of all cpus
74062306a36Sopenharmony_ci version      Kernel version
74162306a36Sopenharmony_ci video 	      bttv info of video resources			(2.4)
74262306a36Sopenharmony_ci vmallocinfo  Show vmalloced areas
74362306a36Sopenharmony_ci ============ ===============================================================
74462306a36Sopenharmony_ci
74562306a36Sopenharmony_ciYou can,  for  example,  check  which interrupts are currently in use and what
74662306a36Sopenharmony_cithey are used for by looking in the file /proc/interrupts::
74762306a36Sopenharmony_ci
74862306a36Sopenharmony_ci  > cat /proc/interrupts
74962306a36Sopenharmony_ci             CPU0
75062306a36Sopenharmony_ci    0:    8728810          XT-PIC  timer
75162306a36Sopenharmony_ci    1:        895          XT-PIC  keyboard
75262306a36Sopenharmony_ci    2:          0          XT-PIC  cascade
75362306a36Sopenharmony_ci    3:     531695          XT-PIC  aha152x
75462306a36Sopenharmony_ci    4:    2014133          XT-PIC  serial
75562306a36Sopenharmony_ci    5:      44401          XT-PIC  pcnet_cs
75662306a36Sopenharmony_ci    8:          2          XT-PIC  rtc
75762306a36Sopenharmony_ci   11:          8          XT-PIC  i82365
75862306a36Sopenharmony_ci   12:     182918          XT-PIC  PS/2 Mouse
75962306a36Sopenharmony_ci   13:          1          XT-PIC  fpu
76062306a36Sopenharmony_ci   14:    1232265          XT-PIC  ide0
76162306a36Sopenharmony_ci   15:          7          XT-PIC  ide1
76262306a36Sopenharmony_ci  NMI:          0
76362306a36Sopenharmony_ci
76462306a36Sopenharmony_ciIn 2.4.* a couple of lines where added to this file LOC & ERR (this time is the
76562306a36Sopenharmony_cioutput of a SMP machine)::
76662306a36Sopenharmony_ci
76762306a36Sopenharmony_ci  > cat /proc/interrupts
76862306a36Sopenharmony_ci
76962306a36Sopenharmony_ci             CPU0       CPU1
77062306a36Sopenharmony_ci    0:    1243498    1214548    IO-APIC-edge  timer
77162306a36Sopenharmony_ci    1:       8949       8958    IO-APIC-edge  keyboard
77262306a36Sopenharmony_ci    2:          0          0          XT-PIC  cascade
77362306a36Sopenharmony_ci    5:      11286      10161    IO-APIC-edge  soundblaster
77462306a36Sopenharmony_ci    8:          1          0    IO-APIC-edge  rtc
77562306a36Sopenharmony_ci    9:      27422      27407    IO-APIC-edge  3c503
77662306a36Sopenharmony_ci   12:     113645     113873    IO-APIC-edge  PS/2 Mouse
77762306a36Sopenharmony_ci   13:          0          0          XT-PIC  fpu
77862306a36Sopenharmony_ci   14:      22491      24012    IO-APIC-edge  ide0
77962306a36Sopenharmony_ci   15:       2183       2415    IO-APIC-edge  ide1
78062306a36Sopenharmony_ci   17:      30564      30414   IO-APIC-level  eth0
78162306a36Sopenharmony_ci   18:        177        164   IO-APIC-level  bttv
78262306a36Sopenharmony_ci  NMI:    2457961    2457959
78362306a36Sopenharmony_ci  LOC:    2457882    2457881
78462306a36Sopenharmony_ci  ERR:       2155
78562306a36Sopenharmony_ci
78662306a36Sopenharmony_ciNMI is incremented in this case because every timer interrupt generates a NMI
78762306a36Sopenharmony_ci(Non Maskable Interrupt) which is used by the NMI Watchdog to detect lockups.
78862306a36Sopenharmony_ci
78962306a36Sopenharmony_ciLOC is the local interrupt counter of the internal APIC of every CPU.
79062306a36Sopenharmony_ci
79162306a36Sopenharmony_ciERR is incremented in the case of errors in the IO-APIC bus (the bus that
79262306a36Sopenharmony_ciconnects the CPUs in a SMP system. This means that an error has been detected,
79362306a36Sopenharmony_cithe IO-APIC automatically retry the transmission, so it should not be a big
79462306a36Sopenharmony_ciproblem, but you should read the SMP-FAQ.
79562306a36Sopenharmony_ci
79662306a36Sopenharmony_ciIn 2.6.2* /proc/interrupts was expanded again.  This time the goal was for
79762306a36Sopenharmony_ci/proc/interrupts to display every IRQ vector in use by the system, not
79862306a36Sopenharmony_cijust those considered 'most important'.  The new vectors are:
79962306a36Sopenharmony_ci
80062306a36Sopenharmony_ciTHR
80162306a36Sopenharmony_ci  interrupt raised when a machine check threshold counter
80262306a36Sopenharmony_ci  (typically counting ECC corrected errors of memory or cache) exceeds
80362306a36Sopenharmony_ci  a configurable threshold.  Only available on some systems.
80462306a36Sopenharmony_ci
80562306a36Sopenharmony_ciTRM
80662306a36Sopenharmony_ci  a thermal event interrupt occurs when a temperature threshold
80762306a36Sopenharmony_ci  has been exceeded for the CPU.  This interrupt may also be generated
80862306a36Sopenharmony_ci  when the temperature drops back to normal.
80962306a36Sopenharmony_ci
81062306a36Sopenharmony_ciSPU
81162306a36Sopenharmony_ci  a spurious interrupt is some interrupt that was raised then lowered
81262306a36Sopenharmony_ci  by some IO device before it could be fully processed by the APIC.  Hence
81362306a36Sopenharmony_ci  the APIC sees the interrupt but does not know what device it came from.
81462306a36Sopenharmony_ci  For this case the APIC will generate the interrupt with a IRQ vector
81562306a36Sopenharmony_ci  of 0xff. This might also be generated by chipset bugs.
81662306a36Sopenharmony_ci
81762306a36Sopenharmony_ciRES, CAL, TLB
81862306a36Sopenharmony_ci  rescheduling, call and TLB flush interrupts are
81962306a36Sopenharmony_ci  sent from one CPU to another per the needs of the OS.  Typically,
82062306a36Sopenharmony_ci  their statistics are used by kernel developers and interested users to
82162306a36Sopenharmony_ci  determine the occurrence of interrupts of the given type.
82262306a36Sopenharmony_ci
82362306a36Sopenharmony_ciThe above IRQ vectors are displayed only when relevant.  For example,
82462306a36Sopenharmony_cithe threshold vector does not exist on x86_64 platforms.  Others are
82562306a36Sopenharmony_cisuppressed when the system is a uniprocessor.  As of this writing, only
82662306a36Sopenharmony_cii386 and x86_64 platforms support the new IRQ vector displays.
82762306a36Sopenharmony_ci
82862306a36Sopenharmony_ciOf some interest is the introduction of the /proc/irq directory to 2.4.
82962306a36Sopenharmony_ciIt could be used to set IRQ to CPU affinity. This means that you can "hook" an
83062306a36Sopenharmony_ciIRQ to only one CPU, or to exclude a CPU of handling IRQs. The contents of the
83162306a36Sopenharmony_ciirq subdir is one subdir for each IRQ, and two files; default_smp_affinity and
83262306a36Sopenharmony_ciprof_cpu_mask.
83362306a36Sopenharmony_ci
83462306a36Sopenharmony_ciFor example::
83562306a36Sopenharmony_ci
83662306a36Sopenharmony_ci  > ls /proc/irq/
83762306a36Sopenharmony_ci  0  10  12  14  16  18  2  4  6  8  prof_cpu_mask
83862306a36Sopenharmony_ci  1  11  13  15  17  19  3  5  7  9  default_smp_affinity
83962306a36Sopenharmony_ci  > ls /proc/irq/0/
84062306a36Sopenharmony_ci  smp_affinity
84162306a36Sopenharmony_ci
84262306a36Sopenharmony_cismp_affinity is a bitmask, in which you can specify which CPUs can handle the
84362306a36Sopenharmony_ciIRQ. You can set it by doing::
84462306a36Sopenharmony_ci
84562306a36Sopenharmony_ci  > echo 1 > /proc/irq/10/smp_affinity
84662306a36Sopenharmony_ci
84762306a36Sopenharmony_ciThis means that only the first CPU will handle the IRQ, but you can also echo
84862306a36Sopenharmony_ci5 which means that only the first and third CPU can handle the IRQ.
84962306a36Sopenharmony_ci
85062306a36Sopenharmony_ciThe contents of each smp_affinity file is the same by default::
85162306a36Sopenharmony_ci
85262306a36Sopenharmony_ci  > cat /proc/irq/0/smp_affinity
85362306a36Sopenharmony_ci  ffffffff
85462306a36Sopenharmony_ci
85562306a36Sopenharmony_ciThere is an alternate interface, smp_affinity_list which allows specifying
85662306a36Sopenharmony_cia CPU range instead of a bitmask::
85762306a36Sopenharmony_ci
85862306a36Sopenharmony_ci  > cat /proc/irq/0/smp_affinity_list
85962306a36Sopenharmony_ci  1024-1031
86062306a36Sopenharmony_ci
86162306a36Sopenharmony_ciThe default_smp_affinity mask applies to all non-active IRQs, which are the
86262306a36Sopenharmony_ciIRQs which have not yet been allocated/activated, and hence which lack a
86362306a36Sopenharmony_ci/proc/irq/[0-9]* directory.
86462306a36Sopenharmony_ci
86562306a36Sopenharmony_ciThe node file on an SMP system shows the node to which the device using the IRQ
86662306a36Sopenharmony_cireports itself as being attached. This hardware locality information does not
86762306a36Sopenharmony_ciinclude information about any possible driver locality preference.
86862306a36Sopenharmony_ci
86962306a36Sopenharmony_ciprof_cpu_mask specifies which CPUs are to be profiled by the system wide
87062306a36Sopenharmony_ciprofiler. Default value is ffffffff (all CPUs if there are only 32 of them).
87162306a36Sopenharmony_ci
87262306a36Sopenharmony_ciThe way IRQs are routed is handled by the IO-APIC, and it's Round Robin
87362306a36Sopenharmony_cibetween all the CPUs which are allowed to handle it. As usual the kernel has
87462306a36Sopenharmony_cimore info than you and does a better job than you, so the defaults are the
87562306a36Sopenharmony_cibest choice for almost everyone.  [Note this applies only to those IO-APIC's
87662306a36Sopenharmony_cithat support "Round Robin" interrupt distribution.]
87762306a36Sopenharmony_ci
87862306a36Sopenharmony_ciThere are  three  more  important subdirectories in /proc: net, scsi, and sys.
87962306a36Sopenharmony_ciThe general  rule  is  that  the  contents,  or  even  the  existence of these
88062306a36Sopenharmony_cidirectories, depend  on your kernel configuration. If SCSI is not enabled, the
88162306a36Sopenharmony_cidirectory scsi  may  not  exist. The same is true with the net, which is there
88262306a36Sopenharmony_cionly when networking support is present in the running kernel.
88362306a36Sopenharmony_ci
88462306a36Sopenharmony_ciThe slabinfo  file  gives  information  about  memory usage at the slab level.
88562306a36Sopenharmony_ciLinux uses  slab  pools for memory management above page level in version 2.2.
88662306a36Sopenharmony_ciCommonly used  objects  have  their  own  slab  pool (such as network buffers,
88762306a36Sopenharmony_cidirectory cache, and so on).
88862306a36Sopenharmony_ci
88962306a36Sopenharmony_ci::
89062306a36Sopenharmony_ci
89162306a36Sopenharmony_ci    > cat /proc/buddyinfo
89262306a36Sopenharmony_ci
89362306a36Sopenharmony_ci    Node 0, zone      DMA      0      4      5      4      4      3 ...
89462306a36Sopenharmony_ci    Node 0, zone   Normal      1      0      0      1    101      8 ...
89562306a36Sopenharmony_ci    Node 0, zone  HighMem      2      0      0      1      1      0 ...
89662306a36Sopenharmony_ci
89762306a36Sopenharmony_ciExternal fragmentation is a problem under some workloads, and buddyinfo is a
89862306a36Sopenharmony_ciuseful tool for helping diagnose these problems.  Buddyinfo will give you a
89962306a36Sopenharmony_ciclue as to how big an area you can safely allocate, or why a previous
90062306a36Sopenharmony_ciallocation failed.
90162306a36Sopenharmony_ci
90262306a36Sopenharmony_ciEach column represents the number of pages of a certain order which are
90362306a36Sopenharmony_ciavailable.  In this case, there are 0 chunks of 2^0*PAGE_SIZE available in
90462306a36Sopenharmony_ciZONE_DMA, 4 chunks of 2^1*PAGE_SIZE in ZONE_DMA, 101 chunks of 2^4*PAGE_SIZE
90562306a36Sopenharmony_ciavailable in ZONE_NORMAL, etc...
90662306a36Sopenharmony_ci
90762306a36Sopenharmony_ciMore information relevant to external fragmentation can be found in
90862306a36Sopenharmony_cipagetypeinfo::
90962306a36Sopenharmony_ci
91062306a36Sopenharmony_ci    > cat /proc/pagetypeinfo
91162306a36Sopenharmony_ci    Page block order: 9
91262306a36Sopenharmony_ci    Pages per block:  512
91362306a36Sopenharmony_ci
91462306a36Sopenharmony_ci    Free pages count per migrate type at order       0      1      2      3      4      5      6      7      8      9     10
91562306a36Sopenharmony_ci    Node    0, zone      DMA, type    Unmovable      0      0      0      1      1      1      1      1      1      1      0
91662306a36Sopenharmony_ci    Node    0, zone      DMA, type  Reclaimable      0      0      0      0      0      0      0      0      0      0      0
91762306a36Sopenharmony_ci    Node    0, zone      DMA, type      Movable      1      1      2      1      2      1      1      0      1      0      2
91862306a36Sopenharmony_ci    Node    0, zone      DMA, type      Reserve      0      0      0      0      0      0      0      0      0      1      0
91962306a36Sopenharmony_ci    Node    0, zone      DMA, type      Isolate      0      0      0      0      0      0      0      0      0      0      0
92062306a36Sopenharmony_ci    Node    0, zone    DMA32, type    Unmovable    103     54     77      1      1      1     11      8      7      1      9
92162306a36Sopenharmony_ci    Node    0, zone    DMA32, type  Reclaimable      0      0      2      1      0      0      0      0      1      0      0
92262306a36Sopenharmony_ci    Node    0, zone    DMA32, type      Movable    169    152    113     91     77     54     39     13      6      1    452
92362306a36Sopenharmony_ci    Node    0, zone    DMA32, type      Reserve      1      2      2      2      2      0      1      1      1      1      0
92462306a36Sopenharmony_ci    Node    0, zone    DMA32, type      Isolate      0      0      0      0      0      0      0      0      0      0      0
92562306a36Sopenharmony_ci
92662306a36Sopenharmony_ci    Number of blocks type     Unmovable  Reclaimable      Movable      Reserve      Isolate
92762306a36Sopenharmony_ci    Node 0, zone      DMA            2            0            5            1            0
92862306a36Sopenharmony_ci    Node 0, zone    DMA32           41            6          967            2            0
92962306a36Sopenharmony_ci
93062306a36Sopenharmony_ciFragmentation avoidance in the kernel works by grouping pages of different
93162306a36Sopenharmony_cimigrate types into the same contiguous regions of memory called page blocks.
93262306a36Sopenharmony_ciA page block is typically the size of the default hugepage size, e.g. 2MB on
93362306a36Sopenharmony_ciX86-64. By keeping pages grouped based on their ability to move, the kernel
93462306a36Sopenharmony_cican reclaim pages within a page block to satisfy a high-order allocation.
93562306a36Sopenharmony_ci
93662306a36Sopenharmony_ciThe pagetypinfo begins with information on the size of a page block. It
93762306a36Sopenharmony_cithen gives the same type of information as buddyinfo except broken down
93862306a36Sopenharmony_ciby migrate-type and finishes with details on how many page blocks of each
93962306a36Sopenharmony_citype exist.
94062306a36Sopenharmony_ci
94162306a36Sopenharmony_ciIf min_free_kbytes has been tuned correctly (recommendations made by hugeadm
94262306a36Sopenharmony_cifrom libhugetlbfs https://github.com/libhugetlbfs/libhugetlbfs/), one can
94362306a36Sopenharmony_cimake an estimate of the likely number of huge pages that can be allocated
94462306a36Sopenharmony_ciat a given point in time. All the "Movable" blocks should be allocatable
94562306a36Sopenharmony_ciunless memory has been mlock()'d. Some of the Reclaimable blocks should
94662306a36Sopenharmony_cialso be allocatable although a lot of filesystem metadata may have to be
94762306a36Sopenharmony_cireclaimed to achieve this.
94862306a36Sopenharmony_ci
94962306a36Sopenharmony_ci
95062306a36Sopenharmony_cimeminfo
95162306a36Sopenharmony_ci~~~~~~~
95262306a36Sopenharmony_ci
95362306a36Sopenharmony_ciProvides information about distribution and utilization of memory.  This
95462306a36Sopenharmony_civaries by architecture and compile options.  Some of the counters reported
95562306a36Sopenharmony_cihere overlap.  The memory reported by the non overlapping counters may not
95662306a36Sopenharmony_ciadd up to the overall memory usage and the difference for some workloads
95762306a36Sopenharmony_cican be substantial.  In many cases there are other means to find out
95862306a36Sopenharmony_ciadditional memory using subsystem specific interfaces, for instance
95962306a36Sopenharmony_ci/proc/net/sockstat for TCP memory allocations.
96062306a36Sopenharmony_ci
96162306a36Sopenharmony_ciExample output. You may not have all of these fields.
96262306a36Sopenharmony_ci
96362306a36Sopenharmony_ci::
96462306a36Sopenharmony_ci
96562306a36Sopenharmony_ci    > cat /proc/meminfo
96662306a36Sopenharmony_ci
96762306a36Sopenharmony_ci    MemTotal:       32858820 kB
96862306a36Sopenharmony_ci    MemFree:        21001236 kB
96962306a36Sopenharmony_ci    MemAvailable:   27214312 kB
97062306a36Sopenharmony_ci    Buffers:          581092 kB
97162306a36Sopenharmony_ci    Cached:          5587612 kB
97262306a36Sopenharmony_ci    SwapCached:            0 kB
97362306a36Sopenharmony_ci    Active:          3237152 kB
97462306a36Sopenharmony_ci    Inactive:        7586256 kB
97562306a36Sopenharmony_ci    Active(anon):      94064 kB
97662306a36Sopenharmony_ci    Inactive(anon):  4570616 kB
97762306a36Sopenharmony_ci    Active(file):    3143088 kB
97862306a36Sopenharmony_ci    Inactive(file):  3015640 kB
97962306a36Sopenharmony_ci    Unevictable:           0 kB
98062306a36Sopenharmony_ci    Mlocked:               0 kB
98162306a36Sopenharmony_ci    SwapTotal:             0 kB
98262306a36Sopenharmony_ci    SwapFree:              0 kB
98362306a36Sopenharmony_ci    Zswap:              1904 kB
98462306a36Sopenharmony_ci    Zswapped:           7792 kB
98562306a36Sopenharmony_ci    Dirty:                12 kB
98662306a36Sopenharmony_ci    Writeback:             0 kB
98762306a36Sopenharmony_ci    AnonPages:       4654780 kB
98862306a36Sopenharmony_ci    Mapped:           266244 kB
98962306a36Sopenharmony_ci    Shmem:              9976 kB
99062306a36Sopenharmony_ci    KReclaimable:     517708 kB
99162306a36Sopenharmony_ci    Slab:             660044 kB
99262306a36Sopenharmony_ci    SReclaimable:     517708 kB
99362306a36Sopenharmony_ci    SUnreclaim:       142336 kB
99462306a36Sopenharmony_ci    KernelStack:       11168 kB
99562306a36Sopenharmony_ci    PageTables:        20540 kB
99662306a36Sopenharmony_ci    SecPageTables:         0 kB
99762306a36Sopenharmony_ci    NFS_Unstable:          0 kB
99862306a36Sopenharmony_ci    Bounce:                0 kB
99962306a36Sopenharmony_ci    WritebackTmp:          0 kB
100062306a36Sopenharmony_ci    CommitLimit:    16429408 kB
100162306a36Sopenharmony_ci    Committed_AS:    7715148 kB
100262306a36Sopenharmony_ci    VmallocTotal:   34359738367 kB
100362306a36Sopenharmony_ci    VmallocUsed:       40444 kB
100462306a36Sopenharmony_ci    VmallocChunk:          0 kB
100562306a36Sopenharmony_ci    Percpu:            29312 kB
100662306a36Sopenharmony_ci    EarlyMemtestBad:       0 kB
100762306a36Sopenharmony_ci    HardwareCorrupted:     0 kB
100862306a36Sopenharmony_ci    AnonHugePages:   4149248 kB
100962306a36Sopenharmony_ci    ShmemHugePages:        0 kB
101062306a36Sopenharmony_ci    ShmemPmdMapped:        0 kB
101162306a36Sopenharmony_ci    FileHugePages:         0 kB
101262306a36Sopenharmony_ci    FilePmdMapped:         0 kB
101362306a36Sopenharmony_ci    CmaTotal:              0 kB
101462306a36Sopenharmony_ci    CmaFree:               0 kB
101562306a36Sopenharmony_ci    HugePages_Total:       0
101662306a36Sopenharmony_ci    HugePages_Free:        0
101762306a36Sopenharmony_ci    HugePages_Rsvd:        0
101862306a36Sopenharmony_ci    HugePages_Surp:        0
101962306a36Sopenharmony_ci    Hugepagesize:       2048 kB
102062306a36Sopenharmony_ci    Hugetlb:               0 kB
102162306a36Sopenharmony_ci    DirectMap4k:      401152 kB
102262306a36Sopenharmony_ci    DirectMap2M:    10008576 kB
102362306a36Sopenharmony_ci    DirectMap1G:    24117248 kB
102462306a36Sopenharmony_ci
102562306a36Sopenharmony_ciMemTotal
102662306a36Sopenharmony_ci              Total usable RAM (i.e. physical RAM minus a few reserved
102762306a36Sopenharmony_ci              bits and the kernel binary code)
102862306a36Sopenharmony_ciMemFree
102962306a36Sopenharmony_ci              Total free RAM. On highmem systems, the sum of LowFree+HighFree
103062306a36Sopenharmony_ciMemAvailable
103162306a36Sopenharmony_ci              An estimate of how much memory is available for starting new
103262306a36Sopenharmony_ci              applications, without swapping. Calculated from MemFree,
103362306a36Sopenharmony_ci              SReclaimable, the size of the file LRU lists, and the low
103462306a36Sopenharmony_ci              watermarks in each zone.
103562306a36Sopenharmony_ci              The estimate takes into account that the system needs some
103662306a36Sopenharmony_ci              page cache to function well, and that not all reclaimable
103762306a36Sopenharmony_ci              slab will be reclaimable, due to items being in use. The
103862306a36Sopenharmony_ci              impact of those factors will vary from system to system.
103962306a36Sopenharmony_ciBuffers
104062306a36Sopenharmony_ci              Relatively temporary storage for raw disk blocks
104162306a36Sopenharmony_ci              shouldn't get tremendously large (20MB or so)
104262306a36Sopenharmony_ciCached
104362306a36Sopenharmony_ci              In-memory cache for files read from the disk (the
104462306a36Sopenharmony_ci              pagecache) as well as tmpfs & shmem.
104562306a36Sopenharmony_ci              Doesn't include SwapCached.
104662306a36Sopenharmony_ciSwapCached
104762306a36Sopenharmony_ci              Memory that once was swapped out, is swapped back in but
104862306a36Sopenharmony_ci              still also is in the swapfile (if memory is needed it
104962306a36Sopenharmony_ci              doesn't need to be swapped out AGAIN because it is already
105062306a36Sopenharmony_ci              in the swapfile. This saves I/O)
105162306a36Sopenharmony_ciActive
105262306a36Sopenharmony_ci              Memory that has been used more recently and usually not
105362306a36Sopenharmony_ci              reclaimed unless absolutely necessary.
105462306a36Sopenharmony_ciInactive
105562306a36Sopenharmony_ci              Memory which has been less recently used.  It is more
105662306a36Sopenharmony_ci              eligible to be reclaimed for other purposes
105762306a36Sopenharmony_ciUnevictable
105862306a36Sopenharmony_ci              Memory allocated for userspace which cannot be reclaimed, such
105962306a36Sopenharmony_ci              as mlocked pages, ramfs backing pages, secret memfd pages etc.
106062306a36Sopenharmony_ciMlocked
106162306a36Sopenharmony_ci              Memory locked with mlock().
106262306a36Sopenharmony_ciHighTotal, HighFree
106362306a36Sopenharmony_ci              Highmem is all memory above ~860MB of physical memory.
106462306a36Sopenharmony_ci              Highmem areas are for use by userspace programs, or
106562306a36Sopenharmony_ci              for the pagecache.  The kernel must use tricks to access
106662306a36Sopenharmony_ci              this memory, making it slower to access than lowmem.
106762306a36Sopenharmony_ciLowTotal, LowFree
106862306a36Sopenharmony_ci              Lowmem is memory which can be used for everything that
106962306a36Sopenharmony_ci              highmem can be used for, but it is also available for the
107062306a36Sopenharmony_ci              kernel's use for its own data structures.  Among many
107162306a36Sopenharmony_ci              other things, it is where everything from the Slab is
107262306a36Sopenharmony_ci              allocated.  Bad things happen when you're out of lowmem.
107362306a36Sopenharmony_ciSwapTotal
107462306a36Sopenharmony_ci              total amount of swap space available
107562306a36Sopenharmony_ciSwapFree
107662306a36Sopenharmony_ci              Memory which has been evicted from RAM, and is temporarily
107762306a36Sopenharmony_ci              on the disk
107862306a36Sopenharmony_ciZswap
107962306a36Sopenharmony_ci              Memory consumed by the zswap backend (compressed size)
108062306a36Sopenharmony_ciZswapped
108162306a36Sopenharmony_ci              Amount of anonymous memory stored in zswap (original size)
108262306a36Sopenharmony_ciDirty
108362306a36Sopenharmony_ci              Memory which is waiting to get written back to the disk
108462306a36Sopenharmony_ciWriteback
108562306a36Sopenharmony_ci              Memory which is actively being written back to the disk
108662306a36Sopenharmony_ciAnonPages
108762306a36Sopenharmony_ci              Non-file backed pages mapped into userspace page tables
108862306a36Sopenharmony_ciMapped
108962306a36Sopenharmony_ci              files which have been mmapped, such as libraries
109062306a36Sopenharmony_ciShmem
109162306a36Sopenharmony_ci              Total memory used by shared memory (shmem) and tmpfs
109262306a36Sopenharmony_ciKReclaimable
109362306a36Sopenharmony_ci              Kernel allocations that the kernel will attempt to reclaim
109462306a36Sopenharmony_ci              under memory pressure. Includes SReclaimable (below), and other
109562306a36Sopenharmony_ci              direct allocations with a shrinker.
109662306a36Sopenharmony_ciSlab
109762306a36Sopenharmony_ci              in-kernel data structures cache
109862306a36Sopenharmony_ciSReclaimable
109962306a36Sopenharmony_ci              Part of Slab, that might be reclaimed, such as caches
110062306a36Sopenharmony_ciSUnreclaim
110162306a36Sopenharmony_ci              Part of Slab, that cannot be reclaimed on memory pressure
110262306a36Sopenharmony_ciKernelStack
110362306a36Sopenharmony_ci              Memory consumed by the kernel stacks of all tasks
110462306a36Sopenharmony_ciPageTables
110562306a36Sopenharmony_ci              Memory consumed by userspace page tables
110662306a36Sopenharmony_ciSecPageTables
110762306a36Sopenharmony_ci              Memory consumed by secondary page tables, this currently
110862306a36Sopenharmony_ci              currently includes KVM mmu allocations on x86 and arm64.
110962306a36Sopenharmony_ciNFS_Unstable
111062306a36Sopenharmony_ci              Always zero. Previous counted pages which had been written to
111162306a36Sopenharmony_ci              the server, but has not been committed to stable storage.
111262306a36Sopenharmony_ciBounce
111362306a36Sopenharmony_ci              Memory used for block device "bounce buffers"
111462306a36Sopenharmony_ciWritebackTmp
111562306a36Sopenharmony_ci              Memory used by FUSE for temporary writeback buffers
111662306a36Sopenharmony_ciCommitLimit
111762306a36Sopenharmony_ci              Based on the overcommit ratio ('vm.overcommit_ratio'),
111862306a36Sopenharmony_ci              this is the total amount of  memory currently available to
111962306a36Sopenharmony_ci              be allocated on the system. This limit is only adhered to
112062306a36Sopenharmony_ci              if strict overcommit accounting is enabled (mode 2 in
112162306a36Sopenharmony_ci              'vm.overcommit_memory').
112262306a36Sopenharmony_ci
112362306a36Sopenharmony_ci              The CommitLimit is calculated with the following formula::
112462306a36Sopenharmony_ci
112562306a36Sopenharmony_ci                CommitLimit = ([total RAM pages] - [total huge TLB pages]) *
112662306a36Sopenharmony_ci                               overcommit_ratio / 100 + [total swap pages]
112762306a36Sopenharmony_ci
112862306a36Sopenharmony_ci              For example, on a system with 1G of physical RAM and 7G
112962306a36Sopenharmony_ci              of swap with a `vm.overcommit_ratio` of 30 it would
113062306a36Sopenharmony_ci              yield a CommitLimit of 7.3G.
113162306a36Sopenharmony_ci
113262306a36Sopenharmony_ci              For more details, see the memory overcommit documentation
113362306a36Sopenharmony_ci              in mm/overcommit-accounting.
113462306a36Sopenharmony_ciCommitted_AS
113562306a36Sopenharmony_ci              The amount of memory presently allocated on the system.
113662306a36Sopenharmony_ci              The committed memory is a sum of all of the memory which
113762306a36Sopenharmony_ci              has been allocated by processes, even if it has not been
113862306a36Sopenharmony_ci              "used" by them as of yet. A process which malloc()'s 1G
113962306a36Sopenharmony_ci              of memory, but only touches 300M of it will show up as
114062306a36Sopenharmony_ci              using 1G. This 1G is memory which has been "committed" to
114162306a36Sopenharmony_ci              by the VM and can be used at any time by the allocating
114262306a36Sopenharmony_ci              application. With strict overcommit enabled on the system
114362306a36Sopenharmony_ci              (mode 2 in 'vm.overcommit_memory'), allocations which would
114462306a36Sopenharmony_ci              exceed the CommitLimit (detailed above) will not be permitted.
114562306a36Sopenharmony_ci              This is useful if one needs to guarantee that processes will
114662306a36Sopenharmony_ci              not fail due to lack of memory once that memory has been
114762306a36Sopenharmony_ci              successfully allocated.
114862306a36Sopenharmony_ciVmallocTotal
114962306a36Sopenharmony_ci              total size of vmalloc virtual address space
115062306a36Sopenharmony_ciVmallocUsed
115162306a36Sopenharmony_ci              amount of vmalloc area which is used
115262306a36Sopenharmony_ciVmallocChunk
115362306a36Sopenharmony_ci              largest contiguous block of vmalloc area which is free
115462306a36Sopenharmony_ciPercpu
115562306a36Sopenharmony_ci              Memory allocated to the percpu allocator used to back percpu
115662306a36Sopenharmony_ci              allocations. This stat excludes the cost of metadata.
115762306a36Sopenharmony_ciEarlyMemtestBad
115862306a36Sopenharmony_ci              The amount of RAM/memory in kB, that was identified as corrupted
115962306a36Sopenharmony_ci              by early memtest. If memtest was not run, this field will not
116062306a36Sopenharmony_ci              be displayed at all. Size is never rounded down to 0 kB.
116162306a36Sopenharmony_ci              That means if 0 kB is reported, you can safely assume
116262306a36Sopenharmony_ci              there was at least one pass of memtest and none of the passes
116362306a36Sopenharmony_ci              found a single faulty byte of RAM.
116462306a36Sopenharmony_ciHardwareCorrupted
116562306a36Sopenharmony_ci              The amount of RAM/memory in KB, the kernel identifies as
116662306a36Sopenharmony_ci              corrupted.
116762306a36Sopenharmony_ciAnonHugePages
116862306a36Sopenharmony_ci              Non-file backed huge pages mapped into userspace page tables
116962306a36Sopenharmony_ciShmemHugePages
117062306a36Sopenharmony_ci              Memory used by shared memory (shmem) and tmpfs allocated
117162306a36Sopenharmony_ci              with huge pages
117262306a36Sopenharmony_ciShmemPmdMapped
117362306a36Sopenharmony_ci              Shared memory mapped into userspace with huge pages
117462306a36Sopenharmony_ciFileHugePages
117562306a36Sopenharmony_ci              Memory used for filesystem data (page cache) allocated
117662306a36Sopenharmony_ci              with huge pages
117762306a36Sopenharmony_ciFilePmdMapped
117862306a36Sopenharmony_ci              Page cache mapped into userspace with huge pages
117962306a36Sopenharmony_ciCmaTotal
118062306a36Sopenharmony_ci              Memory reserved for the Contiguous Memory Allocator (CMA)
118162306a36Sopenharmony_ciCmaFree
118262306a36Sopenharmony_ci              Free remaining memory in the CMA reserves
118362306a36Sopenharmony_ciHugePages_Total, HugePages_Free, HugePages_Rsvd, HugePages_Surp, Hugepagesize, Hugetlb
118462306a36Sopenharmony_ci              See Documentation/admin-guide/mm/hugetlbpage.rst.
118562306a36Sopenharmony_ciDirectMap4k, DirectMap2M, DirectMap1G
118662306a36Sopenharmony_ci              Breakdown of page table sizes used in the kernel's
118762306a36Sopenharmony_ci              identity mapping of RAM
118862306a36Sopenharmony_ci
118962306a36Sopenharmony_civmallocinfo
119062306a36Sopenharmony_ci~~~~~~~~~~~
119162306a36Sopenharmony_ci
119262306a36Sopenharmony_ciProvides information about vmalloced/vmaped areas. One line per area,
119362306a36Sopenharmony_cicontaining the virtual address range of the area, size in bytes,
119462306a36Sopenharmony_cicaller information of the creator, and optional information depending
119562306a36Sopenharmony_cion the kind of area:
119662306a36Sopenharmony_ci
119762306a36Sopenharmony_ci ==========  ===================================================
119862306a36Sopenharmony_ci pages=nr    number of pages
119962306a36Sopenharmony_ci phys=addr   if a physical address was specified
120062306a36Sopenharmony_ci ioremap     I/O mapping (ioremap() and friends)
120162306a36Sopenharmony_ci vmalloc     vmalloc() area
120262306a36Sopenharmony_ci vmap        vmap()ed pages
120362306a36Sopenharmony_ci user        VM_USERMAP area
120462306a36Sopenharmony_ci vpages      buffer for pages pointers was vmalloced (huge area)
120562306a36Sopenharmony_ci N<node>=nr  (Only on NUMA kernels)
120662306a36Sopenharmony_ci             Number of pages allocated on memory node <node>
120762306a36Sopenharmony_ci ==========  ===================================================
120862306a36Sopenharmony_ci
120962306a36Sopenharmony_ci::
121062306a36Sopenharmony_ci
121162306a36Sopenharmony_ci    > cat /proc/vmallocinfo
121262306a36Sopenharmony_ci    0xffffc20000000000-0xffffc20000201000 2101248 alloc_large_system_hash+0x204 ...
121362306a36Sopenharmony_ci    /0x2c0 pages=512 vmalloc N0=128 N1=128 N2=128 N3=128
121462306a36Sopenharmony_ci    0xffffc20000201000-0xffffc20000302000 1052672 alloc_large_system_hash+0x204 ...
121562306a36Sopenharmony_ci    /0x2c0 pages=256 vmalloc N0=64 N1=64 N2=64 N3=64
121662306a36Sopenharmony_ci    0xffffc20000302000-0xffffc20000304000    8192 acpi_tb_verify_table+0x21/0x4f...
121762306a36Sopenharmony_ci    phys=7fee8000 ioremap
121862306a36Sopenharmony_ci    0xffffc20000304000-0xffffc20000307000   12288 acpi_tb_verify_table+0x21/0x4f...
121962306a36Sopenharmony_ci    phys=7fee7000 ioremap
122062306a36Sopenharmony_ci    0xffffc2000031d000-0xffffc2000031f000    8192 init_vdso_vars+0x112/0x210
122162306a36Sopenharmony_ci    0xffffc2000031f000-0xffffc2000032b000   49152 cramfs_uncompress_init+0x2e ...
122262306a36Sopenharmony_ci    /0x80 pages=11 vmalloc N0=3 N1=3 N2=2 N3=3
122362306a36Sopenharmony_ci    0xffffc2000033a000-0xffffc2000033d000   12288 sys_swapon+0x640/0xac0      ...
122462306a36Sopenharmony_ci    pages=2 vmalloc N1=2
122562306a36Sopenharmony_ci    0xffffc20000347000-0xffffc2000034c000   20480 xt_alloc_table_info+0xfe ...
122662306a36Sopenharmony_ci    /0x130 [x_tables] pages=4 vmalloc N0=4
122762306a36Sopenharmony_ci    0xffffffffa0000000-0xffffffffa000f000   61440 sys_init_module+0xc27/0x1d00 ...
122862306a36Sopenharmony_ci    pages=14 vmalloc N2=14
122962306a36Sopenharmony_ci    0xffffffffa000f000-0xffffffffa0014000   20480 sys_init_module+0xc27/0x1d00 ...
123062306a36Sopenharmony_ci    pages=4 vmalloc N1=4
123162306a36Sopenharmony_ci    0xffffffffa0014000-0xffffffffa0017000   12288 sys_init_module+0xc27/0x1d00 ...
123262306a36Sopenharmony_ci    pages=2 vmalloc N1=2
123362306a36Sopenharmony_ci    0xffffffffa0017000-0xffffffffa0022000   45056 sys_init_module+0xc27/0x1d00 ...
123462306a36Sopenharmony_ci    pages=10 vmalloc N0=10
123562306a36Sopenharmony_ci
123662306a36Sopenharmony_ci
123762306a36Sopenharmony_cisoftirqs
123862306a36Sopenharmony_ci~~~~~~~~
123962306a36Sopenharmony_ci
124062306a36Sopenharmony_ciProvides counts of softirq handlers serviced since boot time, for each CPU.
124162306a36Sopenharmony_ci
124262306a36Sopenharmony_ci::
124362306a36Sopenharmony_ci
124462306a36Sopenharmony_ci    > cat /proc/softirqs
124562306a36Sopenharmony_ci		  CPU0       CPU1       CPU2       CPU3
124662306a36Sopenharmony_ci	HI:          0          0          0          0
124762306a36Sopenharmony_ci    TIMER:       27166      27120      27097      27034
124862306a36Sopenharmony_ci    NET_TX:          0          0          0         17
124962306a36Sopenharmony_ci    NET_RX:         42          0          0         39
125062306a36Sopenharmony_ci    BLOCK:           0          0        107       1121
125162306a36Sopenharmony_ci    TASKLET:         0          0          0        290
125262306a36Sopenharmony_ci    SCHED:       27035      26983      26971      26746
125362306a36Sopenharmony_ci    HRTIMER:         0          0          0          0
125462306a36Sopenharmony_ci	RCU:      1678       1769       2178       2250
125562306a36Sopenharmony_ci
125662306a36Sopenharmony_ci1.3 Networking info in /proc/net
125762306a36Sopenharmony_ci--------------------------------
125862306a36Sopenharmony_ci
125962306a36Sopenharmony_ciThe subdirectory  /proc/net  follows  the  usual  pattern. Table 1-8 shows the
126062306a36Sopenharmony_ciadditional values  you  get  for  IP  version 6 if you configure the kernel to
126162306a36Sopenharmony_cisupport this. Table 1-9 lists the files and their meaning.
126262306a36Sopenharmony_ci
126362306a36Sopenharmony_ci
126462306a36Sopenharmony_ci.. table:: Table 1-8: IPv6 info in /proc/net
126562306a36Sopenharmony_ci
126662306a36Sopenharmony_ci ========== =====================================================
126762306a36Sopenharmony_ci File       Content
126862306a36Sopenharmony_ci ========== =====================================================
126962306a36Sopenharmony_ci udp6       UDP sockets (IPv6)
127062306a36Sopenharmony_ci tcp6       TCP sockets (IPv6)
127162306a36Sopenharmony_ci raw6       Raw device statistics (IPv6)
127262306a36Sopenharmony_ci igmp6      IP multicast addresses, which this host joined (IPv6)
127362306a36Sopenharmony_ci if_inet6   List of IPv6 interface addresses
127462306a36Sopenharmony_ci ipv6_route Kernel routing table for IPv6
127562306a36Sopenharmony_ci rt6_stats  Global IPv6 routing tables statistics
127662306a36Sopenharmony_ci sockstat6  Socket statistics (IPv6)
127762306a36Sopenharmony_ci snmp6      Snmp data (IPv6)
127862306a36Sopenharmony_ci ========== =====================================================
127962306a36Sopenharmony_ci
128062306a36Sopenharmony_ci.. table:: Table 1-9: Network info in /proc/net
128162306a36Sopenharmony_ci
128262306a36Sopenharmony_ci ============= ================================================================
128362306a36Sopenharmony_ci File          Content
128462306a36Sopenharmony_ci ============= ================================================================
128562306a36Sopenharmony_ci arp           Kernel  ARP table
128662306a36Sopenharmony_ci dev           network devices with statistics
128762306a36Sopenharmony_ci dev_mcast     the Layer2 multicast groups a device is listening too
128862306a36Sopenharmony_ci               (interface index, label, number of references, number of bound
128962306a36Sopenharmony_ci               addresses).
129062306a36Sopenharmony_ci dev_stat      network device status
129162306a36Sopenharmony_ci ip_fwchains   Firewall chain linkage
129262306a36Sopenharmony_ci ip_fwnames    Firewall chain names
129362306a36Sopenharmony_ci ip_masq       Directory containing the masquerading tables
129462306a36Sopenharmony_ci ip_masquerade Major masquerading table
129562306a36Sopenharmony_ci netstat       Network statistics
129662306a36Sopenharmony_ci raw           raw device statistics
129762306a36Sopenharmony_ci route         Kernel routing table
129862306a36Sopenharmony_ci rpc           Directory containing rpc info
129962306a36Sopenharmony_ci rt_cache      Routing cache
130062306a36Sopenharmony_ci snmp          SNMP data
130162306a36Sopenharmony_ci sockstat      Socket statistics
130262306a36Sopenharmony_ci softnet_stat  Per-CPU incoming packets queues statistics of online CPUs
130362306a36Sopenharmony_ci tcp           TCP  sockets
130462306a36Sopenharmony_ci udp           UDP sockets
130562306a36Sopenharmony_ci unix          UNIX domain sockets
130662306a36Sopenharmony_ci wireless      Wireless interface data (Wavelan etc)
130762306a36Sopenharmony_ci igmp          IP multicast addresses, which this host joined
130862306a36Sopenharmony_ci psched        Global packet scheduler parameters.
130962306a36Sopenharmony_ci netlink       List of PF_NETLINK sockets
131062306a36Sopenharmony_ci ip_mr_vifs    List of multicast virtual interfaces
131162306a36Sopenharmony_ci ip_mr_cache   List of multicast routing cache
131262306a36Sopenharmony_ci ============= ================================================================
131362306a36Sopenharmony_ci
131462306a36Sopenharmony_ciYou can  use  this  information  to see which network devices are available in
131562306a36Sopenharmony_ciyour system and how much traffic was routed over those devices::
131662306a36Sopenharmony_ci
131762306a36Sopenharmony_ci  > cat /proc/net/dev
131862306a36Sopenharmony_ci  Inter-|Receive                                                   |[...
131962306a36Sopenharmony_ci   face |bytes    packets errs drop fifo frame compressed multicast|[...
132062306a36Sopenharmony_ci      lo:  908188   5596     0    0    0     0          0         0 [...
132162306a36Sopenharmony_ci    ppp0:15475140  20721   410    0    0   410          0         0 [...
132262306a36Sopenharmony_ci    eth0:  614530   7085     0    0    0     0          0         1 [...
132362306a36Sopenharmony_ci
132462306a36Sopenharmony_ci  ...] Transmit
132562306a36Sopenharmony_ci  ...] bytes    packets errs drop fifo colls carrier compressed
132662306a36Sopenharmony_ci  ...]  908188     5596    0    0    0     0       0          0
132762306a36Sopenharmony_ci  ...] 1375103    17405    0    0    0     0       0          0
132862306a36Sopenharmony_ci  ...] 1703981     5535    0    0    0     3       0          0
132962306a36Sopenharmony_ci
133062306a36Sopenharmony_ciIn addition, each Channel Bond interface has its own directory.  For
133162306a36Sopenharmony_ciexample, the bond0 device will have a directory called /proc/net/bond0/.
133262306a36Sopenharmony_ciIt will contain information that is specific to that bond, such as the
133362306a36Sopenharmony_cicurrent slaves of the bond, the link status of the slaves, and how
133462306a36Sopenharmony_cimany times the slaves link has failed.
133562306a36Sopenharmony_ci
133662306a36Sopenharmony_ci1.4 SCSI info
133762306a36Sopenharmony_ci-------------
133862306a36Sopenharmony_ci
133962306a36Sopenharmony_ciIf you have a SCSI or ATA host adapter in your system, you'll find a
134062306a36Sopenharmony_cisubdirectory named after the driver for this adapter in /proc/scsi.
134162306a36Sopenharmony_ciYou'll also see a list of all recognized SCSI devices in /proc/scsi::
134262306a36Sopenharmony_ci
134362306a36Sopenharmony_ci  >cat /proc/scsi/scsi
134462306a36Sopenharmony_ci  Attached devices:
134562306a36Sopenharmony_ci  Host: scsi0 Channel: 00 Id: 00 Lun: 00
134662306a36Sopenharmony_ci    Vendor: IBM      Model: DGHS09U          Rev: 03E0
134762306a36Sopenharmony_ci    Type:   Direct-Access                    ANSI SCSI revision: 03
134862306a36Sopenharmony_ci  Host: scsi0 Channel: 00 Id: 06 Lun: 00
134962306a36Sopenharmony_ci    Vendor: PIONEER  Model: CD-ROM DR-U06S   Rev: 1.04
135062306a36Sopenharmony_ci    Type:   CD-ROM                           ANSI SCSI revision: 02
135162306a36Sopenharmony_ci
135262306a36Sopenharmony_ci
135362306a36Sopenharmony_ciThe directory  named  after  the driver has one file for each adapter found in
135462306a36Sopenharmony_cithe system.  These  files  contain information about the controller, including
135562306a36Sopenharmony_cithe used  IRQ  and  the  IO  address range. The amount of information shown is
135662306a36Sopenharmony_cidependent on  the adapter you use. The example shows the output for an Adaptec
135762306a36Sopenharmony_ciAHA-2940 SCSI adapter::
135862306a36Sopenharmony_ci
135962306a36Sopenharmony_ci  > cat /proc/scsi/aic7xxx/0
136062306a36Sopenharmony_ci
136162306a36Sopenharmony_ci  Adaptec AIC7xxx driver version: 5.1.19/3.2.4
136262306a36Sopenharmony_ci  Compile Options:
136362306a36Sopenharmony_ci    TCQ Enabled By Default : Disabled
136462306a36Sopenharmony_ci    AIC7XXX_PROC_STATS     : Disabled
136562306a36Sopenharmony_ci    AIC7XXX_RESET_DELAY    : 5
136662306a36Sopenharmony_ci  Adapter Configuration:
136762306a36Sopenharmony_ci             SCSI Adapter: Adaptec AHA-294X Ultra SCSI host adapter
136862306a36Sopenharmony_ci                             Ultra Wide Controller
136962306a36Sopenharmony_ci      PCI MMAPed I/O Base: 0xeb001000
137062306a36Sopenharmony_ci   Adapter SEEPROM Config: SEEPROM found and used.
137162306a36Sopenharmony_ci        Adaptec SCSI BIOS: Enabled
137262306a36Sopenharmony_ci                      IRQ: 10
137362306a36Sopenharmony_ci                     SCBs: Active 0, Max Active 2,
137462306a36Sopenharmony_ci                           Allocated 15, HW 16, Page 255
137562306a36Sopenharmony_ci               Interrupts: 160328
137662306a36Sopenharmony_ci        BIOS Control Word: 0x18b6
137762306a36Sopenharmony_ci     Adapter Control Word: 0x005b
137862306a36Sopenharmony_ci     Extended Translation: Enabled
137962306a36Sopenharmony_ci  Disconnect Enable Flags: 0xffff
138062306a36Sopenharmony_ci       Ultra Enable Flags: 0x0001
138162306a36Sopenharmony_ci   Tag Queue Enable Flags: 0x0000
138262306a36Sopenharmony_ci  Ordered Queue Tag Flags: 0x0000
138362306a36Sopenharmony_ci  Default Tag Queue Depth: 8
138462306a36Sopenharmony_ci      Tagged Queue By Device array for aic7xxx host instance 0:
138562306a36Sopenharmony_ci        {255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255}
138662306a36Sopenharmony_ci      Actual queue depth per device for aic7xxx host instance 0:
138762306a36Sopenharmony_ci        {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
138862306a36Sopenharmony_ci  Statistics:
138962306a36Sopenharmony_ci  (scsi0:0:0:0)
139062306a36Sopenharmony_ci    Device using Wide/Sync transfers at 40.0 MByte/sec, offset 8
139162306a36Sopenharmony_ci    Transinfo settings: current(12/8/1/0), goal(12/8/1/0), user(12/15/1/0)
139262306a36Sopenharmony_ci    Total transfers 160151 (74577 reads and 85574 writes)
139362306a36Sopenharmony_ci  (scsi0:0:6:0)
139462306a36Sopenharmony_ci    Device using Narrow/Sync transfers at 5.0 MByte/sec, offset 15
139562306a36Sopenharmony_ci    Transinfo settings: current(50/15/0/0), goal(50/15/0/0), user(50/15/0/0)
139662306a36Sopenharmony_ci    Total transfers 0 (0 reads and 0 writes)
139762306a36Sopenharmony_ci
139862306a36Sopenharmony_ci
139962306a36Sopenharmony_ci1.5 Parallel port info in /proc/parport
140062306a36Sopenharmony_ci---------------------------------------
140162306a36Sopenharmony_ci
140262306a36Sopenharmony_ciThe directory  /proc/parport  contains information about the parallel ports of
140362306a36Sopenharmony_ciyour system.  It  has  one  subdirectory  for  each port, named after the port
140462306a36Sopenharmony_cinumber (0,1,2,...).
140562306a36Sopenharmony_ci
140662306a36Sopenharmony_ciThese directories contain the four files shown in Table 1-10.
140762306a36Sopenharmony_ci
140862306a36Sopenharmony_ci
140962306a36Sopenharmony_ci.. table:: Table 1-10: Files in /proc/parport
141062306a36Sopenharmony_ci
141162306a36Sopenharmony_ci ========= ====================================================================
141262306a36Sopenharmony_ci File      Content
141362306a36Sopenharmony_ci ========= ====================================================================
141462306a36Sopenharmony_ci autoprobe Any IEEE-1284 device ID information that has been acquired.
141562306a36Sopenharmony_ci devices   list of the device drivers using that port. A + will appear by the
141662306a36Sopenharmony_ci           name of the device currently using the port (it might not appear
141762306a36Sopenharmony_ci           against any).
141862306a36Sopenharmony_ci hardware  Parallel port's base address, IRQ line and DMA channel.
141962306a36Sopenharmony_ci irq       IRQ that parport is using for that port. This is in a separate
142062306a36Sopenharmony_ci           file to allow you to alter it by writing a new value in (IRQ
142162306a36Sopenharmony_ci           number or none).
142262306a36Sopenharmony_ci ========= ====================================================================
142362306a36Sopenharmony_ci
142462306a36Sopenharmony_ci1.6 TTY info in /proc/tty
142562306a36Sopenharmony_ci-------------------------
142662306a36Sopenharmony_ci
142762306a36Sopenharmony_ciInformation about  the  available  and actually used tty's can be found in the
142862306a36Sopenharmony_cidirectory /proc/tty. You'll find  entries  for drivers and line disciplines in
142962306a36Sopenharmony_cithis directory, as shown in Table 1-11.
143062306a36Sopenharmony_ci
143162306a36Sopenharmony_ci
143262306a36Sopenharmony_ci.. table:: Table 1-11: Files in /proc/tty
143362306a36Sopenharmony_ci
143462306a36Sopenharmony_ci ============= ==============================================
143562306a36Sopenharmony_ci File          Content
143662306a36Sopenharmony_ci ============= ==============================================
143762306a36Sopenharmony_ci drivers       list of drivers and their usage
143862306a36Sopenharmony_ci ldiscs        registered line disciplines
143962306a36Sopenharmony_ci driver/serial usage statistic and status of single tty lines
144062306a36Sopenharmony_ci ============= ==============================================
144162306a36Sopenharmony_ci
144262306a36Sopenharmony_ciTo see  which  tty's  are  currently in use, you can simply look into the file
144362306a36Sopenharmony_ci/proc/tty/drivers::
144462306a36Sopenharmony_ci
144562306a36Sopenharmony_ci  > cat /proc/tty/drivers
144662306a36Sopenharmony_ci  pty_slave            /dev/pts      136   0-255 pty:slave
144762306a36Sopenharmony_ci  pty_master           /dev/ptm      128   0-255 pty:master
144862306a36Sopenharmony_ci  pty_slave            /dev/ttyp       3   0-255 pty:slave
144962306a36Sopenharmony_ci  pty_master           /dev/pty        2   0-255 pty:master
145062306a36Sopenharmony_ci  serial               /dev/cua        5   64-67 serial:callout
145162306a36Sopenharmony_ci  serial               /dev/ttyS       4   64-67 serial
145262306a36Sopenharmony_ci  /dev/tty0            /dev/tty0       4       0 system:vtmaster
145362306a36Sopenharmony_ci  /dev/ptmx            /dev/ptmx       5       2 system
145462306a36Sopenharmony_ci  /dev/console         /dev/console    5       1 system:console
145562306a36Sopenharmony_ci  /dev/tty             /dev/tty        5       0 system:/dev/tty
145662306a36Sopenharmony_ci  unknown              /dev/tty        4    1-63 console
145762306a36Sopenharmony_ci
145862306a36Sopenharmony_ci
145962306a36Sopenharmony_ci1.7 Miscellaneous kernel statistics in /proc/stat
146062306a36Sopenharmony_ci-------------------------------------------------
146162306a36Sopenharmony_ci
146262306a36Sopenharmony_ciVarious pieces   of  information about  kernel activity  are  available in the
146362306a36Sopenharmony_ci/proc/stat file.  All  of  the numbers reported  in  this file are  aggregates
146462306a36Sopenharmony_cisince the system first booted.  For a quick look, simply cat the file::
146562306a36Sopenharmony_ci
146662306a36Sopenharmony_ci  > cat /proc/stat
146762306a36Sopenharmony_ci  cpu  237902850 368826709 106375398 1873517540 1135548 0 14507935 0 0 0
146862306a36Sopenharmony_ci  cpu0 60045249 91891769 26331539 468411416 495718 0 5739640 0 0 0
146962306a36Sopenharmony_ci  cpu1 59746288 91759249 26609887 468860630 312281 0 4384817 0 0 0
147062306a36Sopenharmony_ci  cpu2 59489247 92985423 26904446 467808813 171668 0 2268998 0 0 0
147162306a36Sopenharmony_ci  cpu3 58622065 92190267 26529524 468436680 155879 0 2114478 0 0 0
147262306a36Sopenharmony_ci  intr 8688370575 8 3373 0 0 0 0 0 0 1 40791 0 0 353317 0 0 0 0 224789828 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 190974333 41958554 123983334 43 0 224593 0 0 0 <more 0's deleted>
147362306a36Sopenharmony_ci  ctxt 22848221062
147462306a36Sopenharmony_ci  btime 1605316999
147562306a36Sopenharmony_ci  processes 746787147
147662306a36Sopenharmony_ci  procs_running 2
147762306a36Sopenharmony_ci  procs_blocked 0
147862306a36Sopenharmony_ci  softirq 12121874454 100099120 3938138295 127375644 2795979 187870761 0 173808342 3072582055 52608 224184354
147962306a36Sopenharmony_ci
148062306a36Sopenharmony_ciThe very first  "cpu" line aggregates the  numbers in all  of the other "cpuN"
148162306a36Sopenharmony_cilines.  These numbers identify the amount of time the CPU has spent performing
148262306a36Sopenharmony_cidifferent kinds of work.  Time units are in USER_HZ (typically hundredths of a
148362306a36Sopenharmony_cisecond).  The meanings of the columns are as follows, from left to right:
148462306a36Sopenharmony_ci
148562306a36Sopenharmony_ci- user: normal processes executing in user mode
148662306a36Sopenharmony_ci- nice: niced processes executing in user mode
148762306a36Sopenharmony_ci- system: processes executing in kernel mode
148862306a36Sopenharmony_ci- idle: twiddling thumbs
148962306a36Sopenharmony_ci- iowait: In a word, iowait stands for waiting for I/O to complete. But there
149062306a36Sopenharmony_ci  are several problems:
149162306a36Sopenharmony_ci
149262306a36Sopenharmony_ci  1. CPU will not wait for I/O to complete, iowait is the time that a task is
149362306a36Sopenharmony_ci     waiting for I/O to complete. When CPU goes into idle state for
149462306a36Sopenharmony_ci     outstanding task I/O, another task will be scheduled on this CPU.
149562306a36Sopenharmony_ci  2. In a multi-core CPU, the task waiting for I/O to complete is not running
149662306a36Sopenharmony_ci     on any CPU, so the iowait of each CPU is difficult to calculate.
149762306a36Sopenharmony_ci  3. The value of iowait field in /proc/stat will decrease in certain
149862306a36Sopenharmony_ci     conditions.
149962306a36Sopenharmony_ci
150062306a36Sopenharmony_ci  So, the iowait is not reliable by reading from /proc/stat.
150162306a36Sopenharmony_ci- irq: servicing interrupts
150262306a36Sopenharmony_ci- softirq: servicing softirqs
150362306a36Sopenharmony_ci- steal: involuntary wait
150462306a36Sopenharmony_ci- guest: running a normal guest
150562306a36Sopenharmony_ci- guest_nice: running a niced guest
150662306a36Sopenharmony_ci
150762306a36Sopenharmony_ciThe "intr" line gives counts of interrupts  serviced since boot time, for each
150862306a36Sopenharmony_ciof the  possible system interrupts.   The first  column  is the  total of  all
150962306a36Sopenharmony_ciinterrupts serviced  including  unnumbered  architecture specific  interrupts;
151062306a36Sopenharmony_cieach  subsequent column is the  total for that particular numbered interrupt.
151162306a36Sopenharmony_ciUnnumbered interrupts are not shown, only summed into the total.
151262306a36Sopenharmony_ci
151362306a36Sopenharmony_ciThe "ctxt" line gives the total number of context switches across all CPUs.
151462306a36Sopenharmony_ci
151562306a36Sopenharmony_ciThe "btime" line gives  the time at which the  system booted, in seconds since
151662306a36Sopenharmony_cithe Unix epoch.
151762306a36Sopenharmony_ci
151862306a36Sopenharmony_ciThe "processes" line gives the number  of processes and threads created, which
151962306a36Sopenharmony_ciincludes (but  is not limited  to) those  created by  calls to the  fork() and
152062306a36Sopenharmony_ciclone() system calls.
152162306a36Sopenharmony_ci
152262306a36Sopenharmony_ciThe "procs_running" line gives the total number of threads that are
152362306a36Sopenharmony_cirunning or ready to run (i.e., the total number of runnable threads).
152462306a36Sopenharmony_ci
152562306a36Sopenharmony_ciThe   "procs_blocked" line gives  the  number of  processes currently blocked,
152662306a36Sopenharmony_ciwaiting for I/O to complete.
152762306a36Sopenharmony_ci
152862306a36Sopenharmony_ciThe "softirq" line gives counts of softirqs serviced since boot time, for each
152962306a36Sopenharmony_ciof the possible system softirqs. The first column is the total of all
153062306a36Sopenharmony_cisoftirqs serviced; each subsequent column is the total for that particular
153162306a36Sopenharmony_cisoftirq.
153262306a36Sopenharmony_ci
153362306a36Sopenharmony_ci
153462306a36Sopenharmony_ci1.8 Ext4 file system parameters
153562306a36Sopenharmony_ci-------------------------------
153662306a36Sopenharmony_ci
153762306a36Sopenharmony_ciInformation about mounted ext4 file systems can be found in
153862306a36Sopenharmony_ci/proc/fs/ext4.  Each mounted filesystem will have a directory in
153962306a36Sopenharmony_ci/proc/fs/ext4 based on its device name (i.e., /proc/fs/ext4/hdc or
154062306a36Sopenharmony_ci/proc/fs/ext4/sda9 or /proc/fs/ext4/dm-0).   The files in each per-device
154162306a36Sopenharmony_cidirectory are shown in Table 1-12, below.
154262306a36Sopenharmony_ci
154362306a36Sopenharmony_ci.. table:: Table 1-12: Files in /proc/fs/ext4/<devname>
154462306a36Sopenharmony_ci
154562306a36Sopenharmony_ci ==============  ==========================================================
154662306a36Sopenharmony_ci File            Content
154762306a36Sopenharmony_ci mb_groups       details of multiblock allocator buddy cache of free blocks
154862306a36Sopenharmony_ci ==============  ==========================================================
154962306a36Sopenharmony_ci
155062306a36Sopenharmony_ci1.9 /proc/consoles
155162306a36Sopenharmony_ci-------------------
155262306a36Sopenharmony_ciShows registered system console lines.
155362306a36Sopenharmony_ci
155462306a36Sopenharmony_ciTo see which character device lines are currently used for the system console
155562306a36Sopenharmony_ci/dev/console, you may simply look into the file /proc/consoles::
155662306a36Sopenharmony_ci
155762306a36Sopenharmony_ci  > cat /proc/consoles
155862306a36Sopenharmony_ci  tty0                 -WU (ECp)       4:7
155962306a36Sopenharmony_ci  ttyS0                -W- (Ep)        4:64
156062306a36Sopenharmony_ci
156162306a36Sopenharmony_ciThe columns are:
156262306a36Sopenharmony_ci
156362306a36Sopenharmony_ci+--------------------+-------------------------------------------------------+
156462306a36Sopenharmony_ci| device             | name of the device                                    |
156562306a36Sopenharmony_ci+====================+=======================================================+
156662306a36Sopenharmony_ci| operations         | * R = can do read operations                          |
156762306a36Sopenharmony_ci|                    | * W = can do write operations                         |
156862306a36Sopenharmony_ci|                    | * U = can do unblank                                  |
156962306a36Sopenharmony_ci+--------------------+-------------------------------------------------------+
157062306a36Sopenharmony_ci| flags              | * E = it is enabled                                   |
157162306a36Sopenharmony_ci|                    | * C = it is preferred console                         |
157262306a36Sopenharmony_ci|                    | * B = it is primary boot console                      |
157362306a36Sopenharmony_ci|                    | * p = it is used for printk buffer                    |
157462306a36Sopenharmony_ci|                    | * b = it is not a TTY but a Braille device            |
157562306a36Sopenharmony_ci|                    | * a = it is safe to use when cpu is offline           |
157662306a36Sopenharmony_ci+--------------------+-------------------------------------------------------+
157762306a36Sopenharmony_ci| major:minor        | major and minor number of the device separated by a   |
157862306a36Sopenharmony_ci|                    | colon                                                 |
157962306a36Sopenharmony_ci+--------------------+-------------------------------------------------------+
158062306a36Sopenharmony_ci
158162306a36Sopenharmony_ciSummary
158262306a36Sopenharmony_ci-------
158362306a36Sopenharmony_ci
158462306a36Sopenharmony_ciThe /proc file system serves information about the running system. It not only
158562306a36Sopenharmony_ciallows access to process data but also allows you to request the kernel status
158662306a36Sopenharmony_ciby reading files in the hierarchy.
158762306a36Sopenharmony_ci
158862306a36Sopenharmony_ciThe directory  structure  of /proc reflects the types of information and makes
158962306a36Sopenharmony_ciit easy, if not obvious, where to look for specific data.
159062306a36Sopenharmony_ci
159162306a36Sopenharmony_ciChapter 2: Modifying System Parameters
159262306a36Sopenharmony_ci======================================
159362306a36Sopenharmony_ci
159462306a36Sopenharmony_ciIn This Chapter
159562306a36Sopenharmony_ci---------------
159662306a36Sopenharmony_ci
159762306a36Sopenharmony_ci* Modifying kernel parameters by writing into files found in /proc/sys
159862306a36Sopenharmony_ci* Exploring the files which modify certain parameters
159962306a36Sopenharmony_ci* Review of the /proc/sys file tree
160062306a36Sopenharmony_ci
160162306a36Sopenharmony_ci------------------------------------------------------------------------------
160262306a36Sopenharmony_ci
160362306a36Sopenharmony_ciA very  interesting part of /proc is the directory /proc/sys. This is not only
160462306a36Sopenharmony_cia source  of  information,  it also allows you to change parameters within the
160562306a36Sopenharmony_cikernel. Be  very  careful  when attempting this. You can optimize your system,
160662306a36Sopenharmony_cibut you  can  also  cause  it  to  crash.  Never  alter kernel parameters on a
160762306a36Sopenharmony_ciproduction system.  Set  up  a  development machine and test to make sure that
160862306a36Sopenharmony_cieverything works  the  way  you want it to. You may have no alternative but to
160962306a36Sopenharmony_cireboot the machine once an error has been made.
161062306a36Sopenharmony_ci
161162306a36Sopenharmony_ciTo change  a  value,  simply  echo  the new value into the file.
161262306a36Sopenharmony_ciYou need to be root to do this. You  can  create  your  own  boot script
161362306a36Sopenharmony_cito perform this every time your system boots.
161462306a36Sopenharmony_ci
161562306a36Sopenharmony_ciThe files  in /proc/sys can be used to fine tune and monitor miscellaneous and
161662306a36Sopenharmony_cigeneral things  in  the operation of the Linux kernel. Since some of the files
161762306a36Sopenharmony_cican inadvertently  disrupt  your  system,  it  is  advisable  to  read  both
161862306a36Sopenharmony_cidocumentation and  source  before actually making adjustments. In any case, be
161962306a36Sopenharmony_civery careful  when  writing  to  any  of these files. The entries in /proc may
162062306a36Sopenharmony_cichange slightly between the 2.1.* and the 2.2 kernel, so if there is any doubt
162162306a36Sopenharmony_cireview the kernel documentation in the directory linux/Documentation.
162262306a36Sopenharmony_ciThis chapter  is  heavily  based  on the documentation included in the pre 2.2
162362306a36Sopenharmony_cikernels, and became part of it in version 2.2.1 of the Linux kernel.
162462306a36Sopenharmony_ci
162562306a36Sopenharmony_ciPlease see: Documentation/admin-guide/sysctl/ directory for descriptions of
162662306a36Sopenharmony_cithese entries.
162762306a36Sopenharmony_ci
162862306a36Sopenharmony_ciSummary
162962306a36Sopenharmony_ci-------
163062306a36Sopenharmony_ci
163162306a36Sopenharmony_ciCertain aspects  of  kernel  behavior  can be modified at runtime, without the
163262306a36Sopenharmony_cineed to  recompile  the kernel, or even to reboot the system. The files in the
163362306a36Sopenharmony_ci/proc/sys tree  can  not only be read, but also modified. You can use the echo
163462306a36Sopenharmony_cicommand to write value into these files, thereby changing the default settings
163562306a36Sopenharmony_ciof the kernel.
163662306a36Sopenharmony_ci
163762306a36Sopenharmony_ci
163862306a36Sopenharmony_ciChapter 3: Per-process Parameters
163962306a36Sopenharmony_ci=================================
164062306a36Sopenharmony_ci
164162306a36Sopenharmony_ci3.1 /proc/<pid>/oom_adj & /proc/<pid>/oom_score_adj- Adjust the oom-killer score
164262306a36Sopenharmony_ci--------------------------------------------------------------------------------
164362306a36Sopenharmony_ci
164462306a36Sopenharmony_ciThese files can be used to adjust the badness heuristic used to select which
164562306a36Sopenharmony_ciprocess gets killed in out of memory (oom) conditions.
164662306a36Sopenharmony_ci
164762306a36Sopenharmony_ciThe badness heuristic assigns a value to each candidate task ranging from 0
164862306a36Sopenharmony_ci(never kill) to 1000 (always kill) to determine which process is targeted.  The
164962306a36Sopenharmony_ciunits are roughly a proportion along that range of allowed memory the process
165062306a36Sopenharmony_cimay allocate from based on an estimation of its current memory and swap use.
165162306a36Sopenharmony_ciFor example, if a task is using all allowed memory, its badness score will be
165262306a36Sopenharmony_ci1000.  If it is using half of its allowed memory, its score will be 500.
165362306a36Sopenharmony_ci
165462306a36Sopenharmony_ciThe amount of "allowed" memory depends on the context in which the oom killer
165562306a36Sopenharmony_ciwas called.  If it is due to the memory assigned to the allocating task's cpuset
165662306a36Sopenharmony_cibeing exhausted, the allowed memory represents the set of mems assigned to that
165762306a36Sopenharmony_cicpuset.  If it is due to a mempolicy's node(s) being exhausted, the allowed
165862306a36Sopenharmony_cimemory represents the set of mempolicy nodes.  If it is due to a memory
165962306a36Sopenharmony_cilimit (or swap limit) being reached, the allowed memory is that configured
166062306a36Sopenharmony_cilimit.  Finally, if it is due to the entire system being out of memory, the
166162306a36Sopenharmony_ciallowed memory represents all allocatable resources.
166262306a36Sopenharmony_ci
166362306a36Sopenharmony_ciThe value of /proc/<pid>/oom_score_adj is added to the badness score before it
166462306a36Sopenharmony_ciis used to determine which task to kill.  Acceptable values range from -1000
166562306a36Sopenharmony_ci(OOM_SCORE_ADJ_MIN) to +1000 (OOM_SCORE_ADJ_MAX).  This allows userspace to
166662306a36Sopenharmony_cipolarize the preference for oom killing either by always preferring a certain
166762306a36Sopenharmony_citask or completely disabling it.  The lowest possible value, -1000, is
166862306a36Sopenharmony_ciequivalent to disabling oom killing entirely for that task since it will always
166962306a36Sopenharmony_cireport a badness score of 0.
167062306a36Sopenharmony_ci
167162306a36Sopenharmony_ciConsequently, it is very simple for userspace to define the amount of memory to
167262306a36Sopenharmony_ciconsider for each task.  Setting a /proc/<pid>/oom_score_adj value of +500, for
167362306a36Sopenharmony_ciexample, is roughly equivalent to allowing the remainder of tasks sharing the
167462306a36Sopenharmony_cisame system, cpuset, mempolicy, or memory controller resources to use at least
167562306a36Sopenharmony_ci50% more memory.  A value of -500, on the other hand, would be roughly
167662306a36Sopenharmony_ciequivalent to discounting 50% of the task's allowed memory from being considered
167762306a36Sopenharmony_cias scoring against the task.
167862306a36Sopenharmony_ci
167962306a36Sopenharmony_ciFor backwards compatibility with previous kernels, /proc/<pid>/oom_adj may also
168062306a36Sopenharmony_cibe used to tune the badness score.  Its acceptable values range from -16
168162306a36Sopenharmony_ci(OOM_ADJUST_MIN) to +15 (OOM_ADJUST_MAX) and a special value of -17
168262306a36Sopenharmony_ci(OOM_DISABLE) to disable oom killing entirely for that task.  Its value is
168362306a36Sopenharmony_ciscaled linearly with /proc/<pid>/oom_score_adj.
168462306a36Sopenharmony_ci
168562306a36Sopenharmony_ciThe value of /proc/<pid>/oom_score_adj may be reduced no lower than the last
168662306a36Sopenharmony_civalue set by a CAP_SYS_RESOURCE process. To reduce the value any lower
168762306a36Sopenharmony_cirequires CAP_SYS_RESOURCE.
168862306a36Sopenharmony_ci
168962306a36Sopenharmony_ci
169062306a36Sopenharmony_ci3.2 /proc/<pid>/oom_score - Display current oom-killer score
169162306a36Sopenharmony_ci-------------------------------------------------------------
169262306a36Sopenharmony_ci
169362306a36Sopenharmony_ciThis file can be used to check the current score used by the oom-killer for
169462306a36Sopenharmony_ciany given <pid>. Use it together with /proc/<pid>/oom_score_adj to tune which
169562306a36Sopenharmony_ciprocess should be killed in an out-of-memory situation.
169662306a36Sopenharmony_ci
169762306a36Sopenharmony_ciPlease note that the exported value includes oom_score_adj so it is
169862306a36Sopenharmony_cieffectively in range [0,2000].
169962306a36Sopenharmony_ci
170062306a36Sopenharmony_ci
170162306a36Sopenharmony_ci3.3  /proc/<pid>/io - Display the IO accounting fields
170262306a36Sopenharmony_ci-------------------------------------------------------
170362306a36Sopenharmony_ci
170462306a36Sopenharmony_ciThis file contains IO statistics for each running process.
170562306a36Sopenharmony_ci
170662306a36Sopenharmony_ciExample
170762306a36Sopenharmony_ci~~~~~~~
170862306a36Sopenharmony_ci
170962306a36Sopenharmony_ci::
171062306a36Sopenharmony_ci
171162306a36Sopenharmony_ci    test:/tmp # dd if=/dev/zero of=/tmp/test.dat &
171262306a36Sopenharmony_ci    [1] 3828
171362306a36Sopenharmony_ci
171462306a36Sopenharmony_ci    test:/tmp # cat /proc/3828/io
171562306a36Sopenharmony_ci    rchar: 323934931
171662306a36Sopenharmony_ci    wchar: 323929600
171762306a36Sopenharmony_ci    syscr: 632687
171862306a36Sopenharmony_ci    syscw: 632675
171962306a36Sopenharmony_ci    read_bytes: 0
172062306a36Sopenharmony_ci    write_bytes: 323932160
172162306a36Sopenharmony_ci    cancelled_write_bytes: 0
172262306a36Sopenharmony_ci
172362306a36Sopenharmony_ci
172462306a36Sopenharmony_ciDescription
172562306a36Sopenharmony_ci~~~~~~~~~~~
172662306a36Sopenharmony_ci
172762306a36Sopenharmony_circhar
172862306a36Sopenharmony_ci^^^^^
172962306a36Sopenharmony_ci
173062306a36Sopenharmony_ciI/O counter: chars read
173162306a36Sopenharmony_ciThe number of bytes which this task has caused to be read from storage. This
173262306a36Sopenharmony_ciis simply the sum of bytes which this process passed to read() and pread().
173362306a36Sopenharmony_ciIt includes things like tty IO and it is unaffected by whether or not actual
173462306a36Sopenharmony_ciphysical disk IO was required (the read might have been satisfied from
173562306a36Sopenharmony_cipagecache).
173662306a36Sopenharmony_ci
173762306a36Sopenharmony_ci
173862306a36Sopenharmony_ciwchar
173962306a36Sopenharmony_ci^^^^^
174062306a36Sopenharmony_ci
174162306a36Sopenharmony_ciI/O counter: chars written
174262306a36Sopenharmony_ciThe number of bytes which this task has caused, or shall cause to be written
174362306a36Sopenharmony_cito disk. Similar caveats apply here as with rchar.
174462306a36Sopenharmony_ci
174562306a36Sopenharmony_ci
174662306a36Sopenharmony_cisyscr
174762306a36Sopenharmony_ci^^^^^
174862306a36Sopenharmony_ci
174962306a36Sopenharmony_ciI/O counter: read syscalls
175062306a36Sopenharmony_ciAttempt to count the number of read I/O operations, i.e. syscalls like read()
175162306a36Sopenharmony_ciand pread().
175262306a36Sopenharmony_ci
175362306a36Sopenharmony_ci
175462306a36Sopenharmony_cisyscw
175562306a36Sopenharmony_ci^^^^^
175662306a36Sopenharmony_ci
175762306a36Sopenharmony_ciI/O counter: write syscalls
175862306a36Sopenharmony_ciAttempt to count the number of write I/O operations, i.e. syscalls like
175962306a36Sopenharmony_ciwrite() and pwrite().
176062306a36Sopenharmony_ci
176162306a36Sopenharmony_ci
176262306a36Sopenharmony_ciread_bytes
176362306a36Sopenharmony_ci^^^^^^^^^^
176462306a36Sopenharmony_ci
176562306a36Sopenharmony_ciI/O counter: bytes read
176662306a36Sopenharmony_ciAttempt to count the number of bytes which this process really did cause to
176762306a36Sopenharmony_cibe fetched from the storage layer. Done at the submit_bio() level, so it is
176862306a36Sopenharmony_ciaccurate for block-backed filesystems. <please add status regarding NFS and
176962306a36Sopenharmony_ciCIFS at a later time>
177062306a36Sopenharmony_ci
177162306a36Sopenharmony_ci
177262306a36Sopenharmony_ciwrite_bytes
177362306a36Sopenharmony_ci^^^^^^^^^^^
177462306a36Sopenharmony_ci
177562306a36Sopenharmony_ciI/O counter: bytes written
177662306a36Sopenharmony_ciAttempt to count the number of bytes which this process caused to be sent to
177762306a36Sopenharmony_cithe storage layer. This is done at page-dirtying time.
177862306a36Sopenharmony_ci
177962306a36Sopenharmony_ci
178062306a36Sopenharmony_cicancelled_write_bytes
178162306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^^^^^
178262306a36Sopenharmony_ci
178362306a36Sopenharmony_ciThe big inaccuracy here is truncate. If a process writes 1MB to a file and
178462306a36Sopenharmony_cithen deletes the file, it will in fact perform no writeout. But it will have
178562306a36Sopenharmony_cibeen accounted as having caused 1MB of write.
178662306a36Sopenharmony_ciIn other words: The number of bytes which this process caused to not happen,
178762306a36Sopenharmony_ciby truncating pagecache. A task can cause "negative" IO too. If this task
178862306a36Sopenharmony_citruncates some dirty pagecache, some IO which another task has been accounted
178962306a36Sopenharmony_cifor (in its write_bytes) will not be happening. We _could_ just subtract that
179062306a36Sopenharmony_cifrom the truncating task's write_bytes, but there is information loss in doing
179162306a36Sopenharmony_cithat.
179262306a36Sopenharmony_ci
179362306a36Sopenharmony_ci
179462306a36Sopenharmony_ci.. Note::
179562306a36Sopenharmony_ci
179662306a36Sopenharmony_ci   At its current implementation state, this is a bit racy on 32-bit machines:
179762306a36Sopenharmony_ci   if process A reads process B's /proc/pid/io while process B is updating one
179862306a36Sopenharmony_ci   of those 64-bit counters, process A could see an intermediate result.
179962306a36Sopenharmony_ci
180062306a36Sopenharmony_ci
180162306a36Sopenharmony_ciMore information about this can be found within the taskstats documentation in
180262306a36Sopenharmony_ciDocumentation/accounting.
180362306a36Sopenharmony_ci
180462306a36Sopenharmony_ci3.4 /proc/<pid>/coredump_filter - Core dump filtering settings
180562306a36Sopenharmony_ci---------------------------------------------------------------
180662306a36Sopenharmony_ciWhen a process is dumped, all anonymous memory is written to a core file as
180762306a36Sopenharmony_cilong as the size of the core file isn't limited. But sometimes we don't want
180862306a36Sopenharmony_cito dump some memory segments, for example, huge shared memory or DAX.
180962306a36Sopenharmony_ciConversely, sometimes we want to save file-backed memory segments into a core
181062306a36Sopenharmony_cifile, not only the individual files.
181162306a36Sopenharmony_ci
181262306a36Sopenharmony_ci/proc/<pid>/coredump_filter allows you to customize which memory segments
181362306a36Sopenharmony_ciwill be dumped when the <pid> process is dumped. coredump_filter is a bitmask
181462306a36Sopenharmony_ciof memory types. If a bit of the bitmask is set, memory segments of the
181562306a36Sopenharmony_cicorresponding memory type are dumped, otherwise they are not dumped.
181662306a36Sopenharmony_ci
181762306a36Sopenharmony_ciThe following 9 memory types are supported:
181862306a36Sopenharmony_ci
181962306a36Sopenharmony_ci  - (bit 0) anonymous private memory
182062306a36Sopenharmony_ci  - (bit 1) anonymous shared memory
182162306a36Sopenharmony_ci  - (bit 2) file-backed private memory
182262306a36Sopenharmony_ci  - (bit 3) file-backed shared memory
182362306a36Sopenharmony_ci  - (bit 4) ELF header pages in file-backed private memory areas (it is
182462306a36Sopenharmony_ci    effective only if the bit 2 is cleared)
182562306a36Sopenharmony_ci  - (bit 5) hugetlb private memory
182662306a36Sopenharmony_ci  - (bit 6) hugetlb shared memory
182762306a36Sopenharmony_ci  - (bit 7) DAX private memory
182862306a36Sopenharmony_ci  - (bit 8) DAX shared memory
182962306a36Sopenharmony_ci
183062306a36Sopenharmony_ci  Note that MMIO pages such as frame buffer are never dumped and vDSO pages
183162306a36Sopenharmony_ci  are always dumped regardless of the bitmask status.
183262306a36Sopenharmony_ci
183362306a36Sopenharmony_ci  Note that bits 0-4 don't affect hugetlb or DAX memory. hugetlb memory is
183462306a36Sopenharmony_ci  only affected by bit 5-6, and DAX is only affected by bits 7-8.
183562306a36Sopenharmony_ci
183662306a36Sopenharmony_ciThe default value of coredump_filter is 0x33; this means all anonymous memory
183762306a36Sopenharmony_cisegments, ELF header pages and hugetlb private memory are dumped.
183862306a36Sopenharmony_ci
183962306a36Sopenharmony_ciIf you don't want to dump all shared memory segments attached to pid 1234,
184062306a36Sopenharmony_ciwrite 0x31 to the process's proc file::
184162306a36Sopenharmony_ci
184262306a36Sopenharmony_ci  $ echo 0x31 > /proc/1234/coredump_filter
184362306a36Sopenharmony_ci
184462306a36Sopenharmony_ciWhen a new process is created, the process inherits the bitmask status from its
184562306a36Sopenharmony_ciparent. It is useful to set up coredump_filter before the program runs.
184662306a36Sopenharmony_ciFor example::
184762306a36Sopenharmony_ci
184862306a36Sopenharmony_ci  $ echo 0x7 > /proc/self/coredump_filter
184962306a36Sopenharmony_ci  $ ./some_program
185062306a36Sopenharmony_ci
185162306a36Sopenharmony_ci3.5	/proc/<pid>/mountinfo - Information about mounts
185262306a36Sopenharmony_ci--------------------------------------------------------
185362306a36Sopenharmony_ci
185462306a36Sopenharmony_ciThis file contains lines of the form::
185562306a36Sopenharmony_ci
185662306a36Sopenharmony_ci    36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue
185762306a36Sopenharmony_ci    (1)(2)(3)   (4)   (5)      (6)     (n…m) (m+1)(m+2) (m+3)         (m+4)
185862306a36Sopenharmony_ci
185962306a36Sopenharmony_ci    (1)   mount ID:        unique identifier of the mount (may be reused after umount)
186062306a36Sopenharmony_ci    (2)   parent ID:       ID of parent (or of self for the top of the mount tree)
186162306a36Sopenharmony_ci    (3)   major:minor:     value of st_dev for files on filesystem
186262306a36Sopenharmony_ci    (4)   root:            root of the mount within the filesystem
186362306a36Sopenharmony_ci    (5)   mount point:     mount point relative to the process's root
186462306a36Sopenharmony_ci    (6)   mount options:   per mount options
186562306a36Sopenharmony_ci    (n…m) optional fields: zero or more fields of the form "tag[:value]"
186662306a36Sopenharmony_ci    (m+1) separator:       marks the end of the optional fields
186762306a36Sopenharmony_ci    (m+2) filesystem type: name of filesystem of the form "type[.subtype]"
186862306a36Sopenharmony_ci    (m+3) mount source:    filesystem specific information or "none"
186962306a36Sopenharmony_ci    (m+4) super options:   per super block options
187062306a36Sopenharmony_ci
187162306a36Sopenharmony_ciParsers should ignore all unrecognised optional fields.  Currently the
187262306a36Sopenharmony_cipossible optional fields are:
187362306a36Sopenharmony_ci
187462306a36Sopenharmony_ci================  ==============================================================
187562306a36Sopenharmony_cishared:X          mount is shared in peer group X
187662306a36Sopenharmony_cimaster:X          mount is slave to peer group X
187762306a36Sopenharmony_cipropagate_from:X  mount is slave and receives propagation from peer group X [#]_
187862306a36Sopenharmony_ciunbindable        mount is unbindable
187962306a36Sopenharmony_ci================  ==============================================================
188062306a36Sopenharmony_ci
188162306a36Sopenharmony_ci.. [#] X is the closest dominant peer group under the process's root.  If
188262306a36Sopenharmony_ci       X is the immediate master of the mount, or if there's no dominant peer
188362306a36Sopenharmony_ci       group under the same root, then only the "master:X" field is present
188462306a36Sopenharmony_ci       and not the "propagate_from:X" field.
188562306a36Sopenharmony_ci
188662306a36Sopenharmony_ciFor more information on mount propagation see:
188762306a36Sopenharmony_ci
188862306a36Sopenharmony_ci  Documentation/filesystems/sharedsubtree.rst
188962306a36Sopenharmony_ci
189062306a36Sopenharmony_ci
189162306a36Sopenharmony_ci3.6	/proc/<pid>/comm  & /proc/<pid>/task/<tid>/comm
189262306a36Sopenharmony_ci--------------------------------------------------------
189362306a36Sopenharmony_ciThese files provide a method to access a task's comm value. It also allows for
189462306a36Sopenharmony_cia task to set its own or one of its thread siblings comm value. The comm value
189562306a36Sopenharmony_ciis limited in size compared to the cmdline value, so writing anything longer
189662306a36Sopenharmony_cithen the kernel's TASK_COMM_LEN (currently 16 chars) will result in a truncated
189762306a36Sopenharmony_cicomm value.
189862306a36Sopenharmony_ci
189962306a36Sopenharmony_ci
190062306a36Sopenharmony_ci3.7	/proc/<pid>/task/<tid>/children - Information about task children
190162306a36Sopenharmony_ci-------------------------------------------------------------------------
190262306a36Sopenharmony_ciThis file provides a fast way to retrieve first level children pids
190362306a36Sopenharmony_ciof a task pointed by <pid>/<tid> pair. The format is a space separated
190462306a36Sopenharmony_cistream of pids.
190562306a36Sopenharmony_ci
190662306a36Sopenharmony_ciNote the "first level" here -- if a child has its own children they will
190762306a36Sopenharmony_cinot be listed here; one needs to read /proc/<children-pid>/task/<tid>/children
190862306a36Sopenharmony_cito obtain the descendants.
190962306a36Sopenharmony_ci
191062306a36Sopenharmony_ciSince this interface is intended to be fast and cheap it doesn't
191162306a36Sopenharmony_ciguarantee to provide precise results and some children might be
191262306a36Sopenharmony_ciskipped, especially if they've exited right after we printed their
191362306a36Sopenharmony_cipids, so one needs to either stop or freeze processes being inspected
191462306a36Sopenharmony_ciif precise results are needed.
191562306a36Sopenharmony_ci
191662306a36Sopenharmony_ci
191762306a36Sopenharmony_ci3.8	/proc/<pid>/fdinfo/<fd> - Information about opened file
191862306a36Sopenharmony_ci---------------------------------------------------------------
191962306a36Sopenharmony_ciThis file provides information associated with an opened file. The regular
192062306a36Sopenharmony_cifiles have at least four fields -- 'pos', 'flags', 'mnt_id' and 'ino'.
192162306a36Sopenharmony_ciThe 'pos' represents the current offset of the opened file in decimal
192262306a36Sopenharmony_ciform [see lseek(2) for details], 'flags' denotes the octal O_xxx mask the
192362306a36Sopenharmony_cifile has been created with [see open(2) for details] and 'mnt_id' represents
192462306a36Sopenharmony_cimount ID of the file system containing the opened file [see 3.5
192562306a36Sopenharmony_ci/proc/<pid>/mountinfo for details]. 'ino' represents the inode number of
192662306a36Sopenharmony_cithe file.
192762306a36Sopenharmony_ci
192862306a36Sopenharmony_ciA typical output is::
192962306a36Sopenharmony_ci
193062306a36Sopenharmony_ci	pos:	0
193162306a36Sopenharmony_ci	flags:	0100002
193262306a36Sopenharmony_ci	mnt_id:	19
193362306a36Sopenharmony_ci	ino:	63107
193462306a36Sopenharmony_ci
193562306a36Sopenharmony_ciAll locks associated with a file descriptor are shown in its fdinfo too::
193662306a36Sopenharmony_ci
193762306a36Sopenharmony_ci    lock:       1: FLOCK  ADVISORY  WRITE 359 00:13:11691 0 EOF
193862306a36Sopenharmony_ci
193962306a36Sopenharmony_ciThe files such as eventfd, fsnotify, signalfd, epoll among the regular pos/flags
194062306a36Sopenharmony_cipair provide additional information particular to the objects they represent.
194162306a36Sopenharmony_ci
194262306a36Sopenharmony_ciEventfd files
194362306a36Sopenharmony_ci~~~~~~~~~~~~~
194462306a36Sopenharmony_ci
194562306a36Sopenharmony_ci::
194662306a36Sopenharmony_ci
194762306a36Sopenharmony_ci	pos:	0
194862306a36Sopenharmony_ci	flags:	04002
194962306a36Sopenharmony_ci	mnt_id:	9
195062306a36Sopenharmony_ci	ino:	63107
195162306a36Sopenharmony_ci	eventfd-count:	5a
195262306a36Sopenharmony_ci
195362306a36Sopenharmony_ciwhere 'eventfd-count' is hex value of a counter.
195462306a36Sopenharmony_ci
195562306a36Sopenharmony_ciSignalfd files
195662306a36Sopenharmony_ci~~~~~~~~~~~~~~
195762306a36Sopenharmony_ci
195862306a36Sopenharmony_ci::
195962306a36Sopenharmony_ci
196062306a36Sopenharmony_ci	pos:	0
196162306a36Sopenharmony_ci	flags:	04002
196262306a36Sopenharmony_ci	mnt_id:	9
196362306a36Sopenharmony_ci	ino:	63107
196462306a36Sopenharmony_ci	sigmask:	0000000000000200
196562306a36Sopenharmony_ci
196662306a36Sopenharmony_ciwhere 'sigmask' is hex value of the signal mask associated
196762306a36Sopenharmony_ciwith a file.
196862306a36Sopenharmony_ci
196962306a36Sopenharmony_ciEpoll files
197062306a36Sopenharmony_ci~~~~~~~~~~~
197162306a36Sopenharmony_ci
197262306a36Sopenharmony_ci::
197362306a36Sopenharmony_ci
197462306a36Sopenharmony_ci	pos:	0
197562306a36Sopenharmony_ci	flags:	02
197662306a36Sopenharmony_ci	mnt_id:	9
197762306a36Sopenharmony_ci	ino:	63107
197862306a36Sopenharmony_ci	tfd:        5 events:       1d data: ffffffffffffffff pos:0 ino:61af sdev:7
197962306a36Sopenharmony_ci
198062306a36Sopenharmony_ciwhere 'tfd' is a target file descriptor number in decimal form,
198162306a36Sopenharmony_ci'events' is events mask being watched and the 'data' is data
198262306a36Sopenharmony_ciassociated with a target [see epoll(7) for more details].
198362306a36Sopenharmony_ci
198462306a36Sopenharmony_ciThe 'pos' is current offset of the target file in decimal form
198562306a36Sopenharmony_ci[see lseek(2)], 'ino' and 'sdev' are inode and device numbers
198662306a36Sopenharmony_ciwhere target file resides, all in hex format.
198762306a36Sopenharmony_ci
198862306a36Sopenharmony_ciFsnotify files
198962306a36Sopenharmony_ci~~~~~~~~~~~~~~
199062306a36Sopenharmony_ciFor inotify files the format is the following::
199162306a36Sopenharmony_ci
199262306a36Sopenharmony_ci	pos:	0
199362306a36Sopenharmony_ci	flags:	02000000
199462306a36Sopenharmony_ci	mnt_id:	9
199562306a36Sopenharmony_ci	ino:	63107
199662306a36Sopenharmony_ci	inotify wd:3 ino:9e7e sdev:800013 mask:800afce ignored_mask:0 fhandle-bytes:8 fhandle-type:1 f_handle:7e9e0000640d1b6d
199762306a36Sopenharmony_ci
199862306a36Sopenharmony_ciwhere 'wd' is a watch descriptor in decimal form, i.e. a target file
199962306a36Sopenharmony_cidescriptor number, 'ino' and 'sdev' are inode and device where the
200062306a36Sopenharmony_citarget file resides and the 'mask' is the mask of events, all in hex
200162306a36Sopenharmony_ciform [see inotify(7) for more details].
200262306a36Sopenharmony_ci
200362306a36Sopenharmony_ciIf the kernel was built with exportfs support, the path to the target
200462306a36Sopenharmony_cifile is encoded as a file handle.  The file handle is provided by three
200562306a36Sopenharmony_cifields 'fhandle-bytes', 'fhandle-type' and 'f_handle', all in hex
200662306a36Sopenharmony_ciformat.
200762306a36Sopenharmony_ci
200862306a36Sopenharmony_ciIf the kernel is built without exportfs support the file handle won't be
200962306a36Sopenharmony_ciprinted out.
201062306a36Sopenharmony_ci
201162306a36Sopenharmony_ciIf there is no inotify mark attached yet the 'inotify' line will be omitted.
201262306a36Sopenharmony_ci
201362306a36Sopenharmony_ciFor fanotify files the format is::
201462306a36Sopenharmony_ci
201562306a36Sopenharmony_ci	pos:	0
201662306a36Sopenharmony_ci	flags:	02
201762306a36Sopenharmony_ci	mnt_id:	9
201862306a36Sopenharmony_ci	ino:	63107
201962306a36Sopenharmony_ci	fanotify flags:10 event-flags:0
202062306a36Sopenharmony_ci	fanotify mnt_id:12 mflags:40 mask:38 ignored_mask:40000003
202162306a36Sopenharmony_ci	fanotify ino:4f969 sdev:800013 mflags:0 mask:3b ignored_mask:40000000 fhandle-bytes:8 fhandle-type:1 f_handle:69f90400c275b5b4
202262306a36Sopenharmony_ci
202362306a36Sopenharmony_ciwhere fanotify 'flags' and 'event-flags' are values used in fanotify_init
202462306a36Sopenharmony_cicall, 'mnt_id' is the mount point identifier, 'mflags' is the value of
202562306a36Sopenharmony_ciflags associated with mark which are tracked separately from events
202662306a36Sopenharmony_cimask. 'ino' and 'sdev' are target inode and device, 'mask' is the events
202762306a36Sopenharmony_cimask and 'ignored_mask' is the mask of events which are to be ignored.
202862306a36Sopenharmony_ciAll are in hex format. Incorporation of 'mflags', 'mask' and 'ignored_mask'
202962306a36Sopenharmony_ciprovide information about flags and mask used in fanotify_mark
203062306a36Sopenharmony_cicall [see fsnotify manpage for details].
203162306a36Sopenharmony_ci
203262306a36Sopenharmony_ciWhile the first three lines are mandatory and always printed, the rest is
203362306a36Sopenharmony_cioptional and may be omitted if no marks created yet.
203462306a36Sopenharmony_ci
203562306a36Sopenharmony_ciTimerfd files
203662306a36Sopenharmony_ci~~~~~~~~~~~~~
203762306a36Sopenharmony_ci
203862306a36Sopenharmony_ci::
203962306a36Sopenharmony_ci
204062306a36Sopenharmony_ci	pos:	0
204162306a36Sopenharmony_ci	flags:	02
204262306a36Sopenharmony_ci	mnt_id:	9
204362306a36Sopenharmony_ci	ino:	63107
204462306a36Sopenharmony_ci	clockid: 0
204562306a36Sopenharmony_ci	ticks: 0
204662306a36Sopenharmony_ci	settime flags: 01
204762306a36Sopenharmony_ci	it_value: (0, 49406829)
204862306a36Sopenharmony_ci	it_interval: (1, 0)
204962306a36Sopenharmony_ci
205062306a36Sopenharmony_ciwhere 'clockid' is the clock type and 'ticks' is the number of the timer expirations
205162306a36Sopenharmony_cithat have occurred [see timerfd_create(2) for details]. 'settime flags' are
205262306a36Sopenharmony_ciflags in octal form been used to setup the timer [see timerfd_settime(2) for
205362306a36Sopenharmony_cidetails]. 'it_value' is remaining time until the timer expiration.
205462306a36Sopenharmony_ci'it_interval' is the interval for the timer. Note the timer might be set up
205562306a36Sopenharmony_ciwith TIMER_ABSTIME option which will be shown in 'settime flags', but 'it_value'
205662306a36Sopenharmony_cistill exhibits timer's remaining time.
205762306a36Sopenharmony_ci
205862306a36Sopenharmony_ciDMA Buffer files
205962306a36Sopenharmony_ci~~~~~~~~~~~~~~~~
206062306a36Sopenharmony_ci
206162306a36Sopenharmony_ci::
206262306a36Sopenharmony_ci
206362306a36Sopenharmony_ci	pos:	0
206462306a36Sopenharmony_ci	flags:	04002
206562306a36Sopenharmony_ci	mnt_id:	9
206662306a36Sopenharmony_ci	ino:	63107
206762306a36Sopenharmony_ci	size:   32768
206862306a36Sopenharmony_ci	count:  2
206962306a36Sopenharmony_ci	exp_name:  system-heap
207062306a36Sopenharmony_ci
207162306a36Sopenharmony_ciwhere 'size' is the size of the DMA buffer in bytes. 'count' is the file count of
207262306a36Sopenharmony_cithe DMA buffer file. 'exp_name' is the name of the DMA buffer exporter.
207362306a36Sopenharmony_ci
207462306a36Sopenharmony_ci3.9	/proc/<pid>/map_files - Information about memory mapped files
207562306a36Sopenharmony_ci---------------------------------------------------------------------
207662306a36Sopenharmony_ciThis directory contains symbolic links which represent memory mapped files
207762306a36Sopenharmony_cithe process is maintaining.  Example output::
207862306a36Sopenharmony_ci
207962306a36Sopenharmony_ci     | lr-------- 1 root root 64 Jan 27 11:24 333c600000-333c620000 -> /usr/lib64/ld-2.18.so
208062306a36Sopenharmony_ci     | lr-------- 1 root root 64 Jan 27 11:24 333c81f000-333c820000 -> /usr/lib64/ld-2.18.so
208162306a36Sopenharmony_ci     | lr-------- 1 root root 64 Jan 27 11:24 333c820000-333c821000 -> /usr/lib64/ld-2.18.so
208262306a36Sopenharmony_ci     | ...
208362306a36Sopenharmony_ci     | lr-------- 1 root root 64 Jan 27 11:24 35d0421000-35d0422000 -> /usr/lib64/libselinux.so.1
208462306a36Sopenharmony_ci     | lr-------- 1 root root 64 Jan 27 11:24 400000-41a000 -> /usr/bin/ls
208562306a36Sopenharmony_ci
208662306a36Sopenharmony_ciThe name of a link represents the virtual memory bounds of a mapping, i.e.
208762306a36Sopenharmony_civm_area_struct::vm_start-vm_area_struct::vm_end.
208862306a36Sopenharmony_ci
208962306a36Sopenharmony_ciThe main purpose of the map_files is to retrieve a set of memory mapped
209062306a36Sopenharmony_cifiles in a fast way instead of parsing /proc/<pid>/maps or
209162306a36Sopenharmony_ci/proc/<pid>/smaps, both of which contain many more records.  At the same
209262306a36Sopenharmony_citime one can open(2) mappings from the listings of two processes and
209362306a36Sopenharmony_cicomparing their inode numbers to figure out which anonymous memory areas
209462306a36Sopenharmony_ciare actually shared.
209562306a36Sopenharmony_ci
209662306a36Sopenharmony_ci3.10	/proc/<pid>/timerslack_ns - Task timerslack value
209762306a36Sopenharmony_ci---------------------------------------------------------
209862306a36Sopenharmony_ciThis file provides the value of the task's timerslack value in nanoseconds.
209962306a36Sopenharmony_ciThis value specifies an amount of time that normal timers may be deferred
210062306a36Sopenharmony_ciin order to coalesce timers and avoid unnecessary wakeups.
210162306a36Sopenharmony_ci
210262306a36Sopenharmony_ciThis allows a task's interactivity vs power consumption tradeoff to be
210362306a36Sopenharmony_ciadjusted.
210462306a36Sopenharmony_ci
210562306a36Sopenharmony_ciWriting 0 to the file will set the task's timerslack to the default value.
210662306a36Sopenharmony_ci
210762306a36Sopenharmony_ciValid values are from 0 - ULLONG_MAX
210862306a36Sopenharmony_ci
210962306a36Sopenharmony_ciAn application setting the value must have PTRACE_MODE_ATTACH_FSCREDS level
211062306a36Sopenharmony_cipermissions on the task specified to change its timerslack_ns value.
211162306a36Sopenharmony_ci
211262306a36Sopenharmony_ci3.11	/proc/<pid>/patch_state - Livepatch patch operation state
211362306a36Sopenharmony_ci-----------------------------------------------------------------
211462306a36Sopenharmony_ciWhen CONFIG_LIVEPATCH is enabled, this file displays the value of the
211562306a36Sopenharmony_cipatch state for the task.
211662306a36Sopenharmony_ci
211762306a36Sopenharmony_ciA value of '-1' indicates that no patch is in transition.
211862306a36Sopenharmony_ci
211962306a36Sopenharmony_ciA value of '0' indicates that a patch is in transition and the task is
212062306a36Sopenharmony_ciunpatched.  If the patch is being enabled, then the task hasn't been
212162306a36Sopenharmony_cipatched yet.  If the patch is being disabled, then the task has already
212262306a36Sopenharmony_cibeen unpatched.
212362306a36Sopenharmony_ci
212462306a36Sopenharmony_ciA value of '1' indicates that a patch is in transition and the task is
212562306a36Sopenharmony_cipatched.  If the patch is being enabled, then the task has already been
212662306a36Sopenharmony_cipatched.  If the patch is being disabled, then the task hasn't been
212762306a36Sopenharmony_ciunpatched yet.
212862306a36Sopenharmony_ci
212962306a36Sopenharmony_ci3.12 /proc/<pid>/arch_status - task architecture specific status
213062306a36Sopenharmony_ci-------------------------------------------------------------------
213162306a36Sopenharmony_ciWhen CONFIG_PROC_PID_ARCH_STATUS is enabled, this file displays the
213262306a36Sopenharmony_ciarchitecture specific status of the task.
213362306a36Sopenharmony_ci
213462306a36Sopenharmony_ciExample
213562306a36Sopenharmony_ci~~~~~~~
213662306a36Sopenharmony_ci
213762306a36Sopenharmony_ci::
213862306a36Sopenharmony_ci
213962306a36Sopenharmony_ci $ cat /proc/6753/arch_status
214062306a36Sopenharmony_ci AVX512_elapsed_ms:      8
214162306a36Sopenharmony_ci
214262306a36Sopenharmony_ciDescription
214362306a36Sopenharmony_ci~~~~~~~~~~~
214462306a36Sopenharmony_ci
214562306a36Sopenharmony_cix86 specific entries
214662306a36Sopenharmony_ci~~~~~~~~~~~~~~~~~~~~~
214762306a36Sopenharmony_ci
214862306a36Sopenharmony_ciAVX512_elapsed_ms
214962306a36Sopenharmony_ci^^^^^^^^^^^^^^^^^^
215062306a36Sopenharmony_ci
215162306a36Sopenharmony_ci  If AVX512 is supported on the machine, this entry shows the milliseconds
215262306a36Sopenharmony_ci  elapsed since the last time AVX512 usage was recorded. The recording
215362306a36Sopenharmony_ci  happens on a best effort basis when a task is scheduled out. This means
215462306a36Sopenharmony_ci  that the value depends on two factors:
215562306a36Sopenharmony_ci
215662306a36Sopenharmony_ci    1) The time which the task spent on the CPU without being scheduled
215762306a36Sopenharmony_ci       out. With CPU isolation and a single runnable task this can take
215862306a36Sopenharmony_ci       several seconds.
215962306a36Sopenharmony_ci
216062306a36Sopenharmony_ci    2) The time since the task was scheduled out last. Depending on the
216162306a36Sopenharmony_ci       reason for being scheduled out (time slice exhausted, syscall ...)
216262306a36Sopenharmony_ci       this can be arbitrary long time.
216362306a36Sopenharmony_ci
216462306a36Sopenharmony_ci  As a consequence the value cannot be considered precise and authoritative
216562306a36Sopenharmony_ci  information. The application which uses this information has to be aware
216662306a36Sopenharmony_ci  of the overall scenario on the system in order to determine whether a
216762306a36Sopenharmony_ci  task is a real AVX512 user or not. Precise information can be obtained
216862306a36Sopenharmony_ci  with performance counters.
216962306a36Sopenharmony_ci
217062306a36Sopenharmony_ci  A special value of '-1' indicates that no AVX512 usage was recorded, thus
217162306a36Sopenharmony_ci  the task is unlikely an AVX512 user, but depends on the workload and the
217262306a36Sopenharmony_ci  scheduling scenario, it also could be a false negative mentioned above.
217362306a36Sopenharmony_ci
217462306a36Sopenharmony_ci3.13 /proc/<pid>/fd - List of symlinks to open files
217562306a36Sopenharmony_ci-------------------------------------------------------
217662306a36Sopenharmony_ciThis directory contains symbolic links which represent open files
217762306a36Sopenharmony_cithe process is maintaining.  Example output::
217862306a36Sopenharmony_ci
217962306a36Sopenharmony_ci  lr-x------ 1 root root 64 Sep 20 17:53 0 -> /dev/null
218062306a36Sopenharmony_ci  l-wx------ 1 root root 64 Sep 20 17:53 1 -> /dev/null
218162306a36Sopenharmony_ci  lrwx------ 1 root root 64 Sep 20 17:53 10 -> 'socket:[12539]'
218262306a36Sopenharmony_ci  lrwx------ 1 root root 64 Sep 20 17:53 11 -> 'socket:[12540]'
218362306a36Sopenharmony_ci  lrwx------ 1 root root 64 Sep 20 17:53 12 -> 'socket:[12542]'
218462306a36Sopenharmony_ci
218562306a36Sopenharmony_ciThe number of open files for the process is stored in 'size' member
218662306a36Sopenharmony_ciof stat() output for /proc/<pid>/fd for fast access.
218762306a36Sopenharmony_ci-------------------------------------------------------
218862306a36Sopenharmony_ci
218962306a36Sopenharmony_ci
219062306a36Sopenharmony_ciChapter 4: Configuring procfs
219162306a36Sopenharmony_ci=============================
219262306a36Sopenharmony_ci
219362306a36Sopenharmony_ci4.1	Mount options
219462306a36Sopenharmony_ci---------------------
219562306a36Sopenharmony_ci
219662306a36Sopenharmony_ciThe following mount options are supported:
219762306a36Sopenharmony_ci
219862306a36Sopenharmony_ci	=========	========================================================
219962306a36Sopenharmony_ci	hidepid=	Set /proc/<pid>/ access mode.
220062306a36Sopenharmony_ci	gid=		Set the group authorized to learn processes information.
220162306a36Sopenharmony_ci	subset=		Show only the specified subset of procfs.
220262306a36Sopenharmony_ci	=========	========================================================
220362306a36Sopenharmony_ci
220462306a36Sopenharmony_cihidepid=off or hidepid=0 means classic mode - everybody may access all
220562306a36Sopenharmony_ci/proc/<pid>/ directories (default).
220662306a36Sopenharmony_ci
220762306a36Sopenharmony_cihidepid=noaccess or hidepid=1 means users may not access any /proc/<pid>/
220862306a36Sopenharmony_cidirectories but their own.  Sensitive files like cmdline, sched*, status are now
220962306a36Sopenharmony_ciprotected against other users.  This makes it impossible to learn whether any
221062306a36Sopenharmony_ciuser runs specific program (given the program doesn't reveal itself by its
221162306a36Sopenharmony_cibehaviour).  As an additional bonus, as /proc/<pid>/cmdline is unaccessible for
221262306a36Sopenharmony_ciother users, poorly written programs passing sensitive information via program
221362306a36Sopenharmony_ciarguments are now protected against local eavesdroppers.
221462306a36Sopenharmony_ci
221562306a36Sopenharmony_cihidepid=invisible or hidepid=2 means hidepid=1 plus all /proc/<pid>/ will be
221662306a36Sopenharmony_cifully invisible to other users.  It doesn't mean that it hides a fact whether a
221762306a36Sopenharmony_ciprocess with a specific pid value exists (it can be learned by other means, e.g.
221862306a36Sopenharmony_ciby "kill -0 $PID"), but it hides process' uid and gid, which may be learned by
221962306a36Sopenharmony_cistat()'ing /proc/<pid>/ otherwise.  It greatly complicates an intruder's task of
222062306a36Sopenharmony_cigathering information about running processes, whether some daemon runs with
222162306a36Sopenharmony_cielevated privileges, whether other user runs some sensitive program, whether
222262306a36Sopenharmony_ciother users run any program at all, etc.
222362306a36Sopenharmony_ci
222462306a36Sopenharmony_cihidepid=ptraceable or hidepid=4 means that procfs should only contain
222562306a36Sopenharmony_ci/proc/<pid>/ directories that the caller can ptrace.
222662306a36Sopenharmony_ci
222762306a36Sopenharmony_cigid= defines a group authorized to learn processes information otherwise
222862306a36Sopenharmony_ciprohibited by hidepid=.  If you use some daemon like identd which needs to learn
222962306a36Sopenharmony_ciinformation about processes information, just add identd to this group.
223062306a36Sopenharmony_ci
223162306a36Sopenharmony_cisubset=pid hides all top level files and directories in the procfs that
223262306a36Sopenharmony_ciare not related to tasks.
223362306a36Sopenharmony_ci
223462306a36Sopenharmony_ciChapter 5: Filesystem behavior
223562306a36Sopenharmony_ci==============================
223662306a36Sopenharmony_ci
223762306a36Sopenharmony_ciOriginally, before the advent of pid namespace, procfs was a global file
223862306a36Sopenharmony_cisystem. It means that there was only one procfs instance in the system.
223962306a36Sopenharmony_ci
224062306a36Sopenharmony_ciWhen pid namespace was added, a separate procfs instance was mounted in
224162306a36Sopenharmony_cieach pid namespace. So, procfs mount options are global among all
224262306a36Sopenharmony_cimountpoints within the same namespace::
224362306a36Sopenharmony_ci
224462306a36Sopenharmony_ci	# grep ^proc /proc/mounts
224562306a36Sopenharmony_ci	proc /proc proc rw,relatime,hidepid=2 0 0
224662306a36Sopenharmony_ci
224762306a36Sopenharmony_ci	# strace -e mount mount -o hidepid=1 -t proc proc /tmp/proc
224862306a36Sopenharmony_ci	mount("proc", "/tmp/proc", "proc", 0, "hidepid=1") = 0
224962306a36Sopenharmony_ci	+++ exited with 0 +++
225062306a36Sopenharmony_ci
225162306a36Sopenharmony_ci	# grep ^proc /proc/mounts
225262306a36Sopenharmony_ci	proc /proc proc rw,relatime,hidepid=2 0 0
225362306a36Sopenharmony_ci	proc /tmp/proc proc rw,relatime,hidepid=2 0 0
225462306a36Sopenharmony_ci
225562306a36Sopenharmony_ciand only after remounting procfs mount options will change at all
225662306a36Sopenharmony_cimountpoints::
225762306a36Sopenharmony_ci
225862306a36Sopenharmony_ci	# mount -o remount,hidepid=1 -t proc proc /tmp/proc
225962306a36Sopenharmony_ci
226062306a36Sopenharmony_ci	# grep ^proc /proc/mounts
226162306a36Sopenharmony_ci	proc /proc proc rw,relatime,hidepid=1 0 0
226262306a36Sopenharmony_ci	proc /tmp/proc proc rw,relatime,hidepid=1 0 0
226362306a36Sopenharmony_ci
226462306a36Sopenharmony_ciThis behavior is different from the behavior of other filesystems.
226562306a36Sopenharmony_ci
226662306a36Sopenharmony_ciThe new procfs behavior is more like other filesystems. Each procfs mount
226762306a36Sopenharmony_cicreates a new procfs instance. Mount options affect own procfs instance.
226862306a36Sopenharmony_ciIt means that it became possible to have several procfs instances
226962306a36Sopenharmony_cidisplaying tasks with different filtering options in one pid namespace::
227062306a36Sopenharmony_ci
227162306a36Sopenharmony_ci	# mount -o hidepid=invisible -t proc proc /proc
227262306a36Sopenharmony_ci	# mount -o hidepid=noaccess -t proc proc /tmp/proc
227362306a36Sopenharmony_ci	# grep ^proc /proc/mounts
227462306a36Sopenharmony_ci	proc /proc proc rw,relatime,hidepid=invisible 0 0
227562306a36Sopenharmony_ci	proc /tmp/proc proc rw,relatime,hidepid=noaccess 0 0
2276