diff options
author | Johannes Weiner <hannes@cmpxchg.org> | 2012-01-12 20:18:40 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-01-12 23:13:06 -0500 |
commit | 00c54c0bac24bb02d2460c516da76651a7451286 (patch) | |
tree | d88356ab217fa4c119a6c11dd7f614413adc020a /mm | |
parent | cfa449461e67b60df986170eecb089831fa9e49a (diff) |
mm: page_cgroup: check page_cgroup arrays in lookup_page_cgroup() only when necessary
lookup_page_cgroup() is usually used only against pages that are used in
userspace.
The exception is the CONFIG_DEBUG_VM-only memcg check from the page
allocator: it can run on pages without page_cgroup descriptors allocated
when the pages are fed into the page allocator for the first time during
boot or memory hotplug.
Include the array check only when CONFIG_DEBUG_VM is set and save the
unnecessary check in production kernels.
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/page_cgroup.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/mm/page_cgroup.c b/mm/page_cgroup.c index f0559e049e00..e910524e5a08 100644 --- a/mm/page_cgroup.c +++ b/mm/page_cgroup.c | |||
@@ -28,9 +28,16 @@ struct page_cgroup *lookup_page_cgroup(struct page *page) | |||
28 | struct page_cgroup *base; | 28 | struct page_cgroup *base; |
29 | 29 | ||
30 | base = NODE_DATA(page_to_nid(page))->node_page_cgroup; | 30 | base = NODE_DATA(page_to_nid(page))->node_page_cgroup; |
31 | #ifdef CONFIG_DEBUG_VM | ||
32 | /* | ||
33 | * The sanity checks the page allocator does upon freeing a | ||
34 | * page can reach here before the page_cgroup arrays are | ||
35 | * allocated when feeding a range of pages to the allocator | ||
36 | * for the first time during bootup or memory hotplug. | ||
37 | */ | ||
31 | if (unlikely(!base)) | 38 | if (unlikely(!base)) |
32 | return NULL; | 39 | return NULL; |
33 | 40 | #endif | |
34 | offset = pfn - NODE_DATA(page_to_nid(page))->node_start_pfn; | 41 | offset = pfn - NODE_DATA(page_to_nid(page))->node_start_pfn; |
35 | return base + offset; | 42 | return base + offset; |
36 | } | 43 | } |
@@ -85,9 +92,16 @@ struct page_cgroup *lookup_page_cgroup(struct page *page) | |||
85 | { | 92 | { |
86 | unsigned long pfn = page_to_pfn(page); | 93 | unsigned long pfn = page_to_pfn(page); |
87 | struct mem_section *section = __pfn_to_section(pfn); | 94 | struct mem_section *section = __pfn_to_section(pfn); |
88 | 95 | #ifdef CONFIG_DEBUG_VM | |
96 | /* | ||
97 | * The sanity checks the page allocator does upon freeing a | ||
98 | * page can reach here before the page_cgroup arrays are | ||
99 | * allocated when feeding a range of pages to the allocator | ||
100 | * for the first time during bootup or memory hotplug. | ||
101 | */ | ||
89 | if (!section->page_cgroup) | 102 | if (!section->page_cgroup) |
90 | return NULL; | 103 | return NULL; |
104 | #endif | ||
91 | return section->page_cgroup + pfn; | 105 | return section->page_cgroup + pfn; |
92 | } | 106 | } |
93 | 107 | ||