From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29E23C433E0 for ; Thu, 2 Jul 2020 17:13:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EBEA621582 for ; Thu, 2 Jul 2020 17:13:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBEA621582 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 827E68D0011; Thu, 2 Jul 2020 13:13:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 801118D000C; Thu, 2 Jul 2020 13:13:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 73CAF8D0011; Thu, 2 Jul 2020 13:13:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0126.hostedemail.com [216.40.44.126]) by kanga.kvack.org (Postfix) with ESMTP id 5E65E8D000C for ; Thu, 2 Jul 2020 13:13:05 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 20319180AD804 for ; Thu, 2 Jul 2020 17:13:05 +0000 (UTC) X-FDA: 76993781130.29.cars32_0b073fb26e8a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id ED2C618086CAC for ; Thu, 2 Jul 2020 17:13:04 +0000 (UTC) X-HE-Tag: cars32_0b073fb26e8a X-Filterd-Recvd-Size: 5482 Received: from mail-ed1-f68.google.com (mail-ed1-f68.google.com [209.85.208.68]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Thu, 2 Jul 2020 17:13:04 +0000 (UTC) Received: by mail-ed1-f68.google.com with SMTP id dg28so24756625edb.3 for ; Thu, 02 Jul 2020 10:13:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=VVnE4dgvyAySr2AFaA3khkVH7tNEvr0JK5jKeXH+JQw=; b=UpgNj6uFO86jffSd6WQVrstCFnNn5CHD4n2aY3UUsXSyLNUfCmEZwtcspiOOHMz62E jBkd5r725fRGX2dFu0Y+kjs29WBx+Zh3op9V3cZPkWVBenhGg8g31BjDYozKynaz+JZs sIZNuRJn2SEFJb1ZWXmPo6W5tbA9L1fQn1PJX9t7J/VPEm6bwylLWZNHwk3FlCVrTU9l Xr7EgCamDrNS+Q6v9VP+tYLm9LvkAcxFW9uyaenW+X/NKjuSU+NpIn+k+XeJAZWtp9ee gvxzOTUp/AWPaoFmFBoeSWpA535+nFEl3IP1+5y5YZHwDoRTy3uWmrPZSxKGPRtijGth 49yg== X-Gm-Message-State: AOAM533ebdTbqXJAH/u83XFbgil0Xtp9PvJtnBh+2qtozLOo+aeAlpZ4 GpLSapjlGVuaiciXRJBeNPM= X-Google-Smtp-Source: ABdhPJzsx3bO5yi0V/ckWa7Vrn10ZB0zUEKO/SIIlR9h4BC7fL/R/0EN4AXZgNcI++/I6s3g461IIw== X-Received: by 2002:aa7:c50e:: with SMTP id o14mr36265439edq.168.1593709983439; Thu, 02 Jul 2020 10:13:03 -0700 (PDT) Received: from localhost (ip-37-188-168-3.eurotel.cz. [37.188.168.3]) by smtp.gmail.com with ESMTPSA id x4sm7204449eju.2.2020.07.02.10.13.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2020 10:13:02 -0700 (PDT) Date: Thu, 2 Jul 2020 19:13:02 +0200 From: Michal Hocko To: Roman Gushchin Cc: Naresh Kamboju , Shakeel Butt , Johannes Weiner , Andrew Morton , linux-mm , open list , lkft-triage@lists.linaro.org, Chris Down Subject: Re: BUG: Bad page state in process - page dumped because: page still charged to cgroup Message-ID: <20200702171302.GK18446@dhcp22.suse.cz> References: <20200701082904.GM2369@dhcp22.suse.cz> <20200701184552.GA61684@carbon.DHCP.thefacebook.com> <20200702162202.GI18446@dhcp22.suse.cz> <20200702163738.GA106423@carbon.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200702163738.GA106423@carbon.dhcp.thefacebook.com> X-Rspamd-Queue-Id: ED2C618086CAC X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu 02-07-20 09:37:38, Roman Gushchin wrote: > On Thu, Jul 02, 2020 at 06:22:02PM +0200, Michal Hocko wrote: > > On Wed 01-07-20 11:45:52, Roman Gushchin wrote: > > [...] > > > >From c97afecd32c0db5e024be9ba72f43d22974f5bcd Mon Sep 17 00:00:00 2001 > > > From: Roman Gushchin > > > Date: Wed, 1 Jul 2020 11:05:32 -0700 > > > Subject: [PATCH] mm: kmem: make memcg_kmem_enabled() irreversible > > > > > > Historically the kernel memory accounting was an opt-in feature, which > > > could be enabled for individual cgroups. But now it's not true, and > > > it's on by default both on cgroup v1 and cgroup v2. And as long as a > > > user has at least one non-root memory cgroup, the kernel memory > > > accounting is on. So in most setups it's either always on (if memory > > > cgroups are in use and kmem accounting is not disabled), either always > > > off (otherwise). > > > > > > memcg_kmem_enabled() is used in many places to guard the kernel memory > > > accounting code. If memcg_kmem_enabled() can reverse from returning > > > true to returning false (as now), we can't rely on it on release paths > > > and have to check if it was on before. > > > > > > If we'll make memcg_kmem_enabled() irreversible (always returning true > > > after returning it for the first time), it'll make the general logic > > > more simple and robust. It also will allow to guard some checks which > > > otherwise would stay unguarded. > > > > > > Signed-off-by: Roman Gushchin > > > --- > > > mm/memcontrol.c | 6 ++---- > > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > > > index 50ae77f3985e..2d018a51c941 100644 > > > --- a/mm/memcontrol.c > > > +++ b/mm/memcontrol.c > > > @@ -3582,7 +3582,8 @@ static int memcg_online_kmem(struct mem_cgroup *memcg) > > > objcg->memcg = memcg; > > > rcu_assign_pointer(memcg->objcg, objcg); > > > > > > - static_branch_inc(&memcg_kmem_enabled_key); > > > + if (!memcg_kmem_enabled()) > > > + static_branch_inc(&memcg_kmem_enabled_key); > > > > Wouldn't be static_branch_enable() more readable? > > Agree, will change, add reported-by and tested-by tags and resend. > Thanks! Feel free to add Acked-by: Michal Hocko > Btw, don't we wanna to change memcg_kmem_enabled() definition > from static_branch_unlikely() to static_branch_likely()? Honestly, I do not know what would be the impact but considering kmem is enabled unless explicitly disabled these days then likely sounds more logical from reading POV. I do not think that early allocations until the first memcg is created is the case to optimize for. Worth a separate patch I guess. -- Michal Hocko SUSE Labs