diff options
author | Arnd Bergmann <arnd@arndb.de> | 2016-08-25 18:17:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-08-26 20:39:35 -0400 |
commit | 358c07fcc3b60ab08d77f1684de8bd81bcf49a1a (patch) | |
tree | 44aff5d640270a9a77957c340773a3c90fd399fe /mm | |
parent | b32eaf71db6085f2ba54cf3ddf688bfc858219d0 (diff) |
mm: memcontrol: avoid unused function warning
A bugfix in v4.8-rc2 introduced a harmless warning when
CONFIG_MEMCG_SWAP is disabled but CONFIG_MEMCG is enabled:
mm/memcontrol.c:4085:27: error: 'mem_cgroup_id_get_online' defined but not used [-Werror=unused-function]
static struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg)
This moves the function inside of the #ifdef block that hides the
calling function, to avoid the warning.
Fixes: 1f47b61fb407 ("mm: memcontrol: fix swap counter leak on swapout from offline cgroup")
Link: http://lkml.kernel.org/r/20160824113733.2776701-1-arnd@arndb.de
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Vladimir Davydov <vdavydov@virtuozzo.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/memcontrol.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 2ff0289ad061..9a6a51a7c416 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -4082,24 +4082,6 @@ static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n) | |||
4082 | atomic_add(n, &memcg->id.ref); | 4082 | atomic_add(n, &memcg->id.ref); |
4083 | } | 4083 | } |
4084 | 4084 | ||
4085 | static struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg) | ||
4086 | { | ||
4087 | while (!atomic_inc_not_zero(&memcg->id.ref)) { | ||
4088 | /* | ||
4089 | * The root cgroup cannot be destroyed, so it's refcount must | ||
4090 | * always be >= 1. | ||
4091 | */ | ||
4092 | if (WARN_ON_ONCE(memcg == root_mem_cgroup)) { | ||
4093 | VM_BUG_ON(1); | ||
4094 | break; | ||
4095 | } | ||
4096 | memcg = parent_mem_cgroup(memcg); | ||
4097 | if (!memcg) | ||
4098 | memcg = root_mem_cgroup; | ||
4099 | } | ||
4100 | return memcg; | ||
4101 | } | ||
4102 | |||
4103 | static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n) | 4085 | static void mem_cgroup_id_put_many(struct mem_cgroup *memcg, unsigned int n) |
4104 | { | 4086 | { |
4105 | if (atomic_sub_and_test(n, &memcg->id.ref)) { | 4087 | if (atomic_sub_and_test(n, &memcg->id.ref)) { |
@@ -5821,6 +5803,24 @@ static int __init mem_cgroup_init(void) | |||
5821 | subsys_initcall(mem_cgroup_init); | 5803 | subsys_initcall(mem_cgroup_init); |
5822 | 5804 | ||
5823 | #ifdef CONFIG_MEMCG_SWAP | 5805 | #ifdef CONFIG_MEMCG_SWAP |
5806 | static struct mem_cgroup *mem_cgroup_id_get_online(struct mem_cgroup *memcg) | ||
5807 | { | ||
5808 | while (!atomic_inc_not_zero(&memcg->id.ref)) { | ||
5809 | /* | ||
5810 | * The root cgroup cannot be destroyed, so it's refcount must | ||
5811 | * always be >= 1. | ||
5812 | */ | ||
5813 | if (WARN_ON_ONCE(memcg == root_mem_cgroup)) { | ||
5814 | VM_BUG_ON(1); | ||
5815 | break; | ||
5816 | } | ||
5817 | memcg = parent_mem_cgroup(memcg); | ||
5818 | if (!memcg) | ||
5819 | memcg = root_mem_cgroup; | ||
5820 | } | ||
5821 | return memcg; | ||
5822 | } | ||
5823 | |||
5824 | /** | 5824 | /** |
5825 | * mem_cgroup_swapout - transfer a memsw charge to swap | 5825 | * mem_cgroup_swapout - transfer a memsw charge to swap |
5826 | * @page: page whose memsw charge to transfer | 5826 | * @page: page whose memsw charge to transfer |