aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/vm
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-13 16:00:36 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-13 16:00:36 -0500
commit78a45c6f067824cf5d0a9fedea7339ac2e28603c (patch)
treeb4f78c8b6b9059ddace0a18c11629b8d2045f793 /Documentation/vm
parentf96fe225677b3efb74346ebd56fafe3997b02afa (diff)
parent29d293b6007b91a4463f05bc8d0b26e0e65c5816 (diff)
Merge branch 'akpm' (second patch-bomb from Andrew)
Merge second patchbomb from Andrew Morton: - the rest of MM - misc fs fixes - add execveat() syscall - new ratelimit feature for fault-injection - decompressor updates - ipc/ updates - fallocate feature creep - fsnotify cleanups - a few other misc things * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (99 commits) cgroups: Documentation: fix trivial typos and wrong paragraph numberings parisc: percpu: update comments referring to __get_cpu_var percpu: update local_ops.txt to reflect this_cpu operations percpu: remove __get_cpu_var and __raw_get_cpu_var macros fsnotify: remove destroy_list from fsnotify_mark fsnotify: unify inode and mount marks handling fallocate: create FAN_MODIFY and IN_MODIFY events mm/cma: make kmemleak ignore CMA regions slub: fix cpuset check in get_any_partial slab: fix cpuset check in fallback_alloc shmdt: use i_size_read() instead of ->i_size ipc/shm.c: fix overly aggressive shmdt() when calls span multiple segments ipc/msg: increase MSGMNI, remove scaling ipc/sem.c: increase SEMMSL, SEMMNI, SEMOPM ipc/sem.c: change memory barrier in sem_lock() to smp_rmb() lib/decompress.c: consistency of compress formats for kernel image decompress_bunzip2: off by one in get_next_block() usr/Kconfig: make initrd compression algorithm selection not expert fault-inject: add ratelimit option ratelimit: add initialization macro ...
Diffstat (limited to 'Documentation/vm')
-rw-r--r--Documentation/vm/page_owner.txt81
1 files changed, 81 insertions, 0 deletions
diff --git a/Documentation/vm/page_owner.txt b/Documentation/vm/page_owner.txt
new file mode 100644
index 000000000000..8f3ce9b3aa11
--- /dev/null
+++ b/Documentation/vm/page_owner.txt
@@ -0,0 +1,81 @@
1page owner: Tracking about who allocated each page
2-----------------------------------------------------------
3
4* Introduction
5
6page owner is for the tracking about who allocated each page.
7It can be used to debug memory leak or to find a memory hogger.
8When allocation happens, information about allocation such as call stack
9and order of pages is stored into certain storage for each page.
10When we need to know about status of all pages, we can get and analyze
11this information.
12
13Although we already have tracepoint for tracing page allocation/free,
14using it for analyzing who allocate each page is rather complex. We need
15to enlarge the trace buffer for preventing overlapping until userspace
16program launched. And, launched program continually dump out the trace
17buffer for later analysis and it would change system behviour with more
18possibility rather than just keeping it in memory, so bad for debugging.
19
20page owner can also be used for various purposes. For example, accurate
21fragmentation statistics can be obtained through gfp flag information of
22each page. It is already implemented and activated if page owner is
23enabled. Other usages are more than welcome.
24
25page owner is disabled in default. So, if you'd like to use it, you need
26to add "page_owner=on" into your boot cmdline. If the kernel is built
27with page owner and page owner is disabled in runtime due to no enabling
28boot option, runtime overhead is marginal. If disabled in runtime, it
29doesn't require memory to store owner information, so there is no runtime
30memory overhead. And, page owner inserts just two unlikely branches into
31the page allocator hotpath and if it returns false then allocation is
32done like as the kernel without page owner. These two unlikely branches
33would not affect to allocation performance. Following is the kernel's
34code size change due to this facility.
35
36- Without page owner
37 text data bss dec hex filename
38 40662 1493 644 42799 a72f mm/page_alloc.o
39
40- With page owner
41 text data bss dec hex filename
42 40892 1493 644 43029 a815 mm/page_alloc.o
43 1427 24 8 1459 5b3 mm/page_ext.o
44 2722 50 0 2772 ad4 mm/page_owner.o
45
46Although, roughly, 4 KB code is added in total, page_alloc.o increase by
47230 bytes and only half of it is in hotpath. Building the kernel with
48page owner and turning it on if needed would be great option to debug
49kernel memory problem.
50
51There is one notice that is caused by implementation detail. page owner
52stores information into the memory from struct page extension. This memory
53is initialized some time later than that page allocator starts in sparse
54memory system, so, until initialization, many pages can be allocated and
55they would have no owner information. To fix it up, these early allocated
56pages are investigated and marked as allocated in initialization phase.
57Although it doesn't mean that they have the right owner information,
58at least, we can tell whether the page is allocated or not,
59more accurately. On 2GB memory x86-64 VM box, 13343 early allocated pages
60are catched and marked, although they are mostly allocated from struct
61page extension feature. Anyway, after that, no page is left in
62un-tracking state.
63
64* Usage
65
661) Build user-space helper
67 cd tools/vm
68 make page_owner_sort
69
702) Enable page owner
71 Add "page_owner=on" to boot cmdline.
72
733) Do the job what you want to debug
74
754) Analyze information from page owner
76 cat /sys/kernel/debug/page_owner > page_owner_full.txt
77 grep -v ^PFN page_owner_full.txt > page_owner.txt
78 ./page_owner_sort page_owner.txt sorted_page_owner.txt
79
80 See the result about who allocated each page
81 in the sorted_page_owner.txt.