From 6c27b037971a7225565eeb744e3d7ab6bd9fafe8 Mon Sep 17 00:00:00 2001 From: Muchun Song Date: Sat, 30 Oct 2021 15:51:26 +0800 Subject: [PATCH] mm: memcontrol: move PageMemcgKmem to the scope of CONFIG_MEMCG_KMEM mainline inclusion from mainline-v5.13-rc1 commit bd290e1e75d8a8b2d87031b63db56ae165677870 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I4C0GB CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=bd290e1e75d8a8b2d87031b63db56ae165677870 ---------------------------------------------------------------------- The page only can be marked as kmem when CONFIG_MEMCG_KMEM is enabled. So move PageMemcgKmem() to the scope of the CONFIG_MEMCG_KMEM. As a bonus, on !CONFIG_MEMCG_KMEM build some code can be compiled out. Link: https://lkml.kernel.org/r/20210319163821.20704-8-songmuchun@bytedance.com Signed-off-by: Muchun Song Acked-by: Roman Gushchin Reviewed-by: Shakeel Butt Acked-by: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov Cc: Xiongchun Duan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Chen Huang Reviewed-by: Kefeng Wang Reviewed-by: Chen Wandun Signed-off-by: Zheng Zengkai --- include/linux/memcontrol.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 8ab981ea6c69..e6e70b3bbcee 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -536,6 +536,7 @@ static inline struct mem_cgroup *page_memcg_check(struct page *page) return (struct mem_cgroup *)(memcg_data & ~MEMCG_DATA_FLAGS_MASK); } +#ifdef CONFIG_MEMCG_KMEM /* * PageMemcgKmem - check if the page has MemcgKmem flag set * @page: a pointer to the page struct @@ -550,7 +551,6 @@ static inline bool PageMemcgKmem(struct page *page) return page->memcg_data & MEMCG_DATA_KMEM; } -#ifdef CONFIG_MEMCG_KMEM /* * page_objcgs - get the object cgroups vector associated with a page * @page: a pointer to the page struct @@ -605,6 +605,11 @@ static inline bool set_page_objcgs(struct page *page, MEMCG_DATA_OBJCGS); } #else +static inline bool PageMemcgKmem(struct page *page) +{ + return false; +} + static inline struct obj_cgroup **page_objcgs(struct page *page) { return NULL; -- GitLab