hulk inclusion category: bugfix bugzilla: https://atomgit.com/openeuler/kernel/issues/7679 -------------------------------- For a hugetlb folio, the memcg may be null, which will lead to warning, To avoid warning, add !folio_test_hugetlb(old). The mem_cgroup_replace_folio is only used by fuse or shmem, the !folio_test_hugetlb(old) is unnecessary, remove it and keep the same with mainline. Fixes: d151025ac030 ("hugetlb: memcg: account hugetlb-backed memory in memory controller") Signed-off-by: Chen Ridong <chenridong@huawei.com> --- mm/memcontrol.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 45352cee74b18..51b438146ceef 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -8803,12 +8803,7 @@ void mem_cgroup_replace_folio(struct folio *old, struct folio *new) return; memcg = folio_memcg(old); - /* - * Note that it is normal to see !memcg for a hugetlb folio. - * For e.g, itt could have been allocated when memory_hugetlb_accounting - * was not selected. - */ - VM_WARN_ON_ONCE_FOLIO(!folio_test_hugetlb(old) && !memcg, old); + VM_WARN_ON_ONCE_FOLIO(!memcg, old); if (!memcg) return; @@ -8852,7 +8847,12 @@ void mem_cgroup_migrate(struct folio *old, struct folio *new) return; memcg = folio_memcg(old); - VM_WARN_ON_ONCE_FOLIO(!memcg, old); + /* + * Note that it is normal to see !memcg for a hugetlb folio. + * For e.g, itt could have been allocated when memory_hugetlb_accounting + * was not selected. + */ + VM_WARN_ON_ONCE_FOLIO(!folio_test_hugetlb(old) && !memcg, old); if (!memcg) return; -- 2.34.1