]> Git Repo - linux.git/commit
mm/memcg: set memcg when splitting page
authorZhou Guanghui <[email protected]>
Sat, 13 Mar 2021 05:08:33 +0000 (21:08 -0800)
committerLinus Torvalds <[email protected]>
Sat, 13 Mar 2021 19:27:31 +0000 (11:27 -0800)
commite1baddf8475b06cc56f4bafecf9a32a124343d9f
tree234f0f728ac7575508962af8a8f8b2dbeae2576a
parentbe6c8982e4ab9a41907555f601b711a7e2a17d4c
mm/memcg: set memcg when splitting page

As described in the split_page() comment, for the non-compound high order
page, the sub-pages must be freed individually.  If the memcg of the first
page is valid, the tail pages cannot be uncharged when be freed.

For example, when alloc_pages_exact is used to allocate 1MB continuous
physical memory, 2MB is charged(kmemcg is enabled and __GFP_ACCOUNT is
set).  When make_alloc_exact free the unused 1MB and free_pages_exact free
the applied 1MB, actually, only 4KB(one page) is uncharged.

Therefore, the memcg of the tail page needs to be set when splitting a
page.

Michel:

There are at least two explicit users of __GFP_ACCOUNT with
alloc_exact_pages added recently.  See 7efe8ef274024 ("KVM: arm64:
Allocate stage-2 pgd pages with GFP_KERNEL_ACCOUNT") and c419621873713
("KVM: s390: Add memcg accounting to KVM allocations"), so this is not
just a theoretical issue.

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: Hanjun Guo <[email protected]>
Cc: Hugh Dickins <[email protected]>
Cc: Kefeng Wang <[email protected]>
Cc: "Kirill A. Shutemov" <[email protected]>
Cc: Nicholas Piggin <[email protected]>
Cc: Rui Xiang <[email protected]>
Cc: Tianhong Ding <[email protected]>
Cc: Weilong Chen <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/page_alloc.c
This page took 0.058174 seconds and 4 git commands to generate.