Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp393824pxa; Tue, 11 Aug 2020 05:56:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWQ/NaF+/2yw1xJrC8vW041GLZc1m6OesI9OIj/zPnOjnRwGlH+N/a8SAK5g1VVoIuO6kH X-Received: by 2002:a17:906:a0c5:: with SMTP id bh5mr7381808ejb.120.1597150614791; Tue, 11 Aug 2020 05:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597150614; cv=none; d=google.com; s=arc-20160816; b=apy+2vaSF+W5+DdbSrVGTp8F8nMnZox0TynPeg2nD1Xamag+rxOA9Ty430Sk0GUpet AMlSdZVl0fgi4nZ86rl9J0vA9JYVFyg40gv6uqy8T4TZUcWcTU66Q4aTsseKVtNBzIJE SVNlrWpQ1/ZisYtVSwSopneHCTKWfMez9kwsOGrMG8rLWGunwGpQTB/PmPwGxKAtiwmz gwoJdjMd8ozc62ythPe9FDIw6OerWBBxHhJB2hKyKgztjwEAoJ404h7VzbN2R1HDqK1A LHdXzilw/DhLITXE8xWtqPOIbiZGa2v/B9gU0RJ7Pt5IkQyisKZLClskcNLQR6IkW+L1 AVjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=IYXw9YUmZF3j7+IYMd3vVcCjRumSpcHtzn94sBKnoJ4=; b=LZhCzdKhyfvJnsrKnOKiBaDDm1QPvYT+zLkPul4wvkM0nTyMvFsXDsPygaIeDQkkUh XlYcQolw9usV2dJjnvCIjKTQ6yA255Uii5r8Xt+ndrrkl848zht7PcEBuoqs4FyJQ4Ad W3I9mtwhrqYMyrcbeg0sIdEgoxXp/9UefD6KcRgSPuMiAB8hDn1P0DBRLSThwVNrM1SU O5CschhBZFCUamaf3SaBjwaRO84ToCthoXyrXMaaUFaXMMlzSoSbhNYcvcVGg6sbu/ae uP8gZEbnKlSyuhZH4gwvQynPBi+m6ZZAglHMz0k4A0LcVuJZfSm7Fcus/1i9ZytRYdf4 scAA== 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 ba10si2746279edb.472.2020.08.11.05.56.31; Tue, 11 Aug 2020 05:56:54 -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 S1728648AbgHKMyz (ORCPT + 99 others); Tue, 11 Aug 2020 08:54:55 -0400 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:43536 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728081AbgHKMyv (ORCPT ); Tue, 11 Aug 2020 08:54:51 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R231e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04394;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0U5U0lpc_1597150487; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U5U0lpc_1597150487) by smtp.aliyun-inc.com(127.0.0.1); Tue, 11 Aug 2020 20:54:48 +0800 Subject: Re: [Resend PATCH 2/6] mm/memcg: remove useless check on page->mem_cgroup To: Michal Hocko Cc: akpm@linux-foundation.org, Johannes Weiner , Vladimir Davydov , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <1597144232-11370-1-git-send-email-alex.shi@linux.alibaba.com> <1597144232-11370-2-git-send-email-alex.shi@linux.alibaba.com> <20200811113008.GK4793@dhcp22.suse.cz> From: Alex Shi Message-ID: <776b0e6f-4129-9fb9-0f66-47757cf320d5@linux.alibaba.com> Date: Tue, 11 Aug 2020 20:54:18 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200811113008.GK4793@dhcp22.suse.cz> Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From beeac61119ab39b1869c520c0f272fb8bab93765 Mon Sep 17 00:00:00 2001 From: Alex Shi Date: Wed, 5 Aug 2020 21:02:30 +0800 Subject: [PATCH 2/6] memcg: bail out early from swap accounting when memcg is disabled If we disabled memcg by cgroup_disable=memory, the swap charges are still called. Let's return from the funcs earlier. 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