You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mm: memcontrol: make all the callers of {folio,page}_memcg() safe
When we use objcg APIs to charge the LRU pages, the page will not hold
a reference to the memcg associated with the page. So the caller of the
{folio,page}_memcg() should hold an rcu read lock or obtain a reference
to the memcg associated with the page to protect memcg from being
released. So introduce get_mem_cgroup_from_{page,folio}() to obtain a
reference to the memory cgroup associated with the page.
In this patch, make all the callers hold an rcu read lock or obtain a
reference to the memcg to protect memcg from being released when the LRU
pages reparented.
We do not need to adjust the callers of {folio,page}_memcg() during
the whole process of mem_cgroup_move_task(). Because the cgroup migration
and memory cgroup offlining are serialized by @cgroup_mutex. In this
routine, the LRU pages cannot be reparented to its parent memory cgroup.
So {folio,page}_memcg() is stable and cannot be released.
This is a preparation for reparenting the LRU pages.
Signed-off-by: Muchun Song <[email protected]>
Acked-by: Roman Gushchin <[email protected]>
Link: https://lore.kernel.org/all/[email protected]/
Orabug: 37405594
Conflicts:
fs/buffer.c
fs/fs-writeback.c
include/linux/memcontrol.h
mm/memcontrol.c
mm/page_io.c
(Due to presence of following commits in UEK-8:
i. 'commits c71124a buffer: add folio_alloc_buffers() helper'
ii. 'commit 75376c6 mm: convert mem_cgroup_css_from_page() to
mem_cgroup_css_from_folio()'
iii. 'commit 98630cf mm/page_io: convert bio_associate_blkg_from_page()
to take in a folio'
Signed-off-by: Imran Khan <[email protected]>
Reviewed-by: Kamalesh Babulal <[email protected]>
0 commit comments