mm: memcontrol: avoid unused function warning
Subsystems (3)
PATCH v2 1/1 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.
--- mm/memcontrol.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
This is the alternative to the original patch, as suggested by Michal Hocko. Andrew, please pick whichever version you like better.
mm/memcontrol.c +18 -18
@@ -4082,24 +4082,6 @@ static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)atomic_add (n, &memcg->id.ref); } -static struct mem_cgroup *mem_cgroup_id_get_online (struct mem_cgroup *memcg) -{ -while (!atomic_inc_not_zero (&memcg->id.ref)) { -/* -* The root cgroup cannot be destroyed, so it's refcount must -* always be >= 1. -*/ -if (WARN_ON_ONCE (memcg == root_mem_cgroup)) { -VM_BUG_ON (1 ); -break ; - } - memcg =parent_mem_cgroup (memcg); -if (!memcg) - memcg = root_mem_cgroup; - } -return memcg; -} -static void mem_cgroup_id_put_many (struct mem_cgroup *memcg,unsigned int n) {if (atomic_sub_and_test (n, &memcg->id.ref)) {
@@ -5821,6 +5803,24 @@ static int __init mem_cgroup_init(void)subsys_initcall (mem_cgroup_init);#ifdef CONFIG_MEMCG_SWAP +static struct mem_cgroup *mem_cgroup_id_get_online (struct mem_cgroup *memcg) +{ +while (!atomic_inc_not_zero (&memcg->id.ref)) { +/* +* The root cgroup cannot be destroyed, so it's refcount must +* always be >= 1. +*/ +if (WARN_ON_ONCE (memcg == root_mem_cgroup)) { +VM_BUG_ON (1 ); +break ; + } + memcg =parent_mem_cgroup (memcg); +if (!memcg) + memcg = root_mem_cgroup; + } +return memcg; +} +/** * mem_cgroup_swapout - transfer a memsw charge to swap * @page: page whose memsw charge to transfer
Signature · 7 lines
2.9.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Michal Hocko
maintainerQuoted 6 lines · Arnd Bergmann
A bugfix in v4.8-rc2 introduced a harmless warning when
CONFIG_MEMCG_SWAPis disabled butCONFIG_MEMCGis enabled:
mm/memcontrol.c:4085:27: error: 'mem_cgroup_id_get_online' defined but not used [-Werror=unused-function]
static structmem_cgroup*mem_cgroup_id_get_online(structmem_cgroup*memcg)
Quoted 7 lines
This moves the function inside of the #ifdef block that hides the calling function, to avoid the warning.
Signed-off-by Arnd Bergmann <[email protected]>Fixes 1f47b61fb407 ("mm: memcontrol: fix swap counter leak on swapout from offline cgroup")Acked-by Michal Hocko <[email protected]>Acked-by Vladimir Davydov <[email protected]>
Thanks a lot for respinning this Arnd!
Quoted 63 lines
--- mm/memcontrol.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)This is the alternative to the original patch, as suggested by Michal Hocko. Andrew, please pick whichever version you like better.
mm/memcontrol.c +18
-18@@ -4082,24 +4082,6 @@ static void mem_cgroup_id_get_many(struct mem_cgroup *memcg, unsigned int n)atomic_add (n, &memcg->id.ref); } -static struct mem_cgroup *mem_cgroup_id_get_online (struct mem_cgroup *memcg) -{ -while (!atomic_inc_not_zero (&memcg->id.ref)) { -/* -* The root cgroup cannot be destroyed, so it's refcount must -* always be >= 1. -*/ -if (WARN_ON_ONCE (memcg == root_mem_cgroup)) { -VM_BUG_ON (1 ); -break ; - } - memcg =parent_mem_cgroup (memcg); -if (!memcg) - memcg = root_mem_cgroup; - } -return memcg; -} -static void mem_cgroup_id_put_many (struct mem_cgroup *memcg,unsigned int n) {if (atomic_sub_and_test (n, &memcg->id.ref)) {@@ -5821,6 +5803,24 @@ static int __init mem_cgroup_init(void)subsys_initcall (mem_cgroup_init);#ifdef CONFIG_MEMCG_SWAP +static struct mem_cgroup *mem_cgroup_id_get_online (struct mem_cgroup *memcg) +{ +while (!atomic_inc_not_zero (&memcg->id.ref)) { +/* +* The root cgroup cannot be destroyed, so it's refcount must +* always be >= 1. +*/ +if (WARN_ON_ONCE (memcg == root_mem_cgroup)) { +VM_BUG_ON (1 ); +break ; + } + memcg =parent_mem_cgroup (memcg); +if (!memcg) + memcg = root_mem_cgroup; + } +return memcg; +} +/** * mem_cgroup_swapout - transfer a memsw charge to swap * @page: page whose memsw charge to transfer Signature · 1 line
2.9.0
Signature · 8 lines
Michal Hocko SUSE Labs -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 6 lines · Arnd Bergmann
A bugfix in v4.8-rc2 introduced a harmless warning when
CONFIG_MEMCG_SWAPis disabled butCONFIG_MEMCGis enabled:
mm/memcontrol.c:4085:27: error: 'mem_cgroup_id_get_online' defined but not used [-Werror=unused-function]
static structmem_cgroup*mem_cgroup_id_get_online(structmem_cgroup*memcg)
Quoted 7 lines
This moves the function inside of the #ifdef block that hides the calling function, to avoid the warning.
Signed-off-by Arnd Bergmann <[email protected]>Fixes 1f47b61fb407 ("mm: memcontrol: fix swap counter leak on swapout from offline cgroup")Acked-by Michal Hocko <[email protected]>Acked-by Vladimir Davydov <[email protected]>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>