diff options
Diffstat (limited to 'Documentation/kmemleak.txt')
-rw-r--r-- | Documentation/kmemleak.txt | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/Documentation/kmemleak.txt b/Documentation/kmemleak.txt index b6e39739a36d..a7563ec4ea7b 100644 --- a/Documentation/kmemleak.txt +++ b/Documentation/kmemleak.txt | |||
@@ -11,9 +11,7 @@ with the difference that the orphan objects are not freed but only | |||
11 | reported via /sys/kernel/debug/kmemleak. A similar method is used by the | 11 | reported via /sys/kernel/debug/kmemleak. A similar method is used by the |
12 | Valgrind tool (memcheck --leak-check) to detect the memory leaks in | 12 | Valgrind tool (memcheck --leak-check) to detect the memory leaks in |
13 | user-space applications. | 13 | user-space applications. |
14 | 14 | Kmemleak is supported on x86, arm, powerpc, sparc, sh, microblaze, ppc, mips, s390, metag and tile. | |
15 | Please check DEBUG_KMEMLEAK dependencies in lib/Kconfig.debug for supported | ||
16 | architectures. | ||
17 | 15 | ||
18 | Usage | 16 | Usage |
19 | ----- | 17 | ----- |
@@ -53,7 +51,8 @@ Memory scanning parameters can be modified at run-time by writing to the | |||
53 | (default 600, 0 to stop the automatic scanning) | 51 | (default 600, 0 to stop the automatic scanning) |
54 | scan - trigger a memory scan | 52 | scan - trigger a memory scan |
55 | clear - clear list of current memory leak suspects, done by | 53 | clear - clear list of current memory leak suspects, done by |
56 | marking all current reported unreferenced objects grey | 54 | marking all current reported unreferenced objects grey, |
55 | or free all kmemleak objects if kmemleak has been disabled. | ||
57 | dump=<addr> - dump information about the object found at <addr> | 56 | dump=<addr> - dump information about the object found at <addr> |
58 | 57 | ||
59 | Kmemleak can also be disabled at boot-time by passing "kmemleak=off" on | 58 | Kmemleak can also be disabled at boot-time by passing "kmemleak=off" on |
@@ -68,7 +67,7 @@ Basic Algorithm | |||
68 | 67 | ||
69 | The memory allocations via kmalloc, vmalloc, kmem_cache_alloc and | 68 | The memory allocations via kmalloc, vmalloc, kmem_cache_alloc and |
70 | friends are traced and the pointers, together with additional | 69 | friends are traced and the pointers, together with additional |
71 | information like size and stack trace, are stored in a prio search tree. | 70 | information like size and stack trace, are stored in a rbtree. |
72 | The corresponding freeing function calls are tracked and the pointers | 71 | The corresponding freeing function calls are tracked and the pointers |
73 | removed from the kmemleak data structures. | 72 | removed from the kmemleak data structures. |
74 | 73 | ||
@@ -84,7 +83,7 @@ The scanning algorithm steps: | |||
84 | 1. mark all objects as white (remaining white objects will later be | 83 | 1. mark all objects as white (remaining white objects will later be |
85 | considered orphan) | 84 | considered orphan) |
86 | 2. scan the memory starting with the data section and stacks, checking | 85 | 2. scan the memory starting with the data section and stacks, checking |
87 | the values against the addresses stored in the prio search tree. If | 86 | the values against the addresses stored in the rbtree. If |
88 | a pointer to a white object is found, the object is added to the | 87 | a pointer to a white object is found, the object is added to the |
89 | gray list | 88 | gray list |
90 | 3. scan the gray objects for matching addresses (some white objects | 89 | 3. scan the gray objects for matching addresses (some white objects |
@@ -120,6 +119,18 @@ Then as usual to get your report with: | |||
120 | 119 | ||
121 | # cat /sys/kernel/debug/kmemleak | 120 | # cat /sys/kernel/debug/kmemleak |
122 | 121 | ||
122 | Freeing kmemleak internal objects | ||
123 | --------------------------------- | ||
124 | |||
125 | To allow access to previosuly found memory leaks after kmemleak has been | ||
126 | disabled by the user or due to an fatal error, internal kmemleak objects | ||
127 | won't be freed when kmemleak is disabled, and those objects may occupy | ||
128 | a large part of physical memory. | ||
129 | |||
130 | In this situation, you may reclaim memory with: | ||
131 | |||
132 | # echo clear > /sys/kernel/debug/kmemleak | ||
133 | |||
123 | Kmemleak API | 134 | Kmemleak API |
124 | ------------ | 135 | ------------ |
125 | 136 | ||