proc.txt 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389
  1. ------------------------------------------------------------------------------
  2. T H E /proc F I L E S Y S T E M
  3. ------------------------------------------------------------------------------
  4. /proc/sys Terrehon Bowden <terrehon@pacbell.net> October 7 1999
  5. Bodo Bauer <bb@ricochet.net>
  6. 2.4.x update Jorge Nerin <comandante@zaralinux.com> November 14 2000
  7. ------------------------------------------------------------------------------
  8. Version 1.3 Kernel version 2.2.12
  9. Kernel version 2.4.0-test11-pre4
  10. ------------------------------------------------------------------------------
  11. Table of Contents
  12. -----------------
  13. 0 Preface
  14. 0.1 Introduction/Credits
  15. 0.2 Legal Stuff
  16. 1 Collecting System Information
  17. 1.1 Process-Specific Subdirectories
  18. 1.2 Kernel data
  19. 1.3 IDE devices in /proc/ide
  20. 1.4 Networking info in /proc/net
  21. 1.5 SCSI info
  22. 1.6 Parallel port info in /proc/parport
  23. 1.7 TTY info in /proc/tty
  24. 1.8 Miscellaneous kernel statistics in /proc/stat
  25. 2 Modifying System Parameters
  26. 2.1 /proc/sys/fs - File system data
  27. 2.2 /proc/sys/fs/binfmt_misc - Miscellaneous binary formats
  28. 2.3 /proc/sys/kernel - general kernel parameters
  29. 2.4 /proc/sys/vm - The virtual memory subsystem
  30. 2.5 /proc/sys/dev - Device specific parameters
  31. 2.6 /proc/sys/sunrpc - Remote procedure calls
  32. 2.7 /proc/sys/net - Networking stuff
  33. 2.8 /proc/sys/net/ipv4 - IPV4 settings
  34. 2.9 Appletalk
  35. 2.10 IPX
  36. 2.11 /proc/sys/fs/mqueue - POSIX message queues filesystem
  37. 2.12 /proc/<pid>/oom_adj - Adjust the oom-killer score
  38. 2.13 /proc/<pid>/oom_score - Display current oom-killer score
  39. 2.14 /proc/<pid>/io - Display the IO accounting fields
  40. 2.15 /proc/<pid>/coredump_filter - Core dump filtering settings
  41. 2.16 /proc/<pid>/mountinfo - Information about mounts
  42. ------------------------------------------------------------------------------
  43. Preface
  44. ------------------------------------------------------------------------------
  45. 0.1 Introduction/Credits
  46. ------------------------
  47. This documentation is part of a soon (or so we hope) to be released book on
  48. the SuSE Linux distribution. As there is no complete documentation for the
  49. /proc file system and we've used many freely available sources to write these
  50. chapters, it seems only fair to give the work back to the Linux community.
  51. This work is based on the 2.2.* kernel version and the upcoming 2.4.*. I'm
  52. afraid it's still far from complete, but we hope it will be useful. As far as
  53. we know, it is the first 'all-in-one' document about the /proc file system. It
  54. is focused on the Intel x86 hardware, so if you are looking for PPC, ARM,
  55. SPARC, AXP, etc., features, you probably won't find what you are looking for.
  56. It also only covers IPv4 networking, not IPv6 nor other protocols - sorry. But
  57. additions and patches are welcome and will be added to this document if you
  58. mail them to Bodo.
  59. We'd like to thank Alan Cox, Rik van Riel, and Alexey Kuznetsov and a lot of
  60. other people for help compiling this documentation. We'd also like to extend a
  61. special thank you to Andi Kleen for documentation, which we relied on heavily
  62. to create this document, as well as the additional information he provided.
  63. Thanks to everybody else who contributed source or docs to the Linux kernel
  64. and helped create a great piece of software... :)
  65. If you have any comments, corrections or additions, please don't hesitate to
  66. contact Bodo Bauer at bb@ricochet.net. We'll be happy to add them to this
  67. document.
  68. The latest version of this document is available online at
  69. http://skaro.nightcrawler.com/~bb/Docs/Proc as HTML version.
  70. If the above direction does not works for you, ypu could try the kernel
  71. mailing list at linux-kernel@vger.kernel.org and/or try to reach me at
  72. comandante@zaralinux.com.
  73. 0.2 Legal Stuff
  74. ---------------
  75. We don't guarantee the correctness of this document, and if you come to us
  76. complaining about how you screwed up your system because of incorrect
  77. documentation, we won't feel responsible...
  78. ------------------------------------------------------------------------------
  79. CHAPTER 1: COLLECTING SYSTEM INFORMATION
  80. ------------------------------------------------------------------------------
  81. ------------------------------------------------------------------------------
  82. In This Chapter
  83. ------------------------------------------------------------------------------
  84. * Investigating the properties of the pseudo file system /proc and its
  85. ability to provide information on the running Linux system
  86. * Examining /proc's structure
  87. * Uncovering various information about the kernel and the processes running
  88. on the system
  89. ------------------------------------------------------------------------------
  90. The proc file system acts as an interface to internal data structures in the
  91. kernel. It can be used to obtain information about the system and to change
  92. certain kernel parameters at runtime (sysctl).
  93. First, we'll take a look at the read-only parts of /proc. In Chapter 2, we
  94. show you how you can use /proc/sys to change settings.
  95. 1.1 Process-Specific Subdirectories
  96. -----------------------------------
  97. The directory /proc contains (among other things) one subdirectory for each
  98. process running on the system, which is named after the process ID (PID).
  99. The link self points to the process reading the file system. Each process
  100. subdirectory has the entries listed in Table 1-1.
  101. Table 1-1: Process specific entries in /proc
  102. ..............................................................................
  103. File Content
  104. clear_refs Clears page referenced bits shown in smaps output
  105. cmdline Command line arguments
  106. cpu Current and last cpu in which it was executed (2.4)(smp)
  107. cwd Link to the current working directory
  108. environ Values of environment variables
  109. exe Link to the executable of this process
  110. fd Directory, which contains all file descriptors
  111. maps Memory maps to executables and library files (2.4)
  112. mem Memory held by this process
  113. root Link to the root directory of this process
  114. stat Process status
  115. statm Process memory status information
  116. status Process status in human readable form
  117. wchan If CONFIG_KALLSYMS is set, a pre-decoded wchan
  118. smaps Extension based on maps, the rss size for each mapped file
  119. ..............................................................................
  120. For example, to get the status information of a process, all you have to do is
  121. read the file /proc/PID/status:
  122. >cat /proc/self/status
  123. Name: cat
  124. State: R (running)
  125. Pid: 5452
  126. PPid: 743
  127. TracerPid: 0 (2.4)
  128. Uid: 501 501 501 501
  129. Gid: 100 100 100 100
  130. Groups: 100 14 16
  131. VmSize: 1112 kB
  132. VmLck: 0 kB
  133. VmRSS: 348 kB
  134. VmData: 24 kB
  135. VmStk: 12 kB
  136. VmExe: 8 kB
  137. VmLib: 1044 kB
  138. SigPnd: 0000000000000000
  139. SigBlk: 0000000000000000
  140. SigIgn: 0000000000000000
  141. SigCgt: 0000000000000000
  142. CapInh: 00000000fffffeff
  143. CapPrm: 0000000000000000
  144. CapEff: 0000000000000000
  145. This shows you nearly the same information you would get if you viewed it with
  146. the ps command. In fact, ps uses the proc file system to obtain its
  147. information. The statm file contains more detailed information about the
  148. process memory usage. Its seven fields are explained in Table 1-2. The stat
  149. file contains details information about the process itself. Its fields are
  150. explained in Table 1-3.
  151. Table 1-2: Contents of the statm files (as of 2.6.8-rc3)
  152. ..............................................................................
  153. Field Content
  154. size total program size (pages) (same as VmSize in status)
  155. resident size of memory portions (pages) (same as VmRSS in status)
  156. shared number of pages that are shared (i.e. backed by a file)
  157. trs number of pages that are 'code' (not including libs; broken,
  158. includes data segment)
  159. lrs number of pages of library (always 0 on 2.6)
  160. drs number of pages of data/stack (including libs; broken,
  161. includes library text)
  162. dt number of dirty pages (always 0 on 2.6)
  163. ..............................................................................
  164. Table 1-3: Contents of the stat files (as of 2.6.22-rc3)
  165. ..............................................................................
  166. Field Content
  167. pid process id
  168. tcomm filename of the executable
  169. state state (R is running, S is sleeping, D is sleeping in an
  170. uninterruptible wait, Z is zombie, T is traced or stopped)
  171. ppid process id of the parent process
  172. pgrp pgrp of the process
  173. sid session id
  174. tty_nr tty the process uses
  175. tty_pgrp pgrp of the tty
  176. flags task flags
  177. min_flt number of minor faults
  178. cmin_flt number of minor faults with child's
  179. maj_flt number of major faults
  180. cmaj_flt number of major faults with child's
  181. utime user mode jiffies
  182. stime kernel mode jiffies
  183. cutime user mode jiffies with child's
  184. cstime kernel mode jiffies with child's
  185. priority priority level
  186. nice nice level
  187. num_threads number of threads
  188. it_real_value (obsolete, always 0)
  189. start_time time the process started after system boot
  190. vsize virtual memory size
  191. rss resident set memory size
  192. rsslim current limit in bytes on the rss
  193. start_code address above which program text can run
  194. end_code address below which program text can run
  195. start_stack address of the start of the stack
  196. esp current value of ESP
  197. eip current value of EIP
  198. pending bitmap of pending signals (obsolete)
  199. blocked bitmap of blocked signals (obsolete)
  200. sigign bitmap of ignored signals (obsolete)
  201. sigcatch bitmap of catched signals (obsolete)
  202. wchan address where process went to sleep
  203. 0 (place holder)
  204. 0 (place holder)
  205. exit_signal signal to send to parent thread on exit
  206. task_cpu which CPU the task is scheduled on
  207. rt_priority realtime priority
  208. policy scheduling policy (man sched_setscheduler)
  209. blkio_ticks time spent waiting for block IO
  210. ..............................................................................
  211. 1.2 Kernel data
  212. ---------------
  213. Similar to the process entries, the kernel data files give information about
  214. the running kernel. The files used to obtain this information are contained in
  215. /proc and are listed in Table 1-4. Not all of these will be present in your
  216. system. It depends on the kernel configuration and the loaded modules, which
  217. files are there, and which are missing.
  218. Table 1-4: Kernel info in /proc
  219. ..............................................................................
  220. File Content
  221. apm Advanced power management info
  222. buddyinfo Kernel memory allocator information (see text) (2.5)
  223. bus Directory containing bus specific information
  224. cmdline Kernel command line
  225. cpuinfo Info about the CPU
  226. devices Available devices (block and character)
  227. dma Used DMS channels
  228. filesystems Supported filesystems
  229. driver Various drivers grouped here, currently rtc (2.4)
  230. execdomains Execdomains, related to security (2.4)
  231. fb Frame Buffer devices (2.4)
  232. fs File system parameters, currently nfs/exports (2.4)
  233. ide Directory containing info about the IDE subsystem
  234. interrupts Interrupt usage
  235. iomem Memory map (2.4)
  236. ioports I/O port usage
  237. irq Masks for irq to cpu affinity (2.4)(smp?)
  238. isapnp ISA PnP (Plug&Play) Info (2.4)
  239. kcore Kernel core image (can be ELF or A.OUT(deprecated in 2.4))
  240. kmsg Kernel messages
  241. ksyms Kernel symbol table
  242. loadavg Load average of last 1, 5 & 15 minutes
  243. locks Kernel locks
  244. meminfo Memory info
  245. misc Miscellaneous
  246. modules List of loaded modules
  247. mounts Mounted filesystems
  248. net Networking info (see text)
  249. partitions Table of partitions known to the system
  250. pci Deprecated info of PCI bus (new way -> /proc/bus/pci/,
  251. decoupled by lspci (2.4)
  252. rtc Real time clock
  253. scsi SCSI info (see text)
  254. slabinfo Slab pool info
  255. stat Overall statistics
  256. swaps Swap space utilization
  257. sys See chapter 2
  258. sysvipc Info of SysVIPC Resources (msg, sem, shm) (2.4)
  259. tty Info of tty drivers
  260. uptime System uptime
  261. version Kernel version
  262. video bttv info of video resources (2.4)
  263. ..............................................................................
  264. You can, for example, check which interrupts are currently in use and what
  265. they are used for by looking in the file /proc/interrupts:
  266. > cat /proc/interrupts
  267. CPU0
  268. 0: 8728810 XT-PIC timer
  269. 1: 895 XT-PIC keyboard
  270. 2: 0 XT-PIC cascade
  271. 3: 531695 XT-PIC aha152x
  272. 4: 2014133 XT-PIC serial
  273. 5: 44401 XT-PIC pcnet_cs
  274. 8: 2 XT-PIC rtc
  275. 11: 8 XT-PIC i82365
  276. 12: 182918 XT-PIC PS/2 Mouse
  277. 13: 1 XT-PIC fpu
  278. 14: 1232265 XT-PIC ide0
  279. 15: 7 XT-PIC ide1
  280. NMI: 0
  281. In 2.4.* a couple of lines where added to this file LOC & ERR (this time is the
  282. output of a SMP machine):
  283. > cat /proc/interrupts
  284. CPU0 CPU1
  285. 0: 1243498 1214548 IO-APIC-edge timer
  286. 1: 8949 8958 IO-APIC-edge keyboard
  287. 2: 0 0 XT-PIC cascade
  288. 5: 11286 10161 IO-APIC-edge soundblaster
  289. 8: 1 0 IO-APIC-edge rtc
  290. 9: 27422 27407 IO-APIC-edge 3c503
  291. 12: 113645 113873 IO-APIC-edge PS/2 Mouse
  292. 13: 0 0 XT-PIC fpu
  293. 14: 22491 24012 IO-APIC-edge ide0
  294. 15: 2183 2415 IO-APIC-edge ide1
  295. 17: 30564 30414 IO-APIC-level eth0
  296. 18: 177 164 IO-APIC-level bttv
  297. NMI: 2457961 2457959
  298. LOC: 2457882 2457881
  299. ERR: 2155
  300. NMI is incremented in this case because every timer interrupt generates a NMI
  301. (Non Maskable Interrupt) which is used by the NMI Watchdog to detect lockups.
  302. LOC is the local interrupt counter of the internal APIC of every CPU.
  303. ERR is incremented in the case of errors in the IO-APIC bus (the bus that
  304. connects the CPUs in a SMP system. This means that an error has been detected,
  305. the IO-APIC automatically retry the transmission, so it should not be a big
  306. problem, but you should read the SMP-FAQ.
  307. In 2.6.2* /proc/interrupts was expanded again. This time the goal was for
  308. /proc/interrupts to display every IRQ vector in use by the system, not
  309. just those considered 'most important'. The new vectors are:
  310. THR -- interrupt raised when a machine check threshold counter
  311. (typically counting ECC corrected errors of memory or cache) exceeds
  312. a configurable threshold. Only available on some systems.
  313. TRM -- a thermal event interrupt occurs when a temperature threshold
  314. has been exceeded for the CPU. This interrupt may also be generated
  315. when the temperature drops back to normal.
  316. SPU -- a spurious interrupt is some interrupt that was raised then lowered
  317. by some IO device before it could be fully processed by the APIC. Hence
  318. the APIC sees the interrupt but does not know what device it came from.
  319. For this case the APIC will generate the interrupt with a IRQ vector
  320. of 0xff. This might also be generated by chipset bugs.
  321. RES, CAL, TLB -- rescheduling, call and TLB flush interrupts are
  322. sent from one CPU to another per the needs of the OS. Typically,
  323. their statistics are used by kernel developers and interested users to
  324. determine the occurance of interrupt of the given type.
  325. The above IRQ vectors are displayed only when relevent. For example,
  326. the threshold vector does not exist on x86_64 platforms. Others are
  327. suppressed when the system is a uniprocessor. As of this writing, only
  328. i386 and x86_64 platforms support the new IRQ vector displays.
  329. Of some interest is the introduction of the /proc/irq directory to 2.4.
  330. It could be used to set IRQ to CPU affinity, this means that you can "hook" an
  331. IRQ to only one CPU, or to exclude a CPU of handling IRQs. The contents of the
  332. irq subdir is one subdir for each IRQ, and one file; prof_cpu_mask
  333. For example
  334. > ls /proc/irq/
  335. 0 10 12 14 16 18 2 4 6 8 prof_cpu_mask
  336. 1 11 13 15 17 19 3 5 7 9
  337. > ls /proc/irq/0/
  338. smp_affinity
  339. The contents of the prof_cpu_mask file and each smp_affinity file for each IRQ
  340. is the same by default:
  341. > cat /proc/irq/0/smp_affinity
  342. ffffffff
  343. It's a bitmask, in which you can specify which CPUs can handle the IRQ, you can
  344. set it by doing:
  345. > echo 1 > /proc/irq/prof_cpu_mask
  346. This means that only the first CPU will handle the IRQ, but you can also echo 5
  347. which means that only the first and fourth CPU can handle the IRQ.
  348. The way IRQs are routed is handled by the IO-APIC, and it's Round Robin
  349. between all the CPUs which are allowed to handle it. As usual the kernel has
  350. more info than you and does a better job than you, so the defaults are the
  351. best choice for almost everyone.
  352. There are three more important subdirectories in /proc: net, scsi, and sys.
  353. The general rule is that the contents, or even the existence of these
  354. directories, depend on your kernel configuration. If SCSI is not enabled, the
  355. directory scsi may not exist. The same is true with the net, which is there
  356. only when networking support is present in the running kernel.
  357. The slabinfo file gives information about memory usage at the slab level.
  358. Linux uses slab pools for memory management above page level in version 2.2.
  359. Commonly used objects have their own slab pool (such as network buffers,
  360. directory cache, and so on).
  361. ..............................................................................
  362. > cat /proc/buddyinfo
  363. Node 0, zone DMA 0 4 5 4 4 3 ...
  364. Node 0, zone Normal 1 0 0 1 101 8 ...
  365. Node 0, zone HighMem 2 0 0 1 1 0 ...
  366. Memory fragmentation is a problem under some workloads, and buddyinfo is a
  367. useful tool for helping diagnose these problems. Buddyinfo will give you a
  368. clue as to how big an area you can safely allocate, or why a previous
  369. allocation failed.
  370. Each column represents the number of pages of a certain order which are
  371. available. In this case, there are 0 chunks of 2^0*PAGE_SIZE available in
  372. ZONE_DMA, 4 chunks of 2^1*PAGE_SIZE in ZONE_DMA, 101 chunks of 2^4*PAGE_SIZE
  373. available in ZONE_NORMAL, etc...
  374. ..............................................................................
  375. meminfo:
  376. Provides information about distribution and utilization of memory. This
  377. varies by architecture and compile options. The following is from a
  378. 16GB PIII, which has highmem enabled. You may not have all of these fields.
  379. > cat /proc/meminfo
  380. MemTotal: 16344972 kB
  381. MemFree: 13634064 kB
  382. Buffers: 3656 kB
  383. Cached: 1195708 kB
  384. SwapCached: 0 kB
  385. Active: 891636 kB
  386. Inactive: 1077224 kB
  387. HighTotal: 15597528 kB
  388. HighFree: 13629632 kB
  389. LowTotal: 747444 kB
  390. LowFree: 4432 kB
  391. SwapTotal: 0 kB
  392. SwapFree: 0 kB
  393. Dirty: 968 kB
  394. Writeback: 0 kB
  395. Mapped: 280372 kB
  396. Slab: 684068 kB
  397. CommitLimit: 7669796 kB
  398. Committed_AS: 100056 kB
  399. PageTables: 24448 kB
  400. VmallocTotal: 112216 kB
  401. VmallocUsed: 428 kB
  402. VmallocChunk: 111088 kB
  403. MemTotal: Total usable ram (i.e. physical ram minus a few reserved
  404. bits and the kernel binary code)
  405. MemFree: The sum of LowFree+HighFree
  406. Buffers: Relatively temporary storage for raw disk blocks
  407. shouldn't get tremendously large (20MB or so)
  408. Cached: in-memory cache for files read from the disk (the
  409. pagecache). Doesn't include SwapCached
  410. SwapCached: Memory that once was swapped out, is swapped back in but
  411. still also is in the swapfile (if memory is needed it
  412. doesn't need to be swapped out AGAIN because it is already
  413. in the swapfile. This saves I/O)
  414. Active: Memory that has been used more recently and usually not
  415. reclaimed unless absolutely necessary.
  416. Inactive: Memory which has been less recently used. It is more
  417. eligible to be reclaimed for other purposes
  418. HighTotal:
  419. HighFree: Highmem is all memory above ~860MB of physical memory
  420. Highmem areas are for use by userspace programs, or
  421. for the pagecache. The kernel must use tricks to access
  422. this memory, making it slower to access than lowmem.
  423. LowTotal:
  424. LowFree: Lowmem is memory which can be used for everything that
  425. highmem can be used for, but it is also available for the
  426. kernel's use for its own data structures. Among many
  427. other things, it is where everything from the Slab is
  428. allocated. Bad things happen when you're out of lowmem.
  429. SwapTotal: total amount of swap space available
  430. SwapFree: Memory which has been evicted from RAM, and is temporarily
  431. on the disk
  432. Dirty: Memory which is waiting to get written back to the disk
  433. Writeback: Memory which is actively being written back to the disk
  434. Mapped: files which have been mmaped, such as libraries
  435. Slab: in-kernel data structures cache
  436. CommitLimit: Based on the overcommit ratio ('vm.overcommit_ratio'),
  437. this is the total amount of memory currently available to
  438. be allocated on the system. This limit is only adhered to
  439. if strict overcommit accounting is enabled (mode 2 in
  440. 'vm.overcommit_memory').
  441. The CommitLimit is calculated with the following formula:
  442. CommitLimit = ('vm.overcommit_ratio' * Physical RAM) + Swap
  443. For example, on a system with 1G of physical RAM and 7G
  444. of swap with a `vm.overcommit_ratio` of 30 it would
  445. yield a CommitLimit of 7.3G.
  446. For more details, see the memory overcommit documentation
  447. in vm/overcommit-accounting.
  448. Committed_AS: The amount of memory presently allocated on the system.
  449. The committed memory is a sum of all of the memory which
  450. has been allocated by processes, even if it has not been
  451. "used" by them as of yet. A process which malloc()'s 1G
  452. of memory, but only touches 300M of it will only show up
  453. as using 300M of memory even if it has the address space
  454. allocated for the entire 1G. This 1G is memory which has
  455. been "committed" to by the VM and can be used at any time
  456. by the allocating application. With strict overcommit
  457. enabled on the system (mode 2 in 'vm.overcommit_memory'),
  458. allocations which would exceed the CommitLimit (detailed
  459. above) will not be permitted. This is useful if one needs
  460. to guarantee that processes will not fail due to lack of
  461. memory once that memory has been successfully allocated.
  462. PageTables: amount of memory dedicated to the lowest level of page
  463. tables.
  464. VmallocTotal: total size of vmalloc memory area
  465. VmallocUsed: amount of vmalloc area which is used
  466. VmallocChunk: largest contigious block of vmalloc area which is free
  467. 1.3 IDE devices in /proc/ide
  468. ----------------------------
  469. The subdirectory /proc/ide contains information about all IDE devices of which
  470. the kernel is aware. There is one subdirectory for each IDE controller, the
  471. file drivers and a link for each IDE device, pointing to the device directory
  472. in the controller specific subtree.
  473. The file drivers contains general information about the drivers used for the
  474. IDE devices:
  475. > cat /proc/ide/drivers
  476. ide-cdrom version 4.53
  477. ide-disk version 1.08
  478. More detailed information can be found in the controller specific
  479. subdirectories. These are named ide0, ide1 and so on. Each of these
  480. directories contains the files shown in table 1-5.
  481. Table 1-5: IDE controller info in /proc/ide/ide?
  482. ..............................................................................
  483. File Content
  484. channel IDE channel (0 or 1)
  485. config Configuration (only for PCI/IDE bridge)
  486. mate Mate name
  487. model Type/Chipset of IDE controller
  488. ..............................................................................
  489. Each device connected to a controller has a separate subdirectory in the
  490. controllers directory. The files listed in table 1-6 are contained in these
  491. directories.
  492. Table 1-6: IDE device information
  493. ..............................................................................
  494. File Content
  495. cache The cache
  496. capacity Capacity of the medium (in 512Byte blocks)
  497. driver driver and version
  498. geometry physical and logical geometry
  499. identify device identify block
  500. media media type
  501. model device identifier
  502. settings device setup
  503. smart_thresholds IDE disk management thresholds
  504. smart_values IDE disk management values
  505. ..............................................................................
  506. The most interesting file is settings. This file contains a nice overview of
  507. the drive parameters:
  508. # cat /proc/ide/ide0/hda/settings
  509. name value min max mode
  510. ---- ----- --- --- ----
  511. bios_cyl 526 0 65535 rw
  512. bios_head 255 0 255 rw
  513. bios_sect 63 0 63 rw
  514. breada_readahead 4 0 127 rw
  515. bswap 0 0 1 r
  516. file_readahead 72 0 2097151 rw
  517. io_32bit 0 0 3 rw
  518. keepsettings 0 0 1 rw
  519. max_kb_per_request 122 1 127 rw
  520. multcount 0 0 8 rw
  521. nice1 1 0 1 rw
  522. nowerr 0 0 1 rw
  523. pio_mode write-only 0 255 w
  524. slow 0 0 1 rw
  525. unmaskirq 0 0 1 rw
  526. using_dma 0 0 1 rw
  527. 1.4 Networking info in /proc/net
  528. --------------------------------
  529. The subdirectory /proc/net follows the usual pattern. Table 1-6 shows the
  530. additional values you get for IP version 6 if you configure the kernel to
  531. support this. Table 1-7 lists the files and their meaning.
  532. Table 1-6: IPv6 info in /proc/net
  533. ..............................................................................
  534. File Content
  535. udp6 UDP sockets (IPv6)
  536. tcp6 TCP sockets (IPv6)
  537. raw6 Raw device statistics (IPv6)
  538. igmp6 IP multicast addresses, which this host joined (IPv6)
  539. if_inet6 List of IPv6 interface addresses
  540. ipv6_route Kernel routing table for IPv6
  541. rt6_stats Global IPv6 routing tables statistics
  542. sockstat6 Socket statistics (IPv6)
  543. snmp6 Snmp data (IPv6)
  544. ..............................................................................
  545. Table 1-7: Network info in /proc/net
  546. ..............................................................................
  547. File Content
  548. arp Kernel ARP table
  549. dev network devices with statistics
  550. dev_mcast the Layer2 multicast groups a device is listening too
  551. (interface index, label, number of references, number of bound
  552. addresses).
  553. dev_stat network device status
  554. ip_fwchains Firewall chain linkage
  555. ip_fwnames Firewall chain names
  556. ip_masq Directory containing the masquerading tables
  557. ip_masquerade Major masquerading table
  558. netstat Network statistics
  559. raw raw device statistics
  560. route Kernel routing table
  561. rpc Directory containing rpc info
  562. rt_cache Routing cache
  563. snmp SNMP data
  564. sockstat Socket statistics
  565. tcp TCP sockets
  566. tr_rif Token ring RIF routing table
  567. udp UDP sockets
  568. unix UNIX domain sockets
  569. wireless Wireless interface data (Wavelan etc)
  570. igmp IP multicast addresses, which this host joined
  571. psched Global packet scheduler parameters.
  572. netlink List of PF_NETLINK sockets
  573. ip_mr_vifs List of multicast virtual interfaces
  574. ip_mr_cache List of multicast routing cache
  575. ..............................................................................
  576. You can use this information to see which network devices are available in
  577. your system and how much traffic was routed over those devices:
  578. > cat /proc/net/dev
  579. Inter-|Receive |[...
  580. face |bytes packets errs drop fifo frame compressed multicast|[...
  581. lo: 908188 5596 0 0 0 0 0 0 [...
  582. ppp0:15475140 20721 410 0 0 410 0 0 [...
  583. eth0: 614530 7085 0 0 0 0 0 1 [...
  584. ...] Transmit
  585. ...] bytes packets errs drop fifo colls carrier compressed
  586. ...] 908188 5596 0 0 0 0 0 0
  587. ...] 1375103 17405 0 0 0 0 0 0
  588. ...] 1703981 5535 0 0 0 3 0 0
  589. In addition, each Channel Bond interface has it's own directory. For
  590. example, the bond0 device will have a directory called /proc/net/bond0/.
  591. It will contain information that is specific to that bond, such as the
  592. current slaves of the bond, the link status of the slaves, and how
  593. many times the slaves link has failed.
  594. 1.5 SCSI info
  595. -------------
  596. If you have a SCSI host adapter in your system, you'll find a subdirectory
  597. named after the driver for this adapter in /proc/scsi. You'll also see a list
  598. of all recognized SCSI devices in /proc/scsi:
  599. >cat /proc/scsi/scsi
  600. Attached devices:
  601. Host: scsi0 Channel: 00 Id: 00 Lun: 00
  602. Vendor: IBM Model: DGHS09U Rev: 03E0
  603. Type: Direct-Access ANSI SCSI revision: 03
  604. Host: scsi0 Channel: 00 Id: 06 Lun: 00
  605. Vendor: PIONEER Model: CD-ROM DR-U06S Rev: 1.04
  606. Type: CD-ROM ANSI SCSI revision: 02
  607. The directory named after the driver has one file for each adapter found in
  608. the system. These files contain information about the controller, including
  609. the used IRQ and the IO address range. The amount of information shown is
  610. dependent on the adapter you use. The example shows the output for an Adaptec
  611. AHA-2940 SCSI adapter:
  612. > cat /proc/scsi/aic7xxx/0
  613. Adaptec AIC7xxx driver version: 5.1.19/3.2.4
  614. Compile Options:
  615. TCQ Enabled By Default : Disabled
  616. AIC7XXX_PROC_STATS : Disabled
  617. AIC7XXX_RESET_DELAY : 5
  618. Adapter Configuration:
  619. SCSI Adapter: Adaptec AHA-294X Ultra SCSI host adapter
  620. Ultra Wide Controller
  621. PCI MMAPed I/O Base: 0xeb001000
  622. Adapter SEEPROM Config: SEEPROM found and used.
  623. Adaptec SCSI BIOS: Enabled
  624. IRQ: 10
  625. SCBs: Active 0, Max Active 2,
  626. Allocated 15, HW 16, Page 255
  627. Interrupts: 160328
  628. BIOS Control Word: 0x18b6
  629. Adapter Control Word: 0x005b
  630. Extended Translation: Enabled
  631. Disconnect Enable Flags: 0xffff
  632. Ultra Enable Flags: 0x0001
  633. Tag Queue Enable Flags: 0x0000
  634. Ordered Queue Tag Flags: 0x0000
  635. Default Tag Queue Depth: 8
  636. Tagged Queue By Device array for aic7xxx host instance 0:
  637. {255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255}
  638. Actual queue depth per device for aic7xxx host instance 0:
  639. {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
  640. Statistics:
  641. (scsi0:0:0:0)
  642. Device using Wide/Sync transfers at 40.0 MByte/sec, offset 8
  643. Transinfo settings: current(12/8/1/0), goal(12/8/1/0), user(12/15/1/0)
  644. Total transfers 160151 (74577 reads and 85574 writes)
  645. (scsi0:0:6:0)
  646. Device using Narrow/Sync transfers at 5.0 MByte/sec, offset 15
  647. Transinfo settings: current(50/15/0/0), goal(50/15/0/0), user(50/15/0/0)
  648. Total transfers 0 (0 reads and 0 writes)
  649. 1.6 Parallel port info in /proc/parport
  650. ---------------------------------------
  651. The directory /proc/parport contains information about the parallel ports of
  652. your system. It has one subdirectory for each port, named after the port
  653. number (0,1,2,...).
  654. These directories contain the four files shown in Table 1-8.
  655. Table 1-8: Files in /proc/parport
  656. ..............................................................................
  657. File Content
  658. autoprobe Any IEEE-1284 device ID information that has been acquired.
  659. devices list of the device drivers using that port. A + will appear by the
  660. name of the device currently using the port (it might not appear
  661. against any).
  662. hardware Parallel port's base address, IRQ line and DMA channel.
  663. irq IRQ that parport is using for that port. This is in a separate
  664. file to allow you to alter it by writing a new value in (IRQ
  665. number or none).
  666. ..............................................................................
  667. 1.7 TTY info in /proc/tty
  668. -------------------------
  669. Information about the available and actually used tty's can be found in the
  670. directory /proc/tty.You'll find entries for drivers and line disciplines in
  671. this directory, as shown in Table 1-9.
  672. Table 1-9: Files in /proc/tty
  673. ..............................................................................
  674. File Content
  675. drivers list of drivers and their usage
  676. ldiscs registered line disciplines
  677. driver/serial usage statistic and status of single tty lines
  678. ..............................................................................
  679. To see which tty's are currently in use, you can simply look into the file
  680. /proc/tty/drivers:
  681. > cat /proc/tty/drivers
  682. pty_slave /dev/pts 136 0-255 pty:slave
  683. pty_master /dev/ptm 128 0-255 pty:master
  684. pty_slave /dev/ttyp 3 0-255 pty:slave
  685. pty_master /dev/pty 2 0-255 pty:master
  686. serial /dev/cua 5 64-67 serial:callout
  687. serial /dev/ttyS 4 64-67 serial
  688. /dev/tty0 /dev/tty0 4 0 system:vtmaster
  689. /dev/ptmx /dev/ptmx 5 2 system
  690. /dev/console /dev/console 5 1 system:console
  691. /dev/tty /dev/tty 5 0 system:/dev/tty
  692. unknown /dev/tty 4 1-63 console
  693. 1.8 Miscellaneous kernel statistics in /proc/stat
  694. -------------------------------------------------
  695. Various pieces of information about kernel activity are available in the
  696. /proc/stat file. All of the numbers reported in this file are aggregates
  697. since the system first booted. For a quick look, simply cat the file:
  698. > cat /proc/stat
  699. cpu 2255 34 2290 22625563 6290 127 456 0
  700. cpu0 1132 34 1441 11311718 3675 127 438 0
  701. cpu1 1123 0 849 11313845 2614 0 18 0
  702. intr 114930548 113199788 3 0 5 263 0 4 [... lots more numbers ...]
  703. ctxt 1990473
  704. btime 1062191376
  705. processes 2915
  706. procs_running 1
  707. procs_blocked 0
  708. The very first "cpu" line aggregates the numbers in all of the other "cpuN"
  709. lines. These numbers identify the amount of time the CPU has spent performing
  710. different kinds of work. Time units are in USER_HZ (typically hundredths of a
  711. second). The meanings of the columns are as follows, from left to right:
  712. - user: normal processes executing in user mode
  713. - nice: niced processes executing in user mode
  714. - system: processes executing in kernel mode
  715. - idle: twiddling thumbs
  716. - iowait: waiting for I/O to complete
  717. - irq: servicing interrupts
  718. - softirq: servicing softirqs
  719. - steal: involuntary wait
  720. The "intr" line gives counts of interrupts serviced since boot time, for each
  721. of the possible system interrupts. The first column is the total of all
  722. interrupts serviced; each subsequent column is the total for that particular
  723. interrupt.
  724. The "ctxt" line gives the total number of context switches across all CPUs.
  725. The "btime" line gives the time at which the system booted, in seconds since
  726. the Unix epoch.
  727. The "processes" line gives the number of processes and threads created, which
  728. includes (but is not limited to) those created by calls to the fork() and
  729. clone() system calls.
  730. The "procs_running" line gives the number of processes currently running on
  731. CPUs.
  732. The "procs_blocked" line gives the number of processes currently blocked,
  733. waiting for I/O to complete.
  734. 1.9 Ext4 file system parameters
  735. ------------------------------
  736. Ext4 file system have one directory per partition under /proc/fs/ext4/
  737. # ls /proc/fs/ext4/hdc/
  738. group_prealloc max_to_scan mb_groups mb_history min_to_scan order2_req
  739. stats stream_req
  740. mb_groups:
  741. This file gives the details of mutiblock allocator buddy cache of free blocks
  742. mb_history:
  743. Multiblock allocation history.
  744. stats:
  745. This file indicate whether the multiblock allocator should start collecting
  746. statistics. The statistics are shown during unmount
  747. group_prealloc:
  748. The multiblock allocator normalize the block allocation request to
  749. group_prealloc filesystem blocks if we don't have strip value set.
  750. The stripe value can be specified at mount time or during mke2fs.
  751. max_to_scan:
  752. How long multiblock allocator can look for a best extent (in found extents)
  753. min_to_scan:
  754. How long multiblock allocator must look for a best extent
  755. order2_req:
  756. Multiblock allocator use 2^N search using buddies only for requests greater
  757. than or equal to order2_req. The request size is specfied in file system
  758. blocks. A value of 2 indicate only if the requests are greater than or equal
  759. to 4 blocks.
  760. stream_req:
  761. Files smaller than stream_req are served by the stream allocator, whose
  762. purpose is to pack requests as close each to other as possible to
  763. produce smooth I/O traffic. Avalue of 16 indicate that file smaller than 16
  764. filesystem block size will use group based preallocation.
  765. ------------------------------------------------------------------------------
  766. Summary
  767. ------------------------------------------------------------------------------
  768. The /proc file system serves information about the running system. It not only
  769. allows access to process data but also allows you to request the kernel status
  770. by reading files in the hierarchy.
  771. The directory structure of /proc reflects the types of information and makes
  772. it easy, if not obvious, where to look for specific data.
  773. ------------------------------------------------------------------------------
  774. ------------------------------------------------------------------------------
  775. CHAPTER 2: MODIFYING SYSTEM PARAMETERS
  776. ------------------------------------------------------------------------------
  777. ------------------------------------------------------------------------------
  778. In This Chapter
  779. ------------------------------------------------------------------------------
  780. * Modifying kernel parameters by writing into files found in /proc/sys
  781. * Exploring the files which modify certain parameters
  782. * Review of the /proc/sys file tree
  783. ------------------------------------------------------------------------------
  784. A very interesting part of /proc is the directory /proc/sys. This is not only
  785. a source of information, it also allows you to change parameters within the
  786. kernel. Be very careful when attempting this. You can optimize your system,
  787. but you can also cause it to crash. Never alter kernel parameters on a
  788. production system. Set up a development machine and test to make sure that
  789. everything works the way you want it to. You may have no alternative but to
  790. reboot the machine once an error has been made.
  791. To change a value, simply echo the new value into the file. An example is
  792. given below in the section on the file system data. You need to be root to do
  793. this. You can create your own boot script to perform this every time your
  794. system boots.
  795. The files in /proc/sys can be used to fine tune and monitor miscellaneous and
  796. general things in the operation of the Linux kernel. Since some of the files
  797. can inadvertently disrupt your system, it is advisable to read both
  798. documentation and source before actually making adjustments. In any case, be
  799. very careful when writing to any of these files. The entries in /proc may
  800. change slightly between the 2.1.* and the 2.2 kernel, so if there is any doubt
  801. review the kernel documentation in the directory /usr/src/linux/Documentation.
  802. This chapter is heavily based on the documentation included in the pre 2.2
  803. kernels, and became part of it in version 2.2.1 of the Linux kernel.
  804. 2.1 /proc/sys/fs - File system data
  805. -----------------------------------
  806. This subdirectory contains specific file system, file handle, inode, dentry
  807. and quota information.
  808. Currently, these files are in /proc/sys/fs:
  809. dentry-state
  810. ------------
  811. Status of the directory cache. Since directory entries are dynamically
  812. allocated and deallocated, this file indicates the current status. It holds
  813. six values, in which the last two are not used and are always zero. The others
  814. are listed in table 2-1.
  815. Table 2-1: Status files of the directory cache
  816. ..............................................................................
  817. File Content
  818. nr_dentry Almost always zero
  819. nr_unused Number of unused cache entries
  820. age_limit
  821. in seconds after the entry may be reclaimed, when memory is short
  822. want_pages internally
  823. ..............................................................................
  824. dquot-nr and dquot-max
  825. ----------------------
  826. The file dquot-max shows the maximum number of cached disk quota entries.
  827. The file dquot-nr shows the number of allocated disk quota entries and the
  828. number of free disk quota entries.
  829. If the number of available cached disk quotas is very low and you have a large
  830. number of simultaneous system users, you might want to raise the limit.
  831. file-nr and file-max
  832. --------------------
  833. The kernel allocates file handles dynamically, but doesn't free them again at
  834. this time.
  835. The value in file-max denotes the maximum number of file handles that the
  836. Linux kernel will allocate. When you get a lot of error messages about running
  837. out of file handles, you might want to raise this limit. The default value is
  838. 10% of RAM in kilobytes. To change it, just write the new number into the
  839. file:
  840. # cat /proc/sys/fs/file-max
  841. 4096
  842. # echo 8192 > /proc/sys/fs/file-max
  843. # cat /proc/sys/fs/file-max
  844. 8192
  845. This method of revision is useful for all customizable parameters of the
  846. kernel - simply echo the new value to the corresponding file.
  847. Historically, the three values in file-nr denoted the number of allocated file
  848. handles, the number of allocated but unused file handles, and the maximum
  849. number of file handles. Linux 2.6 always reports 0 as the number of free file
  850. handles -- this is not an error, it just means that the number of allocated
  851. file handles exactly matches the number of used file handles.
  852. Attempts to allocate more file descriptors than file-max are reported with
  853. printk, look for "VFS: file-max limit <number> reached".
  854. inode-state and inode-nr
  855. ------------------------
  856. The file inode-nr contains the first two items from inode-state, so we'll skip
  857. to that file...
  858. inode-state contains two actual numbers and five dummy values. The numbers
  859. are nr_inodes and nr_free_inodes (in order of appearance).
  860. nr_inodes
  861. ~~~~~~~~~
  862. Denotes the number of inodes the system has allocated. This number will
  863. grow and shrink dynamically.
  864. nr_open
  865. -------
  866. Denotes the maximum number of file-handles a process can
  867. allocate. Default value is 1024*1024 (1048576) which should be
  868. enough for most machines. Actual limit depends on RLIMIT_NOFILE
  869. resource limit.
  870. nr_free_inodes
  871. --------------
  872. Represents the number of free inodes. Ie. The number of inuse inodes is
  873. (nr_inodes - nr_free_inodes).
  874. aio-nr and aio-max-nr
  875. ---------------------
  876. aio-nr is the running total of the number of events specified on the
  877. io_setup system call for all currently active aio contexts. If aio-nr
  878. reaches aio-max-nr then io_setup will fail with EAGAIN. Note that
  879. raising aio-max-nr does not result in the pre-allocation or re-sizing
  880. of any kernel data structures.
  881. 2.2 /proc/sys/fs/binfmt_misc - Miscellaneous binary formats
  882. -----------------------------------------------------------
  883. Besides these files, there is the subdirectory /proc/sys/fs/binfmt_misc. This
  884. handles the kernel support for miscellaneous binary formats.
  885. Binfmt_misc provides the ability to register additional binary formats to the
  886. Kernel without compiling an additional module/kernel. Therefore, binfmt_misc
  887. needs to know magic numbers at the beginning or the filename extension of the
  888. binary.
  889. It works by maintaining a linked list of structs that contain a description of
  890. a binary format, including a magic with size (or the filename extension),
  891. offset and mask, and the interpreter name. On request it invokes the given
  892. interpreter with the original program as argument, as binfmt_java and
  893. binfmt_em86 and binfmt_mz do. Since binfmt_misc does not define any default
  894. binary-formats, you have to register an additional binary-format.
  895. There are two general files in binfmt_misc and one file per registered format.
  896. The two general files are register and status.
  897. Registering a new binary format
  898. -------------------------------
  899. To register a new binary format you have to issue the command
  900. echo :name:type:offset:magic:mask:interpreter: > /proc/sys/fs/binfmt_misc/register
  901. with appropriate name (the name for the /proc-dir entry), offset (defaults to
  902. 0, if omitted), magic, mask (which can be omitted, defaults to all 0xff) and
  903. last but not least, the interpreter that is to be invoked (for example and
  904. testing /bin/echo). Type can be M for usual magic matching or E for filename
  905. extension matching (give extension in place of magic).
  906. Check or reset the status of the binary format handler
  907. ------------------------------------------------------
  908. If you do a cat on the file /proc/sys/fs/binfmt_misc/status, you will get the
  909. current status (enabled/disabled) of binfmt_misc. Change the status by echoing
  910. 0 (disables) or 1 (enables) or -1 (caution: this clears all previously
  911. registered binary formats) to status. For example echo 0 > status to disable
  912. binfmt_misc (temporarily).
  913. Status of a single handler
  914. --------------------------
  915. Each registered handler has an entry in /proc/sys/fs/binfmt_misc. These files
  916. perform the same function as status, but their scope is limited to the actual
  917. binary format. By cating this file, you also receive all related information
  918. about the interpreter/magic of the binfmt.
  919. Example usage of binfmt_misc (emulate binfmt_java)
  920. --------------------------------------------------
  921. cd /proc/sys/fs/binfmt_misc
  922. echo ':Java:M::\xca\xfe\xba\xbe::/usr/local/java/bin/javawrapper:' > register
  923. echo ':HTML:E::html::/usr/local/java/bin/appletviewer:' > register
  924. echo ':Applet:M::<!--applet::/usr/local/java/bin/appletviewer:' > register
  925. echo ':DEXE:M::\x0eDEX::/usr/bin/dosexec:' > register
  926. These four lines add support for Java executables and Java applets (like
  927. binfmt_java, additionally recognizing the .html extension with no need to put
  928. <!--applet> to every applet file). You have to install the JDK and the
  929. shell-script /usr/local/java/bin/javawrapper too. It works around the
  930. brokenness of the Java filename handling. To add a Java binary, just create a
  931. link to the class-file somewhere in the path.
  932. 2.3 /proc/sys/kernel - general kernel parameters
  933. ------------------------------------------------
  934. This directory reflects general kernel behaviors. As I've said before, the
  935. contents depend on your configuration. Here you'll find the most important
  936. files, along with descriptions of what they mean and how to use them.
  937. acct
  938. ----
  939. The file contains three values; highwater, lowwater, and frequency.
  940. It exists only when BSD-style process accounting is enabled. These values
  941. control its behavior. If the free space on the file system where the log lives
  942. goes below lowwater percentage, accounting suspends. If it goes above
  943. highwater percentage, accounting resumes. Frequency determines how often you
  944. check the amount of free space (value is in seconds). Default settings are: 4,
  945. 2, and 30. That is, suspend accounting if there is less than 2 percent free;
  946. resume it if we have a value of 3 or more percent; consider information about
  947. the amount of free space valid for 30 seconds
  948. ctrl-alt-del
  949. ------------
  950. When the value in this file is 0, ctrl-alt-del is trapped and sent to the init
  951. program to handle a graceful restart. However, when the value is greater that
  952. zero, Linux's reaction to this key combination will be an immediate reboot,
  953. without syncing its dirty buffers.
  954. [NOTE]
  955. When a program (like dosemu) has the keyboard in raw mode, the
  956. ctrl-alt-del is intercepted by the program before it ever reaches the
  957. kernel tty layer, and it is up to the program to decide what to do with
  958. it.
  959. domainname and hostname
  960. -----------------------
  961. These files can be controlled to set the NIS domainname and hostname of your
  962. box. For the classic darkstar.frop.org a simple:
  963. # echo "darkstar" > /proc/sys/kernel/hostname
  964. # echo "frop.org" > /proc/sys/kernel/domainname
  965. would suffice to set your hostname and NIS domainname.
  966. osrelease, ostype and version
  967. -----------------------------
  968. The names make it pretty obvious what these fields contain:
  969. > cat /proc/sys/kernel/osrelease
  970. 2.2.12
  971. > cat /proc/sys/kernel/ostype
  972. Linux
  973. > cat /proc/sys/kernel/version
  974. #4 Fri Oct 1 12:41:14 PDT 1999
  975. The files osrelease and ostype should be clear enough. Version needs a little
  976. more clarification. The #4 means that this is the 4th kernel built from this
  977. source base and the date after it indicates the time the kernel was built. The
  978. only way to tune these values is to rebuild the kernel.
  979. panic
  980. -----
  981. The value in this file represents the number of seconds the kernel waits
  982. before rebooting on a panic. When you use the software watchdog, the
  983. recommended setting is 60. If set to 0, the auto reboot after a kernel panic
  984. is disabled, which is the default setting.
  985. printk
  986. ------
  987. The four values in printk denote
  988. * console_loglevel,
  989. * default_message_loglevel,
  990. * minimum_console_loglevel and
  991. * default_console_loglevel
  992. respectively.
  993. These values influence printk() behavior when printing or logging error
  994. messages, which come from inside the kernel. See syslog(2) for more
  995. information on the different log levels.
  996. console_loglevel
  997. ----------------
  998. Messages with a higher priority than this will be printed to the console.
  999. default_message_level
  1000. ---------------------
  1001. Messages without an explicit priority will be printed with this priority.
  1002. minimum_console_loglevel
  1003. ------------------------
  1004. Minimum (highest) value to which the console_loglevel can be set.
  1005. default_console_loglevel
  1006. ------------------------
  1007. Default value for console_loglevel.
  1008. sg-big-buff
  1009. -----------
  1010. This file shows the size of the generic SCSI (sg) buffer. At this point, you
  1011. can't tune it yet, but you can change it at compile time by editing
  1012. include/scsi/sg.h and changing the value of SG_BIG_BUFF.
  1013. If you use a scanner with SANE (Scanner Access Now Easy) you might want to set
  1014. this to a higher value. Refer to the SANE documentation on this issue.
  1015. modprobe
  1016. --------
  1017. The location where the modprobe binary is located. The kernel uses this
  1018. program to load modules on demand.
  1019. unknown_nmi_panic
  1020. -----------------
  1021. The value in this file affects behavior of handling NMI. When the value is
  1022. non-zero, unknown NMI is trapped and then panic occurs. At that time, kernel
  1023. debugging information is displayed on console.
  1024. NMI switch that most IA32 servers have fires unknown NMI up, for example.
  1025. If a system hangs up, try pressing the NMI switch.
  1026. nmi_watchdog
  1027. ------------
  1028. Enables/Disables the NMI watchdog on x86 systems. When the value is non-zero
  1029. the NMI watchdog is enabled and will continuously test all online cpus to
  1030. determine whether or not they are still functioning properly.
  1031. Because the NMI watchdog shares registers with oprofile, by disabling the NMI
  1032. watchdog, oprofile may have more registers to utilize.
  1033. maps_protect
  1034. ------------
  1035. Enables/Disables the protection of the per-process proc entries "maps" and
  1036. "smaps". When enabled, the contents of these files are visible only to
  1037. readers that are allowed to ptrace() the given process.
  1038. 2.4 /proc/sys/vm - The virtual memory subsystem
  1039. -----------------------------------------------
  1040. The files in this directory can be used to tune the operation of the virtual
  1041. memory (VM) subsystem of the Linux kernel.
  1042. vfs_cache_pressure
  1043. ------------------
  1044. Controls the tendency of the kernel to reclaim the memory which is used for
  1045. caching of directory and inode objects.
  1046. At the default value of vfs_cache_pressure=100 the kernel will attempt to
  1047. reclaim dentries and inodes at a "fair" rate with respect to pagecache and
  1048. swapcache reclaim. Decreasing vfs_cache_pressure causes the kernel to prefer
  1049. to retain dentry and inode caches. Increasing vfs_cache_pressure beyond 100
  1050. causes the kernel to prefer to reclaim dentries and inodes.
  1051. dirty_background_ratio
  1052. ----------------------
  1053. Contains, as a percentage of total system memory, the number of pages at which
  1054. the pdflush background writeback daemon will start writing out dirty data.
  1055. dirty_ratio
  1056. -----------------
  1057. Contains, as a percentage of total system memory, the number of pages at which
  1058. a process which is generating disk writes will itself start writing out dirty
  1059. data.
  1060. dirty_writeback_centisecs
  1061. -------------------------
  1062. The pdflush writeback daemons will periodically wake up and write `old' data
  1063. out to disk. This tunable expresses the interval between those wakeups, in
  1064. 100'ths of a second.
  1065. Setting this to zero disables periodic writeback altogether.
  1066. dirty_expire_centisecs
  1067. ----------------------
  1068. This tunable is used to define when dirty data is old enough to be eligible
  1069. for writeout by the pdflush daemons. It is expressed in 100'ths of a second.
  1070. Data which has been dirty in-memory for longer than this interval will be
  1071. written out next time a pdflush daemon wakes up.
  1072. highmem_is_dirtyable
  1073. --------------------
  1074. Only present if CONFIG_HIGHMEM is set.
  1075. This defaults to 0 (false), meaning that the ratios set above are calculated
  1076. as a percentage of lowmem only. This protects against excessive scanning
  1077. in page reclaim, swapping and general VM distress.
  1078. Setting this to 1 can be useful on 32 bit machines where you want to make
  1079. random changes within an MMAPed file that is larger than your available
  1080. lowmem without causing large quantities of random IO. Is is safe if the
  1081. behavior of all programs running on the machine is known and memory will
  1082. not be otherwise stressed.
  1083. legacy_va_layout
  1084. ----------------
  1085. If non-zero, this sysctl disables the new 32-bit mmap mmap layout - the kernel
  1086. will use the legacy (2.4) layout for all processes.
  1087. lowmem_reserve_ratio
  1088. ---------------------
  1089. For some specialised workloads on highmem machines it is dangerous for
  1090. the kernel to allow process memory to be allocated from the "lowmem"
  1091. zone. This is because that memory could then be pinned via the mlock()
  1092. system call, or by unavailability of swapspace.
  1093. And on large highmem machines this lack of reclaimable lowmem memory
  1094. can be fatal.
  1095. So the Linux page allocator has a mechanism which prevents allocations
  1096. which _could_ use highmem from using too much lowmem. This means that
  1097. a certain amount of lowmem is defended from the possibility of being
  1098. captured into pinned user memory.
  1099. (The same argument applies to the old 16 megabyte ISA DMA region. This
  1100. mechanism will also defend that region from allocations which could use
  1101. highmem or lowmem).
  1102. The `lowmem_reserve_ratio' tunable determines how aggressive the kernel is
  1103. in defending these lower zones.
  1104. If you have a machine which uses highmem or ISA DMA and your
  1105. applications are using mlock(), or if you are running with no swap then
  1106. you probably should change the lowmem_reserve_ratio setting.
  1107. The lowmem_reserve_ratio is an array. You can see them by reading this file.
  1108. -
  1109. % cat /proc/sys/vm/lowmem_reserve_ratio
  1110. 256 256 32
  1111. -
  1112. Note: # of this elements is one fewer than number of zones. Because the highest
  1113. zone's value is not necessary for following calculation.
  1114. But, these values are not used directly. The kernel calculates # of protection
  1115. pages for each zones from them. These are shown as array of protection pages
  1116. in /proc/zoneinfo like followings. (This is an example of x86-64 box).
  1117. Each zone has an array of protection pages like this.
  1118. -
  1119. Node 0, zone DMA
  1120. pages free 1355
  1121. min 3
  1122. low 3
  1123. high 4
  1124. :
  1125. :
  1126. numa_other 0
  1127. protection: (0, 2004, 2004, 2004)
  1128. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1129. pagesets
  1130. cpu: 0 pcp: 0
  1131. :
  1132. -
  1133. These protections are added to score to judge whether this zone should be used
  1134. for page allocation or should be reclaimed.
  1135. In this example, if normal pages (index=2) are required to this DMA zone and
  1136. pages_high is used for watermark, the kernel judges this zone should not be
  1137. used because pages_free(1355) is smaller than watermark + protection[2]
  1138. (4 + 2004 = 2008). If this protection value is 0, this zone would be used for
  1139. normal page requirement. If requirement is DMA zone(index=0), protection[0]
  1140. (=0) is used.
  1141. zone[i]'s protection[j] is calculated by following exprssion.
  1142. (i < j):
  1143. zone[i]->protection[j]
  1144. = (total sums of present_pages from zone[i+1] to zone[j] on the node)
  1145. / lowmem_reserve_ratio[i];
  1146. (i = j):
  1147. (should not be protected. = 0;
  1148. (i > j):
  1149. (not necessary, but looks 0)
  1150. The default values of lowmem_reserve_ratio[i] are
  1151. 256 (if zone[i] means DMA or DMA32 zone)
  1152. 32 (others).
  1153. As above expression, they are reciprocal number of ratio.
  1154. 256 means 1/256. # of protection pages becomes about "0.39%" of total present
  1155. pages of higher zones on the node.
  1156. If you would like to protect more pages, smaller values are effective.
  1157. The minimum value is 1 (1/1 -> 100%).
  1158. page-cluster
  1159. ------------
  1160. page-cluster controls the number of pages which are written to swap in
  1161. a single attempt. The swap I/O size.
  1162. It is a logarithmic value - setting it to zero means "1 page", setting
  1163. it to 1 means "2 pages", setting it to 2 means "4 pages", etc.
  1164. The default value is three (eight pages at a time). There may be some
  1165. small benefits in tuning this to a different value if your workload is
  1166. swap-intensive.
  1167. overcommit_memory
  1168. -----------------
  1169. Controls overcommit of system memory, possibly allowing processes
  1170. to allocate (but not use) more memory than is actually available.
  1171. 0 - Heuristic overcommit handling. Obvious overcommits of
  1172. address space are refused. Used for a typical system. It
  1173. ensures a seriously wild allocation fails while allowing
  1174. overcommit to reduce swap usage. root is allowed to
  1175. allocate slightly more memory in this mode. This is the
  1176. default.
  1177. 1 - Always overcommit. Appropriate for some scientific
  1178. applications.
  1179. 2 - Don't overcommit. The total address space commit
  1180. for the system is not permitted to exceed swap plus a
  1181. configurable percentage (default is 50) of physical RAM.
  1182. Depending on the percentage you use, in most situations
  1183. this means a process will not be killed while attempting
  1184. to use already-allocated memory but will receive errors
  1185. on memory allocation as appropriate.
  1186. overcommit_ratio
  1187. ----------------
  1188. Percentage of physical memory size to include in overcommit calculations
  1189. (see above.)
  1190. Memory allocation limit = swapspace + physmem * (overcommit_ratio / 100)
  1191. swapspace = total size of all swap areas
  1192. physmem = size of physical memory in system
  1193. nr_hugepages and hugetlb_shm_group
  1194. ----------------------------------
  1195. nr_hugepages configures number of hugetlb page reserved for the system.
  1196. hugetlb_shm_group contains group id that is allowed to create SysV shared
  1197. memory segment using hugetlb page.
  1198. hugepages_treat_as_movable
  1199. --------------------------
  1200. This parameter is only useful when kernelcore= is specified at boot time to
  1201. create ZONE_MOVABLE for pages that may be reclaimed or migrated. Huge pages
  1202. are not movable so are not normally allocated from ZONE_MOVABLE. A non-zero
  1203. value written to hugepages_treat_as_movable allows huge pages to be allocated
  1204. from ZONE_MOVABLE.
  1205. Once enabled, the ZONE_MOVABLE is treated as an area of memory the huge
  1206. pages pool can easily grow or shrink within. Assuming that applications are
  1207. not running that mlock() a lot of memory, it is likely the huge pages pool
  1208. can grow to the size of ZONE_MOVABLE by repeatedly entering the desired value
  1209. into nr_hugepages and triggering page reclaim.
  1210. laptop_mode
  1211. -----------
  1212. laptop_mode is a knob that controls "laptop mode". All the things that are
  1213. controlled by this knob are discussed in Documentation/laptops/laptop-mode.txt.
  1214. block_dump
  1215. ----------
  1216. block_dump enables block I/O debugging when set to a nonzero value. More
  1217. information on block I/O debugging is in Documentation/laptops/laptop-mode.txt.
  1218. swap_token_timeout
  1219. ------------------
  1220. This file contains valid hold time of swap out protection token. The Linux
  1221. VM has token based thrashing control mechanism and uses the token to prevent
  1222. unnecessary page faults in thrashing situation. The unit of the value is
  1223. second. The value would be useful to tune thrashing behavior.
  1224. drop_caches
  1225. -----------
  1226. Writing to this will cause the kernel to drop clean caches, dentries and
  1227. inodes from memory, causing that memory to become free.
  1228. To free pagecache:
  1229. echo 1 > /proc/sys/vm/drop_caches
  1230. To free dentries and inodes:
  1231. echo 2 > /proc/sys/vm/drop_caches
  1232. To free pagecache, dentries and inodes:
  1233. echo 3 > /proc/sys/vm/drop_caches
  1234. As this is a non-destructive operation and dirty objects are not freeable, the
  1235. user should run `sync' first.
  1236. 2.5 /proc/sys/dev - Device specific parameters
  1237. ----------------------------------------------
  1238. Currently there is only support for CDROM drives, and for those, there is only
  1239. one read-only file containing information about the CD-ROM drives attached to
  1240. the system:
  1241. >cat /proc/sys/dev/cdrom/info
  1242. CD-ROM information, Id: cdrom.c 2.55 1999/04/25
  1243. drive name: sr0 hdb
  1244. drive speed: 32 40
  1245. drive # of slots: 1 0
  1246. Can close tray: 1 1
  1247. Can open tray: 1 1
  1248. Can lock tray: 1 1
  1249. Can change speed: 1 1
  1250. Can select disk: 0 1
  1251. Can read multisession: 1 1
  1252. Can read MCN: 1 1
  1253. Reports media changed: 1 1
  1254. Can play audio: 1 1
  1255. You see two drives, sr0 and hdb, along with a list of their features.
  1256. 2.6 /proc/sys/sunrpc - Remote procedure calls
  1257. ---------------------------------------------
  1258. This directory contains four files, which enable or disable debugging for the
  1259. RPC functions NFS, NFS-daemon, RPC and NLM. The default values are 0. They can
  1260. be set to one to turn debugging on. (The default value is 0 for each)
  1261. 2.7 /proc/sys/net - Networking stuff
  1262. ------------------------------------
  1263. The interface to the networking parts of the kernel is located in
  1264. /proc/sys/net. Table 2-3 shows all possible subdirectories. You may see only
  1265. some of them, depending on your kernel's configuration.
  1266. Table 2-3: Subdirectories in /proc/sys/net
  1267. ..............................................................................
  1268. Directory Content Directory Content
  1269. core General parameter appletalk Appletalk protocol
  1270. unix Unix domain sockets netrom NET/ROM
  1271. 802 E802 protocol ax25 AX25
  1272. ethernet Ethernet protocol rose X.25 PLP layer
  1273. ipv4 IP version 4 x25 X.25 protocol
  1274. ipx IPX token-ring IBM token ring
  1275. bridge Bridging decnet DEC net
  1276. ipv6 IP version 6
  1277. ..............................................................................
  1278. We will concentrate on IP networking here. Since AX15, X.25, and DEC Net are
  1279. only minor players in the Linux world, we'll skip them in this chapter. You'll
  1280. find some short info on Appletalk and IPX further on in this chapter. Review
  1281. the online documentation and the kernel source to get a detailed view of the
  1282. parameters for those protocols. In this section we'll discuss the
  1283. subdirectories printed in bold letters in the table above. As default values
  1284. are suitable for most needs, there is no need to change these values.
  1285. /proc/sys/net/core - Network core options
  1286. -----------------------------------------
  1287. rmem_default
  1288. ------------
  1289. The default setting of the socket receive buffer in bytes.
  1290. rmem_max
  1291. --------
  1292. The maximum receive socket buffer size in bytes.
  1293. wmem_default
  1294. ------------
  1295. The default setting (in bytes) of the socket send buffer.
  1296. wmem_max
  1297. --------
  1298. The maximum send socket buffer size in bytes.
  1299. message_burst and message_cost
  1300. ------------------------------
  1301. These parameters are used to limit the warning messages written to the kernel
  1302. log from the networking code. They enforce a rate limit to make a
  1303. denial-of-service attack impossible. A higher message_cost factor, results in
  1304. fewer messages that will be written. Message_burst controls when messages will
  1305. be dropped. The default settings limit warning messages to one every five
  1306. seconds.
  1307. warnings
  1308. --------
  1309. This controls console messages from the networking stack that can occur because
  1310. of problems on the network like duplicate address or bad checksums. Normally,
  1311. this should be enabled, but if the problem persists the messages can be
  1312. disabled.
  1313. netdev_max_backlog
  1314. ------------------
  1315. Maximum number of packets, queued on the INPUT side, when the interface
  1316. receives packets faster than kernel can process them.
  1317. optmem_max
  1318. ----------
  1319. Maximum ancillary buffer size allowed per socket. Ancillary data is a sequence
  1320. of struct cmsghdr structures with appended data.
  1321. /proc/sys/net/unix - Parameters for Unix domain sockets
  1322. -------------------------------------------------------
  1323. There are only two files in this subdirectory. They control the delays for
  1324. deleting and destroying socket descriptors.
  1325. 2.8 /proc/sys/net/ipv4 - IPV4 settings
  1326. --------------------------------------
  1327. IP version 4 is still the most used protocol in Unix networking. It will be
  1328. replaced by IP version 6 in the next couple of years, but for the moment it's
  1329. the de facto standard for the internet and is used in most networking
  1330. environments around the world. Because of the importance of this protocol,
  1331. we'll have a deeper look into the subtree controlling the behavior of the IPv4
  1332. subsystem of the Linux kernel.
  1333. Let's start with the entries in /proc/sys/net/ipv4.
  1334. ICMP settings
  1335. -------------
  1336. icmp_echo_ignore_all and icmp_echo_ignore_broadcasts
  1337. ----------------------------------------------------
  1338. Turn on (1) or off (0), if the kernel should ignore all ICMP ECHO requests, or
  1339. just those to broadcast and multicast addresses.
  1340. Please note that if you accept ICMP echo requests with a broadcast/multi\-cast
  1341. destination address your network may be used as an exploder for denial of
  1342. service packet flooding attacks to other hosts.
  1343. icmp_destunreach_rate, icmp_echoreply_rate, icmp_paramprob_rate and icmp_timeexeed_rate
  1344. ---------------------------------------------------------------------------------------
  1345. Sets limits for sending ICMP packets to specific targets. A value of zero
  1346. disables all limiting. Any positive value sets the maximum package rate in
  1347. hundredth of a second (on Intel systems).
  1348. IP settings
  1349. -----------
  1350. ip_autoconfig
  1351. -------------
  1352. This file contains the number one if the host received its IP configuration by
  1353. RARP, BOOTP, DHCP or a similar mechanism. Otherwise it is zero.
  1354. ip_default_ttl
  1355. --------------
  1356. TTL (Time To Live) for IPv4 interfaces. This is simply the maximum number of
  1357. hops a packet may travel.
  1358. ip_dynaddr
  1359. ----------
  1360. Enable dynamic socket address rewriting on interface address change. This is
  1361. useful for dialup interface with changing IP addresses.
  1362. ip_forward
  1363. ----------
  1364. Enable or disable forwarding of IP packages between interfaces. Changing this
  1365. value resets all other parameters to their default values. They differ if the
  1366. kernel is configured as host or router.
  1367. ip_local_port_range
  1368. -------------------
  1369. Range of ports used by TCP and UDP to choose the local port. Contains two
  1370. numbers, the first number is the lowest port, the second number the highest
  1371. local port. Default is 1024-4999. Should be changed to 32768-61000 for
  1372. high-usage systems.
  1373. ip_no_pmtu_disc
  1374. ---------------
  1375. Global switch to turn path MTU discovery off. It can also be set on a per
  1376. socket basis by the applications or on a per route basis.
  1377. ip_masq_debug
  1378. -------------
  1379. Enable/disable debugging of IP masquerading.
  1380. IP fragmentation settings
  1381. -------------------------
  1382. ipfrag_high_trash and ipfrag_low_trash
  1383. --------------------------------------
  1384. Maximum memory used to reassemble IP fragments. When ipfrag_high_thresh bytes
  1385. of memory is allocated for this purpose, the fragment handler will toss
  1386. packets until ipfrag_low_thresh is reached.
  1387. ipfrag_time
  1388. -----------
  1389. Time in seconds to keep an IP fragment in memory.
  1390. TCP settings
  1391. ------------
  1392. tcp_ecn
  1393. -------
  1394. This file controls the use of the ECN bit in the IPv4 headers. This is a new
  1395. feature about Explicit Congestion Notification, but some routers and firewalls
  1396. block traffic that has this bit set, so it could be necessary to echo 0 to
  1397. /proc/sys/net/ipv4/tcp_ecn if you want to talk to these sites. For more info
  1398. you could read RFC2481.
  1399. tcp_retrans_collapse
  1400. --------------------
  1401. Bug-to-bug compatibility with some broken printers. On retransmit, try to send
  1402. larger packets to work around bugs in certain TCP stacks. Can be turned off by
  1403. setting it to zero.
  1404. tcp_keepalive_probes
  1405. --------------------
  1406. Number of keep alive probes TCP sends out, until it decides that the
  1407. connection is broken.
  1408. tcp_keepalive_time
  1409. ------------------
  1410. How often TCP sends out keep alive messages, when keep alive is enabled. The
  1411. default is 2 hours.
  1412. tcp_syn_retries
  1413. ---------------
  1414. Number of times initial SYNs for a TCP connection attempt will be
  1415. retransmitted. Should not be higher than 255. This is only the timeout for
  1416. outgoing connections, for incoming connections the number of retransmits is
  1417. defined by tcp_retries1.
  1418. tcp_sack
  1419. --------
  1420. Enable select acknowledgments after RFC2018.
  1421. tcp_timestamps
  1422. --------------
  1423. Enable timestamps as defined in RFC1323.
  1424. tcp_stdurg
  1425. ----------
  1426. Enable the strict RFC793 interpretation of the TCP urgent pointer field. The
  1427. default is to use the BSD compatible interpretation of the urgent pointer
  1428. pointing to the first byte after the urgent data. The RFC793 interpretation is
  1429. to have it point to the last byte of urgent data. Enabling this option may
  1430. lead to interoperability problems. Disabled by default.
  1431. tcp_syncookies
  1432. --------------
  1433. Only valid when the kernel was compiled with CONFIG_SYNCOOKIES. Send out
  1434. syncookies when the syn backlog queue of a socket overflows. This is to ward
  1435. off the common 'syn flood attack'. Disabled by default.
  1436. Note that the concept of a socket backlog is abandoned. This means the peer
  1437. may not receive reliable error messages from an over loaded server with
  1438. syncookies enabled.
  1439. tcp_window_scaling
  1440. ------------------
  1441. Enable window scaling as defined in RFC1323.
  1442. tcp_fin_timeout
  1443. ---------------
  1444. The length of time in seconds it takes to receive a final FIN before the
  1445. socket is always closed. This is strictly a violation of the TCP
  1446. specification, but required to prevent denial-of-service attacks.
  1447. tcp_max_ka_probes
  1448. -----------------
  1449. Indicates how many keep alive probes are sent per slow timer run. Should not
  1450. be set too high to prevent bursts.
  1451. tcp_max_syn_backlog
  1452. -------------------
  1453. Length of the per socket backlog queue. Since Linux 2.2 the backlog specified
  1454. in listen(2) only specifies the length of the backlog queue of already
  1455. established sockets. When more connection requests arrive Linux starts to drop
  1456. packets. When syncookies are enabled the packets are still answered and the
  1457. maximum queue is effectively ignored.
  1458. tcp_retries1
  1459. ------------
  1460. Defines how often an answer to a TCP connection request is retransmitted
  1461. before giving up.
  1462. tcp_retries2
  1463. ------------
  1464. Defines how often a TCP packet is retransmitted before giving up.
  1465. Interface specific settings
  1466. ---------------------------
  1467. In the directory /proc/sys/net/ipv4/conf you'll find one subdirectory for each
  1468. interface the system knows about and one directory calls all. Changes in the
  1469. all subdirectory affect all interfaces, whereas changes in the other
  1470. subdirectories affect only one interface. All directories have the same
  1471. entries:
  1472. accept_redirects
  1473. ----------------
  1474. This switch decides if the kernel accepts ICMP redirect messages or not. The
  1475. default is 'yes' if the kernel is configured for a regular host and 'no' for a
  1476. router configuration.
  1477. accept_source_route
  1478. -------------------
  1479. Should source routed packages be accepted or declined. The default is
  1480. dependent on the kernel configuration. It's 'yes' for routers and 'no' for
  1481. hosts.
  1482. bootp_relay
  1483. ~~~~~~~~~~~
  1484. Accept packets with source address 0.b.c.d with destinations not to this host
  1485. as local ones. It is supposed that a BOOTP relay daemon will catch and forward
  1486. such packets.
  1487. The default is 0, since this feature is not implemented yet (kernel version
  1488. 2.2.12).
  1489. forwarding
  1490. ----------
  1491. Enable or disable IP forwarding on this interface.
  1492. log_martians
  1493. ------------
  1494. Log packets with source addresses with no known route to kernel log.
  1495. mc_forwarding
  1496. -------------
  1497. Do multicast routing. The kernel needs to be compiled with CONFIG_MROUTE and a
  1498. multicast routing daemon is required.
  1499. proxy_arp
  1500. ---------
  1501. Does (1) or does not (0) perform proxy ARP.
  1502. rp_filter
  1503. ---------
  1504. Integer value determines if a source validation should be made. 1 means yes, 0
  1505. means no. Disabled by default, but local/broadcast address spoofing is always
  1506. on.
  1507. If you set this to 1 on a router that is the only connection for a network to
  1508. the net, it will prevent spoofing attacks against your internal networks
  1509. (external addresses can still be spoofed), without the need for additional
  1510. firewall rules.
  1511. secure_redirects
  1512. ----------------
  1513. Accept ICMP redirect messages only for gateways, listed in default gateway
  1514. list. Enabled by default.
  1515. shared_media
  1516. ------------
  1517. If it is not set the kernel does not assume that different subnets on this
  1518. device can communicate directly. Default setting is 'yes'.
  1519. send_redirects
  1520. --------------
  1521. Determines whether to send ICMP redirects to other hosts.
  1522. Routing settings
  1523. ----------------
  1524. The directory /proc/sys/net/ipv4/route contains several file to control
  1525. routing issues.
  1526. error_burst and error_cost
  1527. --------------------------
  1528. These parameters are used to limit how many ICMP destination unreachable to
  1529. send from the host in question. ICMP destination unreachable messages are
  1530. sent when we cannot reach the next hop while trying to transmit a packet.
  1531. It will also print some error messages to kernel logs if someone is ignoring
  1532. our ICMP redirects. The higher the error_cost factor is, the fewer
  1533. destination unreachable and error messages will be let through. Error_burst
  1534. controls when destination unreachable messages and error messages will be
  1535. dropped. The default settings limit warning messages to five every second.
  1536. flush
  1537. -----
  1538. Writing to this file results in a flush of the routing cache.
  1539. gc_elasticity, gc_interval, gc_min_interval_ms, gc_timeout, gc_thresh
  1540. ---------------------------------------------------------------------
  1541. Values to control the frequency and behavior of the garbage collection
  1542. algorithm for the routing cache. gc_min_interval is deprecated and replaced
  1543. by gc_min_interval_ms.
  1544. max_size
  1545. --------
  1546. Maximum size of the routing cache. Old entries will be purged once the cache
  1547. reached has this size.
  1548. redirect_load, redirect_number
  1549. ------------------------------
  1550. Factors which determine if more ICPM redirects should be sent to a specific
  1551. host. No redirects will be sent once the load limit or the maximum number of
  1552. redirects has been reached.
  1553. redirect_silence
  1554. ----------------
  1555. Timeout for redirects. After this period redirects will be sent again, even if
  1556. this has been stopped, because the load or number limit has been reached.
  1557. Network Neighbor handling
  1558. -------------------------
  1559. Settings about how to handle connections with direct neighbors (nodes attached
  1560. to the same link) can be found in the directory /proc/sys/net/ipv4/neigh.
  1561. As we saw it in the conf directory, there is a default subdirectory which
  1562. holds the default values, and one directory for each interface. The contents
  1563. of the directories are identical, with the single exception that the default
  1564. settings contain additional options to set garbage collection parameters.
  1565. In the interface directories you'll find the following entries:
  1566. base_reachable_time, base_reachable_time_ms
  1567. -------------------------------------------
  1568. A base value used for computing the random reachable time value as specified
  1569. in RFC2461.
  1570. Expression of base_reachable_time, which is deprecated, is in seconds.
  1571. Expression of base_reachable_time_ms is in milliseconds.
  1572. retrans_time, retrans_time_ms
  1573. -----------------------------
  1574. The time between retransmitted Neighbor Solicitation messages.
  1575. Used for address resolution and to determine if a neighbor is
  1576. unreachable.
  1577. Expression of retrans_time, which is deprecated, is in 1/100 seconds (for
  1578. IPv4) or in jiffies (for IPv6).
  1579. Expression of retrans_time_ms is in milliseconds.
  1580. unres_qlen
  1581. ----------
  1582. Maximum queue length for a pending arp request - the number of packets which
  1583. are accepted from other layers while the ARP address is still resolved.
  1584. anycast_delay
  1585. -------------
  1586. Maximum for random delay of answers to neighbor solicitation messages in
  1587. jiffies (1/100 sec). Not yet implemented (Linux does not have anycast support
  1588. yet).
  1589. ucast_solicit
  1590. -------------
  1591. Maximum number of retries for unicast solicitation.
  1592. mcast_solicit
  1593. -------------
  1594. Maximum number of retries for multicast solicitation.
  1595. delay_first_probe_time
  1596. ----------------------
  1597. Delay for the first time probe if the neighbor is reachable. (see
  1598. gc_stale_time)
  1599. locktime
  1600. --------
  1601. An ARP/neighbor entry is only replaced with a new one if the old is at least
  1602. locktime old. This prevents ARP cache thrashing.
  1603. proxy_delay
  1604. -----------
  1605. Maximum time (real time is random [0..proxytime]) before answering to an ARP
  1606. request for which we have an proxy ARP entry. In some cases, this is used to
  1607. prevent network flooding.
  1608. proxy_qlen
  1609. ----------
  1610. Maximum queue length of the delayed proxy arp timer. (see proxy_delay).
  1611. app_solicit
  1612. ----------
  1613. Determines the number of requests to send to the user level ARP daemon. Use 0
  1614. to turn off.
  1615. gc_stale_time
  1616. -------------
  1617. Determines how often to check for stale ARP entries. After an ARP entry is
  1618. stale it will be resolved again (which is useful when an IP address migrates
  1619. to another machine). When ucast_solicit is greater than 0 it first tries to
  1620. send an ARP packet directly to the known host When that fails and
  1621. mcast_solicit is greater than 0, an ARP request is broadcasted.
  1622. 2.9 Appletalk
  1623. -------------
  1624. The /proc/sys/net/appletalk directory holds the Appletalk configuration data
  1625. when Appletalk is loaded. The configurable parameters are:
  1626. aarp-expiry-time
  1627. ----------------
  1628. The amount of time we keep an ARP entry before expiring it. Used to age out
  1629. old hosts.
  1630. aarp-resolve-time
  1631. -----------------
  1632. The amount of time we will spend trying to resolve an Appletalk address.
  1633. aarp-retransmit-limit
  1634. ---------------------
  1635. The number of times we will retransmit a query before giving up.
  1636. aarp-tick-time
  1637. --------------
  1638. Controls the rate at which expires are checked.
  1639. The directory /proc/net/appletalk holds the list of active Appletalk sockets
  1640. on a machine.
  1641. The fields indicate the DDP type, the local address (in network:node format)
  1642. the remote address, the size of the transmit pending queue, the size of the
  1643. received queue (bytes waiting for applications to read) the state and the uid
  1644. owning the socket.
  1645. /proc/net/atalk_iface lists all the interfaces configured for appletalk.It
  1646. shows the name of the interface, its Appletalk address, the network range on
  1647. that address (or network number for phase 1 networks), and the status of the
  1648. interface.
  1649. /proc/net/atalk_route lists each known network route. It lists the target
  1650. (network) that the route leads to, the router (may be directly connected), the
  1651. route flags, and the device the route is using.
  1652. 2.10 IPX
  1653. --------
  1654. The IPX protocol has no tunable values in proc/sys/net.
  1655. The IPX protocol does, however, provide proc/net/ipx. This lists each IPX
  1656. socket giving the local and remote addresses in Novell format (that is
  1657. network:node:port). In accordance with the strange Novell tradition,
  1658. everything but the port is in hex. Not_Connected is displayed for sockets that
  1659. are not tied to a specific remote address. The Tx and Rx queue sizes indicate
  1660. the number of bytes pending for transmission and reception. The state
  1661. indicates the state the socket is in and the uid is the owning uid of the
  1662. socket.
  1663. The /proc/net/ipx_interface file lists all IPX interfaces. For each interface
  1664. it gives the network number, the node number, and indicates if the network is
  1665. the primary network. It also indicates which device it is bound to (or
  1666. Internal for internal networks) and the Frame Type if appropriate. Linux
  1667. supports 802.3, 802.2, 802.2 SNAP and DIX (Blue Book) ethernet framing for
  1668. IPX.
  1669. The /proc/net/ipx_route table holds a list of IPX routes. For each route it
  1670. gives the destination network, the router node (or Directly) and the network
  1671. address of the router (or Connected) for internal networks.
  1672. 2.11 /proc/sys/fs/mqueue - POSIX message queues filesystem
  1673. ----------------------------------------------------------
  1674. The "mqueue" filesystem provides the necessary kernel features to enable the
  1675. creation of a user space library that implements the POSIX message queues
  1676. API (as noted by the MSG tag in the POSIX 1003.1-2001 version of the System
  1677. Interfaces specification.)
  1678. The "mqueue" filesystem contains values for determining/setting the amount of
  1679. resources used by the file system.
  1680. /proc/sys/fs/mqueue/queues_max is a read/write file for setting/getting the
  1681. maximum number of message queues allowed on the system.
  1682. /proc/sys/fs/mqueue/msg_max is a read/write file for setting/getting the
  1683. maximum number of messages in a queue value. In fact it is the limiting value
  1684. for another (user) limit which is set in mq_open invocation. This attribute of
  1685. a queue must be less or equal then msg_max.
  1686. /proc/sys/fs/mqueue/msgsize_max is a read/write file for setting/getting the
  1687. maximum message size value (it is every message queue's attribute set during
  1688. its creation).
  1689. 2.12 /proc/<pid>/oom_adj - Adjust the oom-killer score
  1690. ------------------------------------------------------
  1691. This file can be used to adjust the score used to select which processes
  1692. should be killed in an out-of-memory situation. Giving it a high score will
  1693. increase the likelihood of this process being killed by the oom-killer. Valid
  1694. values are in the range -16 to +15, plus the special value -17, which disables
  1695. oom-killing altogether for this process.
  1696. 2.13 /proc/<pid>/oom_score - Display current oom-killer score
  1697. -------------------------------------------------------------
  1698. ------------------------------------------------------------------------------
  1699. This file can be used to check the current score used by the oom-killer is for
  1700. any given <pid>. Use it together with /proc/<pid>/oom_adj to tune which
  1701. process should be killed in an out-of-memory situation.
  1702. ------------------------------------------------------------------------------
  1703. Summary
  1704. ------------------------------------------------------------------------------
  1705. Certain aspects of kernel behavior can be modified at runtime, without the
  1706. need to recompile the kernel, or even to reboot the system. The files in the
  1707. /proc/sys tree can not only be read, but also modified. You can use the echo
  1708. command to write value into these files, thereby changing the default settings
  1709. of the kernel.
  1710. ------------------------------------------------------------------------------
  1711. 2.14 /proc/<pid>/io - Display the IO accounting fields
  1712. -------------------------------------------------------
  1713. This file contains IO statistics for each running process
  1714. Example
  1715. -------
  1716. test:/tmp # dd if=/dev/zero of=/tmp/test.dat &
  1717. [1] 3828
  1718. test:/tmp # cat /proc/3828/io
  1719. rchar: 323934931
  1720. wchar: 323929600
  1721. syscr: 632687
  1722. syscw: 632675
  1723. read_bytes: 0
  1724. write_bytes: 323932160
  1725. cancelled_write_bytes: 0
  1726. Description
  1727. -----------
  1728. rchar
  1729. -----
  1730. I/O counter: chars read
  1731. The number of bytes which this task has caused to be read from storage. This
  1732. is simply the sum of bytes which this process passed to read() and pread().
  1733. It includes things like tty IO and it is unaffected by whether or not actual
  1734. physical disk IO was required (the read might have been satisfied from
  1735. pagecache)
  1736. wchar
  1737. -----
  1738. I/O counter: chars written
  1739. The number of bytes which this task has caused, or shall cause to be written
  1740. to disk. Similar caveats apply here as with rchar.
  1741. syscr
  1742. -----
  1743. I/O counter: read syscalls
  1744. Attempt to count the number of read I/O operations, i.e. syscalls like read()
  1745. and pread().
  1746. syscw
  1747. -----
  1748. I/O counter: write syscalls
  1749. Attempt to count the number of write I/O operations, i.e. syscalls like
  1750. write() and pwrite().
  1751. read_bytes
  1752. ----------
  1753. I/O counter: bytes read
  1754. Attempt to count the number of bytes which this process really did cause to
  1755. be fetched from the storage layer. Done at the submit_bio() level, so it is
  1756. accurate for block-backed filesystems. <please add status regarding NFS and
  1757. CIFS at a later time>
  1758. write_bytes
  1759. -----------
  1760. I/O counter: bytes written
  1761. Attempt to count the number of bytes which this process caused to be sent to
  1762. the storage layer. This is done at page-dirtying time.
  1763. cancelled_write_bytes
  1764. ---------------------
  1765. The big inaccuracy here is truncate. If a process writes 1MB to a file and
  1766. then deletes the file, it will in fact perform no writeout. But it will have
  1767. been accounted as having caused 1MB of write.
  1768. In other words: The number of bytes which this process caused to not happen,
  1769. by truncating pagecache. A task can cause "negative" IO too. If this task
  1770. truncates some dirty pagecache, some IO which another task has been accounted
  1771. for (in it's write_bytes) will not be happening. We _could_ just subtract that
  1772. from the truncating task's write_bytes, but there is information loss in doing
  1773. that.
  1774. Note
  1775. ----
  1776. At its current implementation state, this is a bit racy on 32-bit machines: if
  1777. process A reads process B's /proc/pid/io while process B is updating one of
  1778. those 64-bit counters, process A could see an intermediate result.
  1779. More information about this can be found within the taskstats documentation in
  1780. Documentation/accounting.
  1781. 2.15 /proc/<pid>/coredump_filter - Core dump filtering settings
  1782. ---------------------------------------------------------------
  1783. When a process is dumped, all anonymous memory is written to a core file as
  1784. long as the size of the core file isn't limited. But sometimes we don't want
  1785. to dump some memory segments, for example, huge shared memory. Conversely,
  1786. sometimes we want to save file-backed memory segments into a core file, not
  1787. only the individual files.
  1788. /proc/<pid>/coredump_filter allows you to customize which memory segments
  1789. will be dumped when the <pid> process is dumped. coredump_filter is a bitmask
  1790. of memory types. If a bit of the bitmask is set, memory segments of the
  1791. corresponding memory type are dumped, otherwise they are not dumped.
  1792. The following 4 memory types are supported:
  1793. - (bit 0) anonymous private memory
  1794. - (bit 1) anonymous shared memory
  1795. - (bit 2) file-backed private memory
  1796. - (bit 3) file-backed shared memory
  1797. Note that MMIO pages such as frame buffer are never dumped and vDSO pages
  1798. are always dumped regardless of the bitmask status.
  1799. Default value of coredump_filter is 0x3; this means all anonymous memory
  1800. segments are dumped.
  1801. If you don't want to dump all shared memory segments attached to pid 1234,
  1802. write 1 to the process's proc file.
  1803. $ echo 0x1 > /proc/1234/coredump_filter
  1804. When a new process is created, the process inherits the bitmask status from its
  1805. parent. It is useful to set up coredump_filter before the program runs.
  1806. For example:
  1807. $ echo 0x7 > /proc/self/coredump_filter
  1808. $ ./some_program
  1809. 2.16 /proc/<pid>/mountinfo - Information about mounts
  1810. --------------------------------------------------------
  1811. This file contains lines of the form:
  1812. 36 35 98:0 /mnt1 /mnt2 rw,noatime master:1 - ext3 /dev/root rw,errors=continue
  1813. (1)(2)(3) (4) (5) (6) (7) (8) (9) (10) (11)
  1814. (1) mount ID: unique identifier of the mount (may be reused after umount)
  1815. (2) parent ID: ID of parent (or of self for the top of the mount tree)
  1816. (3) major:minor: value of st_dev for files on filesystem
  1817. (4) root: root of the mount within the filesystem
  1818. (5) mount point: mount point relative to the process's root
  1819. (6) mount options: per mount options
  1820. (7) optional fields: zero or more fields of the form "tag[:value]"
  1821. (8) separator: marks the end of the optional fields
  1822. (9) filesystem type: name of filesystem of the form "type[.subtype]"
  1823. (10) mount source: filesystem specific information or "none"
  1824. (11) super options: per super block options
  1825. Parsers should ignore all unrecognised optional fields. Currently the
  1826. possible optional fields are:
  1827. shared:X mount is shared in peer group X
  1828. master:X mount is slave to peer group X
  1829. propagate_from:X mount is slave and receives propagation from peer group X (*)
  1830. unbindable mount is unbindable
  1831. (*) X is the closest dominant peer group under the process's root. If
  1832. X is the immediate master of the mount, or if there's no dominant peer
  1833. group under the same root, then only the "master:X" field is present
  1834. and not the "propagate_from:X" field.
  1835. For more information on mount propagation see:
  1836. Documentation/filesystems/sharedsubtree.txt
  1837. ------------------------------------------------------------------------------