This is a note to let you know that I've just added the patch titled mm/memcg: fix 5.10 backport of splitting page memcg to the 5.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: mm-memcg-fix-5.10-backport-of-splitting-page-memcg.patch and it can be found in the queue-5.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Mon Mar 29 07:26:55 AM CEST 2021 From: Hugh Dickins <hughd@xxxxxxxxxx> Date: Sun, 28 Mar 2021 17:13:13 -0700 (PDT) Subject: mm/memcg: fix 5.10 backport of splitting page memcg To: gregkh@xxxxxxxxxxxxxxxxxxx Cc: akpm@xxxxxxxxxxxxxxxxxxxx, chenweilong@xxxxxxxxxx, dingtianhong@xxxxxxxxxx, guohanjun@xxxxxxxxxx, guro@xxxxxx, hannes@xxxxxxxxxxx, hughd@xxxxxxxxxx, kirill.shutemov@xxxxxxxxxxxxxxx, mhocko@xxxxxxxx, npiggin@xxxxxxxxx, rui.xiang@xxxxxxxxxx, shakeelb@xxxxxxxxxx, torvalds@xxxxxxxxxxxxxxxxxxxx, wangkefeng.wang@xxxxxxxxxx, willy@xxxxxxxxxxxxx, zhouguanghui1@xxxxxxxxxx, ziy@xxxxxxxxxx, stable@xxxxxxxxxxxxxxx Message-ID: <alpine.LSU.2.11.2103281706200.4623@eggly.anvils> From: Hugh Dickins <hughd@xxxxxxxxxx> The straight backport of 5.12's e1baddf8475b ("mm/memcg: set memcg when splitting page") works fine in 5.11, but turned out to be wrong for 5.10: because that relies on a separate flag, which must also be set for the memcg to be recognized and uncharged and cleared when freeing. Fix that. Signed-off-by: Hugh Dickins <hughd@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- mm/memcontrol.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3274,13 +3274,17 @@ void obj_cgroup_uncharge(struct obj_cgro void split_page_memcg(struct page *head, unsigned int nr) { struct mem_cgroup *memcg = head->mem_cgroup; + int kmemcg = PageKmemcg(head); int i; if (mem_cgroup_disabled() || !memcg) return; - for (i = 1; i < nr; i++) + for (i = 1; i < nr; i++) { head[i].mem_cgroup = memcg; + if (kmemcg) + __SetPageKmemcg(head + i); + } css_get_many(&memcg->css, nr - 1); } Patches currently in stable-queue which might be from hughd@xxxxxxxxxx are queue-5.10/mm-memcg-fix-5.10-backport-of-splitting-page-memcg.patch queue-5.10/mm-memcg-rename-mem_cgroup_split_huge_fixup-to-split_page_memcg-and-add-nr_pages-argument.patch queue-5.10/mm-memcg-set-memcg-when-splitting-page.patch