From: Alex Shi <alex.shi@linux.alibaba.com> Date: Fri, 18 Dec 2020 22:01:28 +0000 (-0800) Subject: mm/memcg: bail early from swap accounting if memcg disabled X-Git-Tag: v5.11-rc1~61^2~17 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=76358ab547357516ec2dace95ae70c1572d6708c;p=users%2Fdwmw2%2Flinux.git mm/memcg: bail early from swap accounting if memcg disabled Patch series "bail out early for memcg disable". These 2 patches are indepenedent from per memcg lru lock, and may encounter unexpected warning, so let's move out them from per memcg lru locking patchset. This patch (of 2): We could bail out early when memcg wasn't enabled. Link: https://lkml.kernel.org/r/1604283436-18880-1-git-send-email-alex.shi@linux.alibaba.com Link: https://lkml.kernel.org/r/1604283436-18880-2-git-send-email-alex.shi@linux.alibaba.com Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com> Reviewed-by: Roman Gushchin <guro@fb.com> Acked-by: Michal Hocko <mhocko@suse.com> Acked-by: Hugh Dickins <hughd@google.com> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Cc: Vladimir Davydov <vdavydov.dev@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> --- diff --git a/mm/memcontrol.c b/mm/memcontrol.c index e3c7ca7dc1749..5c3b054066f59 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -7178,6 +7178,9 @@ void mem_cgroup_swapout(struct page *page, swp_entry_t entry) VM_BUG_ON_PAGE(PageLRU(page), page); VM_BUG_ON_PAGE(page_count(page), page); + if (mem_cgroup_disabled()) + return; + if (cgroup_subsys_on_dfl(memory_cgrp_subsys)) return; @@ -7242,6 +7245,9 @@ int mem_cgroup_try_charge_swap(struct page *page, swp_entry_t entry) struct mem_cgroup *memcg; unsigned short oldid; + if (mem_cgroup_disabled()) + return 0; + if (!cgroup_subsys_on_dfl(memory_cgrp_subsys)) return 0;