On Thu, Mar 04, 2021 at 07:30:12AM -0500, Miaohe Lin wrote: > Since commit 7ae88534cdd9 ("mm: move mem_cgroup_uncharge out of > __page_cache_release()"), the mem_cgroup will be uncharged when hpage is > freed. Uncharge mem_cgroup here is harmless but it looks confusing and > buggy: if mem_cgroup charge failed, we will call mem_cgroup_uncharge() > uncorrectly in error path because hpage is not IS_ERR_OR_NULL(). > > Signed-off-by: Miaohe Lin <linmiaohe@xxxxxxxxxx> Hm. I'm not sure about this patch. For !NUMA the page will get allocated and freed very early: in khugepaged_do_scan() and with the change mem_cgroup_charge() may get called twice for two different mm_structs. Is it safe? -- Kirill A. Shutemov