1 From be6c8982e4ab9a41907555f601b711a7e2a17d4c Mon Sep 17 00:00:00 2001
2 From: Zhou Guanghui <zhouguanghui1@huawei.com>
3 Date: Fri, 12 Mar 2021 21:08:30 -0800
4 Subject: mm/memcg: rename mem_cgroup_split_huge_fixup to split_page_memcg and add nr_pages argument
6 From: Zhou Guanghui <zhouguanghui1@huawei.com>
8 commit be6c8982e4ab9a41907555f601b711a7e2a17d4c upstream.
10 Rename mem_cgroup_split_huge_fixup to split_page_memcg and explicitly pass
11 in page number argument.
13 In this way, the interface name is more common and can be used by
14 potential users. In addition, the complete info(memcg and flag) of the
15 memcg needs to be set to the tail pages.
17 Link: https://lkml.kernel.org/r/20210304074053.65527-2-zhouguanghui1@huawei.com
18 Signed-off-by: Zhou Guanghui <zhouguanghui1@huawei.com>
19 Acked-by: Johannes Weiner <hannes@cmpxchg.org>
20 Reviewed-by: Zi Yan <ziy@nvidia.com>
21 Reviewed-by: Shakeel Butt <shakeelb@google.com>
22 Acked-by: Michal Hocko <mhocko@suse.com>
23 Cc: Hugh Dickins <hughd@google.com>
24 Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
25 Cc: Nicholas Piggin <npiggin@gmail.com>
26 Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
27 Cc: Hanjun Guo <guohanjun@huawei.com>
28 Cc: Tianhong Ding <dingtianhong@huawei.com>
29 Cc: Weilong Chen <chenweilong@huawei.com>
30 Cc: Rui Xiang <rui.xiang@huawei.com>
31 Cc: <stable@vger.kernel.org>
32 Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
33 Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
34 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
36 include/linux/memcontrol.h | 6 ++----
37 mm/huge_memory.c | 2 +-
38 mm/memcontrol.c | 15 ++++++---------
39 3 files changed, 9 insertions(+), 14 deletions(-)
41 --- a/include/linux/memcontrol.h
42 +++ b/include/linux/memcontrol.h
43 @@ -1072,9 +1072,7 @@ static inline void memcg_memory_event_mm
47 -#ifdef CONFIG_TRANSPARENT_HUGEPAGE
48 -void mem_cgroup_split_huge_fixup(struct page *head);
50 +void split_page_memcg(struct page *head, unsigned int nr);
52 #else /* CONFIG_MEMCG */
54 @@ -1416,7 +1414,7 @@ unsigned long mem_cgroup_soft_limit_recl
58 -static inline void mem_cgroup_split_huge_fixup(struct page *head)
59 +static inline void split_page_memcg(struct page *head, unsigned int nr)
63 --- a/mm/huge_memory.c
64 +++ b/mm/huge_memory.c
65 @@ -2465,7 +2465,7 @@ static void __split_huge_page(struct pag
68 /* complete memcg works before add pages to LRU */
69 - mem_cgroup_split_huge_fixup(head);
70 + split_page_memcg(head, nr);
72 if (PageAnon(head) && PageSwapCache(head)) {
73 swp_entry_t entry = { .val = page_private(head) };
76 @@ -3296,24 +3296,21 @@ void obj_cgroup_uncharge(struct obj_cgro
78 #endif /* CONFIG_MEMCG_KMEM */
80 -#ifdef CONFIG_TRANSPARENT_HUGEPAGE
82 - * Because page_memcg(head) is not set on compound tails, set it now.
83 + * Because page_memcg(head) is not set on tails, set it now.
85 -void mem_cgroup_split_huge_fixup(struct page *head)
86 +void split_page_memcg(struct page *head, unsigned int nr)
88 struct mem_cgroup *memcg = page_memcg(head);
91 - if (mem_cgroup_disabled())
92 + if (mem_cgroup_disabled() || !memcg)
95 - for (i = 1; i < HPAGE_PMD_NR; i++) {
96 - css_get(&memcg->css);
97 - head[i].memcg_data = (unsigned long)memcg;
99 + for (i = 1; i < nr; i++)
100 + head[i].memcg_data = head->memcg_data;
101 + css_get_many(&memcg->css, nr - 1);
103 -#endif /* CONFIG_TRANSPARENT_HUGEPAGE */
105 #ifdef CONFIG_MEMCG_SWAP