Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp144773pxa; Tue, 11 Aug 2020 20:28:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVra+owsiMm52q1h70q1iswr+hHgl1VeBbz0xiqjV/eL8kfCudATfJTK8Dj6Vw4NEgZYlF X-Received: by 2002:a17:907:aaa:: with SMTP id bz10mr28793180ejc.304.1597202894221; Tue, 11 Aug 2020 20:28:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597202894; cv=none; d=google.com; s=arc-20160816; b=roHP4KQ7KAVe9oMzF5Rpkox97YxxmQHexwL1lDIZY5oSZnZgMwPFM4TDJKzIBwtAdu WDbPyOZ9DTo/PylVIdGdtyRmx4UfzqFTkScPJdg3o1jciLnoaUzqZAoeRMV9AWVGBU4i jSaFZOAM2WgY3zQn3rB0wHNzK+T8gi3raejBRfZ37lXBR/3gt/edO5JOV6d213ilw1ou vLWXZI0j+rsJ/p13/vGOtAOfVJeA/YuNduCkP6NzIHi2zpP+pMzEJ/AUF+YZPW9BXWgo T0kPA6oJ/+KMVIm+Lw/lH4uO1Q31CLQYOwtTmaEHOgpozXo7aD/uEwf0SFQEvMJ1xApw PVDA== 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=KM5Er3w3sAmZdyTYmvjCyxRjnx0L0Wme2+A/TcPVOFg=; b=YpngFhUfnlTM2drgu9UqkJlFs3rslxv/j5NgS836I+EGvChRssDrNajbHpKdDNqfFM x25YO3ACjnsLhBK9KzIOcVH0Z5Q0FXDhBLTf090X5X36Ti+xElbbiRXpOBTGxypIKGBw JYPRcpUsQrSw6pb2B5iehdJhLxXVPtQAfZpHiHINeNqj/t7+pbBSCrrLCdSO2PVsJx7W DDBxwDT3ypMeC76RTG+i3JTjoCAftHXm9KUFFRQ6G/Soj8i+p09ru5h/f7qJYGuzf/pH LDQHut04/MXyjX5K+Vf+RsnWLnYF/e5S/XnByTWtqZUG2DDSknysEiLRdYqPLUNSQy5V u/SQ== 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 z13si331773eja.704.2020.08.11.20.27.51; Tue, 11 Aug 2020 20:28:14 -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 S1726488AbgHLD0n (ORCPT + 99 others); Tue, 11 Aug 2020 23:26:43 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:56186 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726457AbgHLD0m (ORCPT ); Tue, 11 Aug 2020 23:26:42 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R381e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e01422;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=7;SR=0;TI=SMTPD_---0U5Wk7Ug_1597202786; Received: from IT-FVFX43SYHV2H.local(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0U5Wk7Ug_1597202786) by smtp.aliyun-inc.com(127.0.0.1); Wed, 12 Aug 2020 11:26:27 +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> <776b0e6f-4129-9fb9-0f66-47757cf320d5@linux.alibaba.com> <20200811135626.GL4793@dhcp22.suse.cz> From: Alex Shi Message-ID: <0b5e1ac3-c9c7-35e9-2661-b58430314d0a@linux.alibaba.com> Date: Wed, 12 Aug 2020 11:25:53 +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: <20200811135626.GL4793@dhcp22.suse.cz> Content-Type: text/plain; charset=gbk 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/11 ????9:56, Michal Hocko ะด??: > On Tue 11-08-20 20:54:18, Alex Shi wrote: >> >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. > They are not, are they? page->memcg will be NULL and so the charge is > skipped and that will trigger a warning with your current ordering. Hi Michal, Thanks for comment! Looks like we both agree the memcg wasn't charged, but funcs just are called. :) > > Let me repeat again. Either you put it first in the series and argue > that we can bail out early or keep the ordering then this makes sure the > warning doesn't trigger. > Is the following commit log fine? Thanks! Alex From 999b0fe5fc65865c3b59ff28500d45572a4a9570 Mon Sep 17 00:00:00 2001 From: Alex Shi Date: Wed, 5 Aug 2020 21:02:30 +0800 Subject: [PATCH 2/6] mm/memcg: bail out early from swap accounting when memcg is disabled If we disabled memcg by cgroup_disable=memory, page->memcg will be NULL and so the charge is skipped and that will trigger a warning like below. Let's return from the funcs earlier. ---[ end trace f1f34bfc3b32ed2f ]--- anon flags:0x5005b48008000d(locked|uptodate|dirty|swapbacked) raw: 005005b48008000d dead000000000100 dead000000000122 ffff8897c7c76ad1 raw: 0000000000000022 0000000000000000 0000000200000000 0000000000000000 page dumped because: VM_WARN_ON_ONCE_PAGE(!memcg) 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