Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp330296pxa; Tue, 11 Aug 2020 04:15:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTcJ0jQA2kq4X/PzuxbYCbLw30s9Sw0PH4phUnhsnchGS77p2zJH77jBsIryMIefOJUnYp X-Received: by 2002:a05:6402:1d32:: with SMTP id dh18mr25308520edb.14.1597144528038; Tue, 11 Aug 2020 04:15:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597144528; cv=none; d=google.com; s=arc-20160816; b=RJeiVV8EJj6I9kO9M5a2uJ1hrINILkeyX0Erww/vRnCT/+BtrYYE2uPtKB3yIDmDdt UUNmwuLJDb9flFaV6v1u3wptlau0Ooo6uzgjk+9DIJCvMf6zII+xVwSoyYxXSchxwSm0 rDx1L1Gg+vVgku+qoYBwptCdQDkHuUg1Zapisuu1SusRlxBGQbkvvK99XKVyzjCafCvC gGfrxgJ2nWE7d2j+lKdlknjPmDwdVVHZ6tKK2ElOuAIzUPPTNwWU4d0wuiSJCfAI69p6 p+j8QP14uNUTfgUDIKeZ8DD7qIM3K+O0cWZuSJtkRLJtTb8BeL5M72T7Otvo/6nkv//z HQmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=0qWRzAupJ4CV6K6NMhUEUqrVmN5Fxu3mHdrp7WaKPYk=; b=T0+grZTfJOtf7ycY1jfaLb0GbNd+cZoN22rlvGa10NRX6qLYmmVHtRkxxE9LBAQKbs 6hBGDJ/d7G8Db60lECz2AjtXV63iPfNfXqnQyIPD+wWcJdn5KtutxhQed2fjmIXgcl4m F+NzbARG3kQtXYuPhQRJERlRdYSAe3otPwIQy0nsqkkLZwwiA1Ne+CeeUcUfRrl4m6dV kgTXTkA9sZV2NiuL86sNezuL7AqYlebUsgLiGCYKcp5jQk63LO4YIwCftZ72SlUp6oRW cYFf6oXXGjllNmwRar7jU/P99flc5h5slgK64hye5t1Li7Ph4+EauhWsIY7OkcMv2y5a KzlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id si17si12171465ejb.599.2020.08.11.04.15.04; Tue, 11 Aug 2020 04:15:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728663AbgHKLK4 (ORCPT + 99 others); Tue, 11 Aug 2020 07:10:56 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:47485 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727976AbgHKLKz (ORCPT ); Tue, 11 Aug 2020 07:10:55 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R841e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04397;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0U5TLMT5_1597144252; Received: from aliy80.localdomain(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U5TLMT5_1597144252) by smtp.aliyun-inc.com(127.0.0.1); Tue, 11 Aug 2020 19:10:52 +0800 From: Alex Shi To: akpm@linux-foundation.org Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [Resend PATCH 2/6] mm/memcg: remove useless check on page->mem_cgroup Date: Tue, 11 Aug 2020 19:10:28 +0800 Message-Id: <1597144232-11370-2-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1597144232-11370-1-git-send-email-alex.shi@linux.alibaba.com> References: <1597144232-11370-1-git-send-email-alex.shi@linux.alibaba.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If we disabled memcg by cgroup_disable=memory, the swap charges are still called. Let's return from the funcs earlier and keep WARN_ON monitor. Signed-off-by: Alex Shi Reviewed-by: Roman Gushchin Acked-by: Michal Hocko Cc: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov Cc: Andrew Morton Cc: cgroups@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/memcontrol.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 299382fc55a9..419cf565f40b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -7098,6 +7098,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; @@ -7163,6 +7166,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; -- 1.8.3.1