Skip to content

Commit

Permalink
mm/memcg: rename mem_cgroup_split_huge_fixup to split_page_memcg and …
Browse files Browse the repository at this point in the history
…add nr_pages argument

Rename mem_cgroup_split_huge_fixup to split_page_memcg and explicitly pass
in page number argument.

In this way, the interface name is more common and can be used by
potential users.  In addition, the complete info(memcg and flag) of the
memcg needs to be set to the tail pages.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Zhou Guanghui <[email protected]>
Acked-by: Johannes Weiner <[email protected]>
Reviewed-by: Zi Yan <[email protected]>
Reviewed-by: Shakeel Butt <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: "Kirill A. Shutemov" <[email protected]>
Cc: Nicholas Piggin <[email protected]>
Cc: Kefeng Wang <[email protected]>
Cc: Hanjun Guo <[email protected]>
Cc: Tianhong Ding <[email protected]>
Cc: Weilong Chen <[email protected]>
Cc: Rui Xiang <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Zhou Guanghui authored and torvalds committed Mar 13, 2021
1 parent 61bf318 commit be6c898
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
6 changes: 2 additions & 4 deletions include/linux/memcontrol.h
Original file line number Diff line number Diff line change
Expand Up @@ -1061,9 +1061,7 @@ static inline void memcg_memory_event_mm(struct mm_struct *mm,
rcu_read_unlock();
}

#ifdef CONFIG_TRANSPARENT_HUGEPAGE
void mem_cgroup_split_huge_fixup(struct page *head);
#endif
void split_page_memcg(struct page *head, unsigned int nr);

#else /* CONFIG_MEMCG */

Expand Down Expand Up @@ -1400,7 +1398,7 @@ unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
return 0;
}

static inline void mem_cgroup_split_huge_fixup(struct page *head)
static inline void split_page_memcg(struct page *head, unsigned int nr)
{
}

Expand Down
2 changes: 1 addition & 1 deletion mm/huge_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -2467,7 +2467,7 @@ static void __split_huge_page(struct page *page, struct list_head *list,
int i;

/* complete memcg works before add pages to LRU */
mem_cgroup_split_huge_fixup(head);
split_page_memcg(head, nr);

if (PageAnon(head) && PageSwapCache(head)) {
swp_entry_t entry = { .val = page_private(head) };
Expand Down
15 changes: 6 additions & 9 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -3287,24 +3287,21 @@ void obj_cgroup_uncharge(struct obj_cgroup *objcg, size_t size)

#endif /* CONFIG_MEMCG_KMEM */

#ifdef CONFIG_TRANSPARENT_HUGEPAGE
/*
* Because page_memcg(head) is not set on compound tails, set it now.
* Because page_memcg(head) is not set on tails, set it now.
*/
void mem_cgroup_split_huge_fixup(struct page *head)
void split_page_memcg(struct page *head, unsigned int nr)
{
struct mem_cgroup *memcg = page_memcg(head);
int i;

if (mem_cgroup_disabled())
if (mem_cgroup_disabled() || !memcg)
return;

for (i = 1; i < HPAGE_PMD_NR; i++) {
css_get(&memcg->css);
head[i].memcg_data = (unsigned long)memcg;
}
for (i = 1; i < nr; i++)
head[i].memcg_data = head->memcg_data;
css_get_many(&memcg->css, nr - 1);
}
#endif /* CONFIG_TRANSPARENT_HUGEPAGE */

#ifdef CONFIG_MEMCG_SWAP
/**
Expand Down

0 comments on commit be6c898

Please sign in to comment.