diff options
author | Sergei Rogachev <rogachevsergei@gmail.com> | 2015-02-11 18:28:34 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-11 20:06:07 -0500 |
commit | 94f759d62b2c6a9d124b0622077b1ddcfac43fb5 (patch) | |
tree | 962eb704c95c064dbfcdd59b4033f490c4ede34a /mm/page_owner.c | |
parent | 740a5ddb0e0d2ef3bd0a80ae027bf9d211b8c82d (diff) |
mm/page_owner.c: remove unnecessary stack_trace field
Page owner uses the page_ext structure to keep meta-information for every
page in the system. The structure also contains a field of type 'struct
stack_trace', page owner uses this field during invocation of the function
save_stack_trace. It is easy to notice that keeping a copy of this
structure for every page in the system is very inefficiently in terms of
memory.
The patch removes this unnecessary field of page_ext and forces page owner
to use a stack_trace structure allocated on the stack.
[akpm@linux-foundation.org: use struct initializers]
Signed-off-by: Sergei Rogachev <rogachevsergei@gmail.com>
Acked-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/page_owner.c')
-rw-r--r-- | mm/page_owner.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/mm/page_owner.c b/mm/page_owner.c index 9ab4a9b5bc09..0993f5f36b01 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c | |||
@@ -59,20 +59,19 @@ void __reset_page_owner(struct page *page, unsigned int order) | |||
59 | 59 | ||
60 | void __set_page_owner(struct page *page, unsigned int order, gfp_t gfp_mask) | 60 | void __set_page_owner(struct page *page, unsigned int order, gfp_t gfp_mask) |
61 | { | 61 | { |
62 | struct page_ext *page_ext; | 62 | struct page_ext *page_ext = lookup_page_ext(page); |
63 | struct stack_trace *trace; | 63 | struct stack_trace trace = { |
64 | 64 | .nr_entries = 0, | |
65 | page_ext = lookup_page_ext(page); | 65 | .max_entries = ARRAY_SIZE(page_ext->trace_entries), |
66 | .entries = &page_ext->trace_entries[0], | ||
67 | .skip = 3, | ||
68 | }; | ||
66 | 69 | ||
67 | trace = &page_ext->trace; | 70 | save_stack_trace(&trace); |
68 | trace->nr_entries = 0; | ||
69 | trace->max_entries = ARRAY_SIZE(page_ext->trace_entries); | ||
70 | trace->entries = &page_ext->trace_entries[0]; | ||
71 | trace->skip = 3; | ||
72 | save_stack_trace(&page_ext->trace); | ||
73 | 71 | ||
74 | page_ext->order = order; | 72 | page_ext->order = order; |
75 | page_ext->gfp_mask = gfp_mask; | 73 | page_ext->gfp_mask = gfp_mask; |
74 | page_ext->nr_entries = trace.nr_entries; | ||
76 | 75 | ||
77 | __set_bit(PAGE_EXT_OWNER, &page_ext->flags); | 76 | __set_bit(PAGE_EXT_OWNER, &page_ext->flags); |
78 | } | 77 | } |
@@ -84,6 +83,10 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, | |||
84 | int ret; | 83 | int ret; |
85 | int pageblock_mt, page_mt; | 84 | int pageblock_mt, page_mt; |
86 | char *kbuf; | 85 | char *kbuf; |
86 | struct stack_trace trace = { | ||
87 | .nr_entries = page_ext->nr_entries, | ||
88 | .entries = &page_ext->trace_entries[0], | ||
89 | }; | ||
87 | 90 | ||
88 | kbuf = kmalloc(count, GFP_KERNEL); | 91 | kbuf = kmalloc(count, GFP_KERNEL); |
89 | if (!kbuf) | 92 | if (!kbuf) |
@@ -121,8 +124,7 @@ print_page_owner(char __user *buf, size_t count, unsigned long pfn, | |||
121 | if (ret >= count) | 124 | if (ret >= count) |
122 | goto err; | 125 | goto err; |
123 | 126 | ||
124 | ret += snprint_stack_trace(kbuf + ret, count - ret, | 127 | ret += snprint_stack_trace(kbuf + ret, count - ret, &trace, 0); |
125 | &page_ext->trace, 0); | ||
126 | if (ret >= count) | 128 | if (ret >= count) |
127 | goto err; | 129 | goto err; |
128 | 130 | ||