The patch titled Subject: ksm: reinstate memcg charge on copied pages has been added to the -mm tree. Its filename is ksm-reinstate-memcg-charge-on-copied-pages.patch
This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/ksm-reinstate-memcg-charge-on-copie... and later at http://ozlabs.org/~akpm/mmotm/broken-out/ksm-reinstate-memcg-charge-on-copie...
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: Hugh Dickins hughd@google.com Subject: ksm: reinstate memcg charge on copied pages
Patch series "mm: fixes to past from future testing".
Here's a set of independent fixes against 5.9-rc2: prompted by testing Alex Shi's "warning on !memcg" and lru_lock series, but I think fit for 5.9 - though maybe only the first for stable.
This patch (of 5):
In 5.8 some instances of memcg charging in do_swap_page() and unuse_pte() were removed, on the understanding that swap cache is now already charged at those points; but a case was missed, when ksm_might_need_to_copy() has decided it must allocate a substitute page: such pages were never charged. Fix it inside ksm_might_need_to_copy().
This was discovered by Alex Shi's prospective commit "mm/memcg: warning on !memcg after readahead page charged".
But there is a another surprise: this also fixes some rarer uncharged PageAnon cases, when KSM is configured in, but has never been activated. ksm_might_need_to_copy()'s anon_vma->root and linear_page_index() check sometimes catches a case which would need to have been copied if KSM were turned on. Or that's my optimistic interpretation (of my own old code), but it leaves some doubt as to whether everything is working as intended there - might it hint at rare anon ptes which rmap cannot find? A question not easily answered: put in the fix for missed memcg charges.
Link: http://lkml.kernel.org/r/alpine.LSU.2.11.2008301343270.5954@eggly.anvils Link: http://lkml.kernel.org/r/alpine.LSU.2.11.2008301358020.5954@eggly.anvils Fixes: 4c6355b25e8b ("mm: memcontrol: charge swapin pages on instantiation") Signed-off-by: Hugh Dickins hughd@google.com Cc: Alex Shi alex.shi@linux.alibaba.com Cc: Johannes Weiner hannes@cmpxchg.org Cc: Michal Hocko mhocko@suse.com Cc: Mike Kravetz mike.kravetz@oracle.com Cc: Shakeel Butt shakeelb@google.com Cc; Matthew Wilcox willy@infradead.org Cc: Qian Cai cai@lca.pw Cc: stable@vger.kernel.org [5.8] Signed-off-by: Andrew Morton akpm@linux-foundation.org ---
mm/ksm.c | 4 ++++ 1 file changed, 4 insertions(+)
--- a/mm/ksm.c~ksm-reinstate-memcg-charge-on-copied-pages +++ a/mm/ksm.c @@ -2586,6 +2586,10 @@ struct page *ksm_might_need_to_copy(stru return page; /* let do_swap_page report the error */
new_page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma, address); + if (new_page && mem_cgroup_charge(new_page, vma->vm_mm, GFP_KERNEL)) { + put_page(new_page); + new_page = NULL; + } if (new_page) { copy_user_highpage(new_page, page, address, vma);
_
Patches currently in -mm which might be from hughd@google.com are
ksm-reinstate-memcg-charge-on-copied-pages.patch mm-migration-of-hugetlbfs-page-skip-memcg.patch shmem-shmem_writepage-split-unlikely-i915-thp.patch mm-fix-check_move_unevictable_pages-on-thp.patch mlock-fix-unevictable_pgs-event-counts-on-thp.patch