Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp797233pxa; Wed, 5 Aug 2020 13:02:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAMJWMgYsmayWOwSANjNSbsCHHr6G3v91lqhLDG+fMEUy8pZIpkgyl6COmOuBaZ8dDGgtx X-Received: by 2002:a17:906:3803:: with SMTP id v3mr911981ejc.165.1596657729794; Wed, 05 Aug 2020 13:02:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596657729; cv=none; d=google.com; s=arc-20160816; b=xekURRtqKi0uE1QeBtIlPGnTc5kL5yln0pfXINd4N9fgtrq4/3OUHCTpiqlEV/nLkd yzitwznHGdqfiCD6IA81TzqHjXezypa7wBhhjfIb+fmN5l90UztOU3wJkIAwlVuWhFmh Ki5yB3EFLPh54jv2/zIWmqvTV2oqWOfX3BZSMoE0TW0giWF19Vj70angis0iIhtAjJap jR6piPJsNytLg81yYMu7zP+95No0Ii2YviG87ePXgjH6WRyCggiX6eHtr41m8+zDDrVp +kRvO3MP/arxIt5iQySZaEdaXd1uqCAYbnUu+66zuOfcrJLp6JF/hW+F0nj9Mw+avM1C I+cw== 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:references:cc:to:from :subject; bh=YsYDXinubT8czV/RfiXw9fz7wb2aCpG6oSg2rCF47WE=; b=PCvE1ZOqqar4iLqcAJHrCmVZ0P1H17dIi4tGaY5gyibx1pAi+4T9L9j2sDubZN4VPz GyYAPIVb8yfpzkSpjmoo68aUgCvtz7IXkWlGvM+RClaT23yGwU5P/ZZzWsn09mJeoiku DG+LWSp9GS4XSmXkaaDi6MfFEUz5NbSQNr93LVYWVIrys0DKuhRFJyDAk3jEah3HSBVN AIB8PeMFGSeD+c4D9Z1+FKT7s9MizUEdGl/lzSyWc6MbkX0I9OTy8NKzFIkf/V/Gios0 yIZ5u8GUeKLp6YiWYm88yhDOpeC55u0S7pPEPmUXHsoGzWvupRfHtLkc+K8nA9vqrPPc GZiA== 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 u24si2174778edi.194.2020.08.05.13.01.46; Wed, 05 Aug 2020 13:02:09 -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 S1729731AbgHET6j (ORCPT + 99 others); Wed, 5 Aug 2020 15:58:39 -0400 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:41933 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727039AbgHEQmY (ORCPT ); Wed, 5 Aug 2020 12:42:24 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R541e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04427;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0U4paFMA_1596632569; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U4paFMA_1596632569) by smtp.aliyun-inc.com(127.0.0.1); Wed, 05 Aug 2020 21:02:49 +0800 Subject: Re: [PATCH] mm/memcg: remove useless check on page->mem_cgroup From: Alex Shi To: Michal Hocko Cc: Johannes Weiner , Vladimir Davydov , Andrew Morton , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <1596166480-22814-1-git-send-email-alex.shi@linux.alibaba.com> <20200731151655.GB491801@cmpxchg.org> <9338716f-ca0e-057f-8d94-03e2b3f70281@linux.alibaba.com> <20200803081815.GD5174@dhcp22.suse.cz> <92dd8e68-8095-72c5-0144-2a084e4d5993@linux.alibaba.com> Message-ID: <5622ef68-5e70-d1a9-d1be-b45411b6be5c@linux.alibaba.com> Date: Wed, 5 Aug 2020 21:02:30 +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: <92dd8e68-8095-72c5-0144-2a084e4d5993@linux.alibaba.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 在 2020/8/5 下午8:28, Alex Shi 写道: > The last patch has a problem on define. this version could fix it. > > BTW, I see some !memcg happens when MEMCG compilered but disabled by cgroup_disable > > > [ 94.657666] ---[ end trace f1f34bfc3b32ed2f ]--- > [ 95.138995] anon flags: 0x5005b48008000d(locked|uptodate|dirty|swapbacked) > [ 95.146220] raw: 005005b48008000d dead000000000100 dead000000000122 ffff8897c7c76ad1 > [ 95.154549] raw: 0000000000000022 0000000000000000 0000000200000000 0000000000000000 > [ 95.162876] page dumped because: VM_WARN_ON_ONCE_PAGE(!memcg) > > The following patch may helpful. From 8bfb26a2e37e08dc61d20212bcfa5812a367ba94 Mon Sep 17 00:00:00 2001 From: Alex Shi Date: Wed, 5 Aug 2020 20:32:12 +0800 Subject: [PATCH] mm/memcg: don't try charge swap if memcg disabled 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 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 cb07a48d53aa..65f2b42d25af 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -7163,6 +7163,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; @@ -7228,6 +7231,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