Skip to content

Commit dac23b0

Browse files
Michal Hockotorvalds
authored andcommitted
memcg swap: use mem_cgroup_uncharge_swap fix
Although mem_cgroup_uncharge_swap has an empty placeholder for !CONFIG_CGROUP_MEM_RES_CTLR_SWAP the definition is placed in the CONFIG_SWAP ifdef block so we are missing the same definition for !CONFIG_SWAP which implies !CONFIG_CGROUP_MEM_RES_CTLR_SWAP. This has not been an issue before, because mem_cgroup_uncharge_swap was not called from !CONFIG_SWAP context. But Hugh Dickins has a cleanup patch to call __mem_cgroup_commit_charge_swapin which is defined also for !CONFIG_SWAP. Let's move both the empty definition and declaration outside of the CONFIG_SWAP block to avoid the following compilation error: mm/memcontrol.c: In function '__mem_cgroup_commit_charge_swapin': mm/memcontrol.c:2837: error: implicit declaration of function 'mem_cgroup_uncharge_swap' if CONFIG_SWAP is disabled. Reported-by: David Rientjes <[email protected]> Signed-off-by: Michal Hocko <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Cc: Daisuke Nishimura <[email protected]> Cc: Johannes Weiner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 6ede3d8 commit dac23b0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

include/linux/swap.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,13 @@ static inline int mem_cgroup_swappiness(struct mem_cgroup *mem)
305305
return vm_swappiness;
306306
}
307307
#endif
308+
#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
309+
extern void mem_cgroup_uncharge_swap(swp_entry_t ent);
310+
#else
311+
static inline void mem_cgroup_uncharge_swap(swp_entry_t ent)
312+
{
313+
}
314+
#endif
308315
#ifdef CONFIG_SWAP
309316
/* linux/mm/page_io.c */
310317
extern int swap_readpage(struct page *);
@@ -375,13 +382,6 @@ mem_cgroup_uncharge_swapcache(struct page *page, swp_entry_t ent, bool swapout)
375382
{
376383
}
377384
#endif
378-
#ifdef CONFIG_CGROUP_MEM_RES_CTLR_SWAP
379-
extern void mem_cgroup_uncharge_swap(swp_entry_t ent);
380-
#else
381-
static inline void mem_cgroup_uncharge_swap(swp_entry_t ent)
382-
{
383-
}
384-
#endif
385385

386386
#else /* CONFIG_SWAP */
387387

0 commit comments

Comments
 (0)