📄 proc.txt
字号:
------------------------------------------------------------------------------ T H E /proc F I L E S Y S T E M------------------------------------------------------------------------------/proc/sys Terrehon Bowden <terrehon@pacbell.net> October 7 1999 Bodo Bauer <bb@ricochet.net>2.4.x update Jorge Nerin <comandante@zaralinux.com> November 14 2000------------------------------------------------------------------------------Version 1.3 Kernel version 2.2.12 Kernel version 2.4.0-test11-pre4------------------------------------------------------------------------------Table of Contents----------------- 0 Preface 0.1 Introduction/Credits 0.2 Legal Stuff 1 Collecting System Information 1.1 Process-Specific Subdirectories 1.2 Kernel data 1.3 IDE devices in /proc/ide 1.4 Networking info in /proc/net 1.5 SCSI info 1.6 Parallel port info in /proc/parport 1.7 TTY info in /proc/tty 2 Modifying System Parameters 2.1 /proc/sys/fs - File system data 2.2 /proc/sys/fs/binfmt_misc - Miscellaneous binary formats 2.3 /proc/sys/kernel - general kernel parameters 2.4 /proc/sys/vm - The virtual memory subsystem 2.5 /proc/sys/dev - Device specific parameters 2.6 /proc/sys/sunrpc - Remote procedure calls 2.7 /proc/sys/net - Networking stuff 2.8 /proc/sys/net/ipv4 - IPV4 settings 2.9 Appletalk 2.10 IPX------------------------------------------------------------------------------Preface------------------------------------------------------------------------------0.1 Introduction/Credits------------------------This documentation is part of a soon (or so we hope) to be released book onthe SuSE Linux distribution. As there is no complete documentation for the/proc file system and we've used many freely available sources to write thesechapters, it seems only fair to give the work back to the Linux community.This work is based on the 2.2.* kernel version and the upcoming 2.4.*. I'mafraid it's still far from complete, but we hope it will be useful. As far aswe know, it is the first 'all-in-one' document about the /proc file system. Itis focused on the Intel x86 hardware, so if you are looking for PPC, ARM,SPARC, APX, etc., features, you probably won't find what you are looking for.It also only covers IPv4 networking, not IPv6 nor other protocols - sorry. Butadditions and patches are welcome and will be added to this document if youmail them to Bodo.We'd like to thank Alan Cox, Rik van Riel, and Alexey Kuznetsov and a lot ofother people for help compiling this documentation. We'd also like to extend aspecial thank you to Andi Kleen for documentation, which we relied on heavilyto create this document, as well as the additional information he provided.Thanks to everybody else who contributed source or docs to the Linux kerneland helped create a great piece of software... :)If you have any comments, corrections or additions, please don't hesitate tocontact Bodo Bauer at bb@ricochet.net. We'll be happy to add them to thisdocument.The latest version of this document is available online athttp://skaro.nightcrawler.com/~bb/Docs/Proc as HTML version.If the above direction does not works for you, ypu could try the kernelmailing list at linux-kernel@vger.kernel.org and/or try to reach me atcomandante@zaralinux.com.0.2 Legal Stuff---------------We don't guarantee the correctness of this document, and if you come to uscomplaining about how you screwed up your system because of incorrectdocumentation, we won't feel responsible...------------------------------------------------------------------------------CHAPTER 1: COLLECTING SYSTEM INFORMATION------------------------------------------------------------------------------------------------------------------------------------------------------------In This Chapter------------------------------------------------------------------------------* Investigating the properties of the pseudo file system /proc and its ability to provide information on the running Linux system* Examining /proc's structure* Uncovering various information about the kernel and the processes running on the system------------------------------------------------------------------------------The proc file system acts as an interface to internal data structures in thekernel. It can be used to obtain information about the system and to changecertain kernel parameters at runtime (sysctl).First, we'll take a look at the read-only parts of /proc. In Chapter 2, weshow you how you can use /proc/sys to change settings.1.1 Process-Specific Subdirectories-----------------------------------The directory /proc contains (among other things) one subdirectory for eachprocess running on the system, which is named after the process ID (PID).The link self points to the process reading the file system. Each processsubdirectory has the entries listed in Table 1-1.Table 1-1: Process specific entries in /proc .............................................................................. File Content cmdline Command line arguments cpu Current and last cpu in wich it was executed (2.4)(smp) cwd Link to the current working directory environ Values of environment variables exe Link to the executable of this process fd Directory, which contains all file descriptors maps Memory maps to executables and library files (2.4) mem Memory held by this process root Link to the root directory of this process stat Process status statm Process memory status information status Process status in human readable form ..............................................................................For example, to get the status information of a process, all you have to do isread the file /proc/PID/status: >cat /proc/self/status Name: cat State: R (running) Pid: 5452 PPid: 743 TracerPid: 0 (2.4) Uid: 501 501 501 501 Gid: 100 100 100 100 Groups: 100 14 16 VmSize: 1112 kB VmLck: 0 kB VmRSS: 348 kB VmData: 24 kB VmStk: 12 kB VmExe: 8 kB VmLib: 1044 kB SigPnd: 0000000000000000 SigBlk: 0000000000000000 SigIgn: 0000000000000000 SigCgt: 0000000000000000 CapInh: 00000000fffffeff CapPrm: 0000000000000000 CapEff: 0000000000000000 This shows you nearly the same information you would get if you viewed it withthe ps command. In fact, ps uses the proc file system to obtain itsinformation. The statm file contains more detailed information about theprocess memory usage. Its seven fields are explained in Table 1-2.Table 1-2: Contents of the statm files .............................................................................. File Content size total program size resident size of memory portions shared number of pages that are shared trs number of pages that are 'code' drs number of pages of data/stack lrs number of pages of library dt number of dirty pages ..............................................................................1.2 Kernel data---------------Similar to the process entries, the kernel data files give information aboutthe running kernel. The files used to obtain this information are contained in/proc and are listed in Table 1-3. Not all of these will be present in yoursystem. It depends on the kernel configuration and the loaded modules, whichfiles are there, and which are missing.Table 1-3: Kernel info in /proc .............................................................................. File Content apm Advanced power management info bus Directory containing bus specific information cmdline Kernel command line cpuinfo Info about the CPU devices Available devices (block and character) dma Used DMS channels filesystems Supported filesystems driver Various drivers grouped here, currently rtc (2.4) execdomains Execdomains, related to security (2.4) fb Frame Buffer devices (2.4) fs File system parameters, currently nfs/exports (2.4) ide Directory containing info about the IDE subsystem interrupts Interrupt usage iomem Memory map (2.4) ioports I/O port usage irq Masks for irq to cpu affinity (2.4)(smp?) isapnp ISA PnP (Plug&Play) Info (2.4) kcore Kernel core image (can be ELF or A.OUT(deprecated in 2.4)) kmsg Kernel messages ksyms Kernel symbol table loadavg Load average of last 1, 5 & 15 minutes locks Kernel locks meminfo Memory info misc Miscellaneous modules List of loaded modules mounts Mounted filesystems net Networking info (see text) partitions Table of partitions known to the system pci Depreciated info of PCI bus (new way -> /proc/bus/pci/, decoupled by lspci (2.4) rtc Real time clock scsi SCSI info (see text) slabinfo Slab pool info stat Overall statistics swaps Swap space utilization sys See chapter 2 sysvipc Info of SysVIPC Resources (msg, sem, shm) (2.4) tty Info of tty drivers uptime System uptime version Kernel version video bttv info of video resources (2.4)..............................................................................You can, for example, check which interrupts are currently in use and whatthey are used for by looking in the file /proc/interrupts: > cat /proc/interrupts CPU0 0: 8728810 XT-PIC timer 1: 895 XT-PIC keyboard 2: 0 XT-PIC cascade 3: 531695 XT-PIC aha152x 4: 2014133 XT-PIC serial 5: 44401 XT-PIC pcnet_cs 8: 2 XT-PIC rtc 11: 8 XT-PIC i82365 12: 182918 XT-PIC PS/2 Mouse 13: 1 XT-PIC fpu 14: 1232265 XT-PIC ide0 15: 7 XT-PIC ide1 NMI: 0 In 2.4.* a couple of lines where added to this file LOC & ERR (this time is theoutput of a SMP machine): > cat /proc/interrupts CPU0 CPU1 0: 1243498 1214548 IO-APIC-edge timer 1: 8949 8958 IO-APIC-edge keyboard 2: 0 0 XT-PIC cascade 5: 11286 10161 IO-APIC-edge soundblaster 8: 1 0 IO-APIC-edge rtc 9: 27422 27407 IO-APIC-edge 3c503 12: 113645 113873 IO-APIC-edge PS/2 Mouse 13: 0 0 XT-PIC fpu 14: 22491 24012 IO-APIC-edge ide0 15: 2183 2415 IO-APIC-edge ide1 17: 30564 30414 IO-APIC-level eth0 18: 177 164 IO-APIC-level bttv NMI: 2457961 2457959 LOC: 2457882 2457881 ERR: 2155NMI is incremented in this case because every timer interrupt generates a NMI(Non Maskable Interrupt) which is used by the NMI Watchdog to detect lookups.LOC is the local interrupt counter of the internal APIC of every CPU.ERR is incremented in the case of errors in the IO-APIC bus (the bus thatconnects the CPUs in a SMP system. This means that an error has been detected,the IO-APIC automatically retry the transmission, so it should not be a bigproblem, but you should read the SMP-FAQ.In this context it could be interesting to note the new irq directory in 2.4.It could be used to set IRQ to CPU affinity, this means that you can "hook" anIRQ to only one CPU, or to exclude a CPU of handling IRQs. The contents of theirq subdir is one subdir for each IRQ, and one file; prof_cpu_maskFor example > ls /proc/irq/ 0 10 12 14 16 18 2 4 6 8 prof_cpu_mask 1 11 13 15 17 19 3 5 7 9 > ls /proc/irq/0/ smp_affinityThe contents of the prof_cpu_mask file and each smp_affinity file for each IRQis the same by default: > cat /proc/irq/0/smp_affinity ffffffffIt's a bitmask, in wich you can specify wich CPUs can handle the IRQ, you canset it by doing: > echo 1 > /proc/irq/prof_cpu_maskThis means that only the first CPU will handle the IRQ, but you can also echo 5wich means that only the first and fourth CPU can handle the IRQ.The way IRQs are routed is handled by the IO-APIC, and it's Round Robinbetween all the CPUs which are allowed to handle it. As usual the kernel hasmore info than you and does a better job than you, so the defaults are thebest choice for almost everyone.There are three more important subdirectories in /proc: net, scsi, and sys.The general rule is that the contents, or even the existence of thesedirectories, depend on your kernel configuration. If SCSI is not enabled, thedirectory scsi may not exist. The same is true with the net, which is thereonly when networking support is present in the running kernel.The slabinfo file gives information about memory usage at the slab level.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -