diff options
author | David Rientjes <rientjes@google.com> | 2012-12-12 16:51:57 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-12 20:38:34 -0500 |
commit | 68ae564bbac8eb9ed54ddd2529b0e29ee190b355 (patch) | |
tree | 5cef83b5fa072f62091552457e7d0319ce170b98 | |
parent | 05b0afd73d04109d87f00ccd39f099e217c37263 (diff) |
mm, memcg: avoid unnecessary function call when memcg is disabled
While profiling numa/core v16 with cgroup_disable=memory on the command
line, I noticed mem_cgroup_count_vm_event() still showed up as high as
0.60% in perftop.
This occurs because the function is called extremely often even when memcg
is disabled.
To fix this, inline the check for mem_cgroup_disabled() so we avoid the
unnecessary function call if memcg is disabled.
Signed-off-by: David Rientjes <rientjes@google.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Glauber Costa <glommer@parallels.com>
Acked-by: Michal Hocko <mhocko@suse.cz>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | include/linux/memcontrol.h | 9 | ||||
-rw-r--r-- | mm/memcontrol.c | 6 |
2 files changed, 12 insertions, 3 deletions
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 11ddc7ffeba8..e98a74c0c9c0 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
@@ -181,7 +181,14 @@ unsigned long mem_cgroup_soft_limit_reclaim(struct zone *zone, int order, | |||
181 | gfp_t gfp_mask, | 181 | gfp_t gfp_mask, |
182 | unsigned long *total_scanned); | 182 | unsigned long *total_scanned); |
183 | 183 | ||
184 | void mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx); | 184 | void __mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx); |
185 | static inline void mem_cgroup_count_vm_event(struct mm_struct *mm, | ||
186 | enum vm_event_item idx) | ||
187 | { | ||
188 | if (mem_cgroup_disabled()) | ||
189 | return; | ||
190 | __mem_cgroup_count_vm_event(mm, idx); | ||
191 | } | ||
185 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 192 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
186 | void mem_cgroup_split_huge_fixup(struct page *head); | 193 | void mem_cgroup_split_huge_fixup(struct page *head); |
187 | #endif | 194 | #endif |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 49d86d06e1dd..7f0e3571df7e 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -59,6 +59,8 @@ | |||
59 | #include <trace/events/vmscan.h> | 59 | #include <trace/events/vmscan.h> |
60 | 60 | ||
61 | struct cgroup_subsys mem_cgroup_subsys __read_mostly; | 61 | struct cgroup_subsys mem_cgroup_subsys __read_mostly; |
62 | EXPORT_SYMBOL(mem_cgroup_subsys); | ||
63 | |||
62 | #define MEM_CGROUP_RECLAIM_RETRIES 5 | 64 | #define MEM_CGROUP_RECLAIM_RETRIES 5 |
63 | static struct mem_cgroup *root_mem_cgroup __read_mostly; | 65 | static struct mem_cgroup *root_mem_cgroup __read_mostly; |
64 | 66 | ||
@@ -1015,7 +1017,7 @@ void mem_cgroup_iter_break(struct mem_cgroup *root, | |||
1015 | iter != NULL; \ | 1017 | iter != NULL; \ |
1016 | iter = mem_cgroup_iter(NULL, iter, NULL)) | 1018 | iter = mem_cgroup_iter(NULL, iter, NULL)) |
1017 | 1019 | ||
1018 | void mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx) | 1020 | void __mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx) |
1019 | { | 1021 | { |
1020 | struct mem_cgroup *memcg; | 1022 | struct mem_cgroup *memcg; |
1021 | 1023 | ||
@@ -1040,7 +1042,7 @@ void mem_cgroup_count_vm_event(struct mm_struct *mm, enum vm_event_item idx) | |||
1040 | out: | 1042 | out: |
1041 | rcu_read_unlock(); | 1043 | rcu_read_unlock(); |
1042 | } | 1044 | } |
1043 | EXPORT_SYMBOL(mem_cgroup_count_vm_event); | 1045 | EXPORT_SYMBOL(__mem_cgroup_count_vm_event); |
1044 | 1046 | ||
1045 | /** | 1047 | /** |
1046 | * mem_cgroup_zone_lruvec - get the lru list vector for a zone and memcg | 1048 | * mem_cgroup_zone_lruvec - get the lru list vector for a zone and memcg |