The patch titled Subject: mm/memcg: fix device private memcg accounting has been added to the -mm tree. Its filename is mm-memcg-fix-device-private-memcg-accounting.patch This patch should soon appear at https://ozlabs.org/~akpm/mmots/broken-out/mm-memcg-fix-device-private-memcg-accounting.patch and later at https://ozlabs.org/~akpm/mmotm/broken-out/mm-memcg-fix-device-private-memcg-accounting.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Ralph Campbell <rcampbell@xxxxxxxxxx> Subject: mm/memcg: fix device private memcg accounting The code in mc_handle_swap_pte() checks for non_swap_entry() and returns NULL before checking is_device_private_entry() so device private pages are never handled. Fix this by checking for non_swap_entry() after handling device private swap PTEs. Link: https://lkml.kernel.org/r/20201009215952.2726-1-rcampbell@xxxxxxxxxx Fixes: c733a82874a7 ("mm/memcontrol: support MEMORY_DEVICE_PRIVATE") Signed-off-by: Ralph Campbell <rcampbell@xxxxxxxxxx> Cc: Johannes Weiner <hannes@xxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Vladimir Davydov <vdavydov.dev@xxxxxxxxx> Cc: Jerome Glisse <jglisse@xxxxxxxxxx> Cc: Balbir Singh <bsingharora@xxxxxxxxx> Cc: Ira Weiny <ira.weiny@xxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memcontrol.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/mm/memcontrol.c~mm-memcg-fix-device-private-memcg-accounting +++ a/mm/memcontrol.c @@ -5516,7 +5516,7 @@ static struct page *mc_handle_swap_pte(s struct page *page = NULL; swp_entry_t ent = pte_to_swp_entry(ptent); - if (!(mc.flags & MOVE_ANON) || non_swap_entry(ent)) + if (!(mc.flags & MOVE_ANON)) return NULL; /* @@ -5535,6 +5535,9 @@ static struct page *mc_handle_swap_pte(s return page; } + if (non_swap_entry(ent)) + return NULL; + /* * Because lookup_swap_cache() updates some statistics counter, * we call find_get_page() with swapper_space directly. _ Patches currently in -mm which might be from rcampbell@xxxxxxxxxx are mm-memcg-fix-device-private-memcg-accounting.patch mm-test-use-the-new-skip-macro.patch hmm-test-remove-unused-dmirror_zero_page.patch mm-move-call-to-compound_head-in-release_pages.patch mm-migrate-remove-cpages-in-migrate_vma_finalize.patch mm-migrate-remove-obsolete-comment-about-device-public.patch