Linux Kernel /proc

最後更新: 2016-05-13

 


/proc 頂層

 

/proc/devices

This file displays the various character and block devices currently configured

/proc/fb

This file contains a list of frame buffer devices

/proc/kmsg

This file is used to hold messages generated by the kernel.
These messages are then picked up by other programs, such as /sbin/klogd or /bin/dmesg.

/proc/kcore

This file represents the physical memory of the system and is stored in the core file format.
The contents of this file are designed to be examined by a debugger, such as gdb, and is not human readable.

/proc/iomem

This file shows you the current map of the system's memory for each physical device:

/proc/ioports

provides a list of currently registered port regions used for input or output communication with a device.

/proc/interrupts

This file records the number of interrupts per IRQ on the x86 architecture.

IO-APIC-edge — The voltage signal on this interrupt transitions from low to high (only signaled once)
IO-APIC-level — Generates interrupts when its voltage signal is high until the signal is low again.


Memory(/proc/sys/vm)

 

drop_caches

Writing to this will cause the kernel to drop clean caches, dentries and inodes from memory,

causing that memory to become free.

To free pagecache:

    echo 1 > /proc/sys/vm/drop_caches

To free dentries and inodes:

    echo 2 > /proc/sys/vm/drop_caches

To free pagecache, dentries and inodes:

    echo 3 > /proc/sys/vm/drop_caches

As this is a non-destructive operation and dirty objects are not freeable, the user should run "sync" first.

free -m

             total       used       free     shared    buffers     cached
Mem:          3291       1118       2172          0          0        973
-/+ buffers/cache:        144       3146
Swap:         1906          0       1906

echo 1 > /proc/sys/vm/drop_caches

VZserver:#free -m
             total       used       free     shared    buffers     cached
Mem:          3291        198       3093          0          0         47
-/+ buffers/cache:        150       3140
Swap:         1906          0       1906

 


/proc/[pid]/stat

 

Status information about the process.  This is used by ps

 

(1) pid  %d

(2) comm  %s

(3) state  %c

R  Running
S  Sleeping in an interruptible wait
Z  Zombie
...

(4) ppid  %d                        The PID of the parent of this process

(18) priority

(Explanation for Linux 2.6) For processes running a real-time scheduling policy
(policy below; see sched_setscheduler(2)), this is the negated scheduling priority,

minus one; that is, a number in the range -2 to -100, corresponding to real-time priorities 1 to 99. 

For processes running under a non-real-time scheduling policy, this is the raw nice value (setpriority(2)) as represented in the kernel.
The kernel stores nice values as numbers in the range 0 (high) to 39 (low), corresponding to the user-visible nice range of -20 to 19.

(35) wchan

This is the "channel" in which the process is waiting

hrtimer(High Resolution Timer)

(40) rt_priority

Real-time scheduling priority,

a number in the range 1 to 99 for processes scheduled under a real-time policy, or

0, for non-real-time processes

(41) policy

Scheduling policy (see sched_setscheduler(2)).

Decode using the SCHED_* constants in linux/sched.h.

ps -o cls -p PID

  • RR  SCHED_RR
  • TS  SCHED_OTHER
  • ...

 


 

 

 

 

 

 

 

 

 

Creative Commons license icon Creative Commons license icon