Skip to content

Commit 002ea84

Browse files
Hugh Dickinsgregkh
authored andcommitted
mm/memcg: fix 5.10 backport of splitting page memcg
The straight backport of 5.12's e1baddf ("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@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2c16352 commit 002ea84

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

mm/memcontrol.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3274,13 +3274,17 @@ void obj_cgroup_uncharge(struct obj_cgroup *objcg, size_t size)
32743274
void split_page_memcg(struct page *head, unsigned int nr)
32753275
{
32763276
struct mem_cgroup *memcg = head->mem_cgroup;
3277+
int kmemcg = PageKmemcg(head);
32773278
int i;
32783279

32793280
if (mem_cgroup_disabled() || !memcg)
32803281
return;
32813282

3282-
for (i = 1; i < nr; i++)
3283+
for (i = 1; i < nr; i++) {
32833284
head[i].mem_cgroup = memcg;
3285+
if (kmemcg)
3286+
__SetPageKmemcg(head + i);
3287+
}
32843288
css_get_many(&memcg->css, nr - 1);
32853289
}
32863290

0 commit comments

Comments
 (0)