Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp440695pxa; Tue, 11 Aug 2020 06:57:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMU1K8S7TrjlqY5eoTHSodpyddoWOYWeec4nA0mstX7lUHzRKpdPCVl0rP6MXTwyrQie/4 X-Received: by 2002:a17:907:42cd:: with SMTP id nz21mr26780527ejb.395.1597154247501; Tue, 11 Aug 2020 06:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597154247; cv=none; d=google.com; s=arc-20160816; b=PTk8jDInAm4Ct81jLnWAV+vu2sk5nCOAGPjYalmCa6ePLvTXAMBH1zxya/AHs7YyUK DrVAIFAjwG1bEleg7rnguklLbNpXZKmIJIAj6SnGUiXgVLi8zoglTwnSMqCpFlpYE2tN 8/y0heKKeILxWoXLFI+iOOGQnKmf9lOCgMG4hoLtfv3TQeoZ8zzt5eELXJf5dBhRQ9Fa LuoQL1Xz+jDPxpoyhcgTZj5o61mkn+AjUg1+DbhZCn90+2Ka6foXvpk9RwkMWT2Xgnh8 2r3DD/r9GwroeTk+zDNKULANPBjqNxBShr7tjrb736BwfV4mfEIcpeeDZebLhE8F4eir ec/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=4nJOpzDnwDOhzxfsz6QKO45W0Ho4JgoP5J0WTUAYop4=; b=DnX/6FGqdEokfN3ynVOcn0cOLS3jcgKYfDLne7OqDnWyjl2ESHmyNrErcdews17aXd yadClntAppjXzr5WNko8oyIQA7u4eXOg7ofCRGB/lDHMmdfA5m+uU/hSs3h7K7bSru0z jOjJIce+A/tgGM6C+ztIHPI+WHXwFsBG691J0gJKt9Ae9odfSGTHeVTBLh8XGikwcydK mfVjl/+fMiYPJUQvkLKGGXDKezpu+odsz9m15rB90UpVlI3ArOGKPTeUVWRi8a+lZ0Z+ dbpQKoZuPzIYTWeEKkBZp4o9oqyELxTyCbUpNHo+kLcIHSnQ7RaC5RbWnDxAXi05GOg6 YAWg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si12667808eji.64.2020.08.11.06.57.04; Tue, 11 Aug 2020 06:57:27 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728705AbgHKN4b (ORCPT + 99 others); Tue, 11 Aug 2020 09:56:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:49072 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728532AbgHKN43 (ORCPT ); Tue, 11 Aug 2020 09:56:29 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id BA8F6B0A5; Tue, 11 Aug 2020 13:56:48 +0000 (UTC) Date: Tue, 11 Aug 2020 15:56:26 +0200 From: Michal Hocko To: Alex Shi Cc: akpm@linux-foundation.org, Johannes Weiner , Vladimir Davydov , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [Resend PATCH 2/6] mm/memcg: remove useless check on page->mem_cgroup Message-ID: <20200811135626.GL4793@dhcp22.suse.cz> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <776b0e6f-4129-9fb9-0f66-47757cf320d5@linux.alibaba.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. > 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 -- Michal Hocko SUSE Labs