etc:users:jcmvbkbc:linux-mm
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
etc:users:jcmvbkbc:linux-mm [2009/07/13 17:16] – jcmvbkbc | etc:users:jcmvbkbc:linux-mm [2016/08/08 20:53] (current) – ↷ Page moved from users:jcmvbkbc:linux-mm to etc:users:jcmvbkbc:linux-mm kel | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Linux memory management summary ====== | ====== Linux memory management summary ====== | ||
Every part of process address space is some sort of mapping. | Every part of process address space is some sort of mapping. | ||
+ | |||
+ | |||
===== Memory accounting ===== | ===== Memory accounting ===== | ||
Line 25: | Line 27: | ||
* private_clean -- size of memory mapped only to this process and haven' | * private_clean -- size of memory mapped only to this process and haven' | ||
* private_clean -- size of memory mapped only to this process and changed; | * private_clean -- size of memory mapped only to this process and changed; | ||
- | * referenced -- size of data that were accessed | + | * referenced -- size of data that were accessed. Each physical memory page has an attribute, which may be reset by software and asserted by CPU automatically when the page is accessed. This is used to monitor memory usage activity & to recycle least recently used pages first; |
* swap -- size of region data that is currently in swap file; | * swap -- size of region data that is currently in swap file; | ||
- | * Charging memory to processes | ||
- | * total_vm | ||
==== Information sources ==== | ==== Information sources ==== | ||
+ | Quotes from linux/ | ||
+ | |||
Per-process data: | Per-process data: | ||
- | * / | + | * / |
+ | < | ||
+ | The / | ||
+ | their access permissions. | ||
+ | |||
+ | The format is: | ||
+ | |||
+ | address | ||
+ | |||
+ | 08048000-08049000 r-xp 00000000 03:00 8312 / | ||
+ | 08049000-0804a000 rw-p 00001000 03:00 8312 / | ||
+ | 0804a000-0806b000 rw-p 00000000 00:00 0 [heap] | ||
+ | a7cb1000-a7cb2000 ---p 00000000 00:00 0 | ||
+ | a7cb2000-a7eb2000 rw-p 00000000 00:00 0 | ||
+ | a7eb2000-a7eb3000 ---p 00000000 00:00 0 | ||
+ | a7eb3000-a7ed5000 rw-p 00000000 00:00 0 | ||
+ | a7ed5000-a8008000 r-xp 00000000 03:00 4222 / | ||
+ | a8008000-a800a000 r--p 00133000 03:00 4222 / | ||
+ | a800a000-a800b000 rw-p 00135000 03:00 4222 / | ||
+ | a800b000-a800e000 rw-p 00000000 00:00 0 | ||
+ | a800e000-a8022000 r-xp 00000000 03:00 14462 / | ||
+ | a8022000-a8023000 r--p 00013000 03:00 14462 / | ||
+ | a8023000-a8024000 rw-p 00014000 03:00 14462 / | ||
+ | a8024000-a8027000 rw-p 00000000 00:00 0 | ||
+ | a8027000-a8043000 r-xp 00000000 03:00 8317 / | ||
+ | a8043000-a8044000 r--p 0001b000 03:00 8317 / | ||
+ | a8044000-a8045000 rw-p 0001c000 03:00 8317 / | ||
+ | aff35000-aff4a000 rw-p 00000000 00:00 0 [stack] | ||
+ | ffffe000-fffff000 r-xp 00000000 00:00 0 [vdso] | ||
+ | |||
+ | where " | ||
+ | is a set of permissions: | ||
+ | |||
+ | r = read | ||
+ | w = write | ||
+ | x = execute | ||
+ | s = shared | ||
+ | p = private (copy on write) | ||
+ | |||
+ | " | ||
+ | " | ||
+ | with the memory region, as the case would be with BSS (uninitialized data). | ||
+ | The " | ||
+ | is not associated with a file: | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | the kernel system call handler | ||
+ | |||
+ | or if empty, the mapping is anonymous. | ||
+ | </ | ||
* / | * / | ||
+ | < | ||
+ | 08048000-080bc000 r-xp 00000000 03:02 13130 /bin/bash | ||
+ | Size: 1084 kB | ||
+ | Rss: 892 kB | ||
+ | Pss: 374 kB | ||
+ | Shared_Clean: | ||
+ | Shared_Dirty: | ||
+ | Private_Clean: | ||
+ | Private_Dirty: | ||
+ | Referenced: | ||
+ | Swap: 0 kB | ||
+ | KernelPageSize: | ||
+ | MMUPageSize: | ||
+ | </ | ||
* / | * / | ||
+ | < | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | includes data segment) | ||
+ | | ||
+ | | ||
+ | includes library text) | ||
+ | | ||
+ | </ | ||
* / | * / | ||
+ | < | ||
+ | >cat / | ||
+ | Name: cat | ||
+ | State: | ||
+ | Tgid: 5452 | ||
+ | Pid: 5452 | ||
+ | PPid: 743 | ||
+ | TracerPid: | ||
+ | Uid: 501 | ||
+ | Gid: 100 | ||
+ | FDSize: 256 | ||
+ | Groups: 100 14 16 | ||
+ | VmPeak: | ||
+ | VmSize: | ||
+ | VmLck: | ||
+ | VmHWM: | ||
+ | VmRSS: | ||
+ | VmData: | ||
+ | VmStk: | ||
+ | VmExe: | ||
+ | VmLib: | ||
+ | VmPTE: | ||
+ | Threads: | ||
+ | SigQ: | ||
+ | SigPnd: 0000000000000000 | ||
+ | ShdPnd: 0000000000000000 | ||
+ | SigBlk: 0000000000000000 | ||
+ | SigIgn: 0000000000000000 | ||
+ | SigCgt: 0000000000000000 | ||
+ | CapInh: 00000000fffffeff | ||
+ | CapPrm: 0000000000000000 | ||
+ | CapEff: 0000000000000000 | ||
+ | CapBnd: ffffffffffffffff | ||
+ | voluntary_ctxt_switches: | ||
+ | nonvoluntary_ctxt_switches: | ||
+ | </ | ||
* / | * / | ||
* / | * / | ||
Line 61: | Line 176: | ||
* Resident is what currently in physical memory; | * Resident is what currently in physical memory; | ||
* If not resident, it may be swapped or not backed by whatever storage at all. | * If not resident, it may be swapped or not backed by whatever storage at all. | ||
+ | |||
==== What to expect ==== | ==== What to expect ==== | ||
* of heap usage | * of heap usage | ||
+ | * private_dirty or swap size of [heap] region grows; | ||
+ | * size of [heap] region grows; | ||
* of file mapping | * of file mapping | ||
* of anonymous mapping | * of anonymous mapping | ||
Line 71: | Line 189: | ||
* of threads | * of threads | ||
* tls? | * tls? | ||
+ | |||
===== OOM killing ===== | ===== OOM killing ===== | ||
==== When this happens ==== | ==== When this happens ==== | ||
Line 115: | Line 234: | ||
* if (oom_adj > 0) points <<= oom_adj; //(if points == 0 before shift, points = 1)// | * if (oom_adj > 0) points <<= oom_adj; //(if points == 0 before shift, points = 1)// | ||
* if (oom_adj < 0) points >>= -oom_adj; | * if (oom_adj < 0) points >>= -oom_adj; | ||
+ | |||
+ | |||
==== How to control OOM-killer ==== | ==== How to control OOM-killer ==== | ||
Line 122: | Line 243: | ||
* vm.panic_on_oom -- panic in case of OOM, instead of trying to kill some processes; | * vm.panic_on_oom -- panic in case of OOM, instead of trying to kill some processes; | ||
* vm.oom_kill_allocating_task -- try first to kill task that issued request for memory that caused OOM condition; | * vm.oom_kill_allocating_task -- try first to kill task that issued request for memory that caused OOM condition; | ||
- | * vm.oom_dump_tasks | + | * vm.oom_dump_tasks |
* vm.would_have_oomkilled | * vm.would_have_oomkilled | ||
+ | |||
===== Memleak detection ===== | ===== Memleak detection ===== | ||
+ | |||
+ | |||
+ | |||
==== Direct memleak evidences ==== | ==== Direct memleak evidences ==== | ||
+ | $ cat / | ||
+ | |||
+ | And monitor [heap] swap+private_dirty | ||
+ | |||
+ | < | ||
+ | 08143000-bfd30000 rw-p 08143000 00:00 0 [heap] | ||
+ | Size: 3010484 kB | ||
+ | Rss: 475660 kB | ||
+ | Pss: 475660 kB | ||
+ | Shared_Clean: | ||
+ | Shared_Dirty: | ||
+ | Private_Clean: | ||
+ | Private_Dirty: | ||
+ | Referenced: | ||
+ | Swap: | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | 08143000-bfd30000 rw-p 08143000 00:00 0 [heap] | ||
+ | Size: 3010484 kB | ||
+ | Rss: 0 kB | ||
+ | Pss: 0 kB | ||
+ | Shared_Clean: | ||
+ | Shared_Dirty: | ||
+ | Private_Clean: | ||
+ | Private_Dirty: | ||
+ | Referenced: | ||
+ | Swap: 1203284 kB | ||
+ | </ |
etc/users/jcmvbkbc/linux-mm.1247490968.txt.gz · Last modified: 2009/07/13 17:16 by jcmvbkbc