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=-1.0 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 E9903C54FD0 for ; Fri, 24 Apr 2020 14:33:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9701B2075A for ; Fri, 24 Apr 2020 14:33:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9701B2075A 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 F2EE08E0005; Fri, 24 Apr 2020 10:33:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EB8E08E0003; Fri, 24 Apr 2020 10:33:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DA8F88E0005; Fri, 24 Apr 2020 10:33:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0243.hostedemail.com [216.40.44.243]) by kanga.kvack.org (Postfix) with ESMTP id C08118E0003 for ; Fri, 24 Apr 2020 10:33:50 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 85E258248047 for ; Fri, 24 Apr 2020 14:33:50 +0000 (UTC) X-FDA: 76742992620.24.ear26_78cf69e35ed2d X-HE-Tag: ear26_78cf69e35ed2d X-Filterd-Recvd-Size: 3764 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Fri, 24 Apr 2020 14:33:50 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id y24so11033606wma.4 for ; Fri, 24 Apr 2020 07:33:49 -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=1dmTq9GYPFXiIasqQmCsmDhwPpqRF+E4SKqVryAxjAs=; b=N97yTc7WFjlzJNL8iLV2Y19yU+1M/IvUCZ7ipNBkJ+fa5I2Kse6QoDbXw5eJ2G1IeW 50TLryWPy+8eFZ6WhzqJdLhB0vmhaEcaVdSa8O664tCLyhS2ja87ll3fpV3NOrTr+rBn JvYvPco0+FTWaXCr0xKYwvHuta/O6wKATjB7QCyFekqTCsKr5GtkiS29STr2x6hSVy8p fuR3WAHFWhLukDmsYdZaHw+mxjB8BS1wgd+GOZYCv9Kg+el9IJtHu43jcOyqWDoRJhDi jFve9sNF5dtHyNThSbVI+puhPtDXqI1v5GpDlrDVeEFrbbjgylw7b8hlaqHAlzPjLuJh RCCQ== X-Gm-Message-State: AGi0PuYBA2an39SZ/6EIDwmBPseeFy6Oq44M03iUYO2UjvCirtN6F2OX 0GiS4JRYJ6n5b53U+xLd3S0+yKwj X-Google-Smtp-Source: APiQypKxPPwhck2+CtPILFT0UzPpuF4y1M2wxk9KzL2S44daGsMJL+fRSi9kEDyC1i4kwgqcAPfQuw== X-Received: by 2002:a1c:3dd6:: with SMTP id k205mr10495213wma.138.1587738829017; Fri, 24 Apr 2020 07:33:49 -0700 (PDT) Received: from localhost (ip-37-188-130-62.eurotel.cz. [37.188.130.62]) by smtp.gmail.com with ESMTPSA id h1sm3247165wme.42.2020.04.24.07.33.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2020 07:33:48 -0700 (PDT) Date: Fri, 24 Apr 2020 16:33:46 +0200 From: Michal Hocko To: Johannes Weiner Cc: Yafang Shao , akpm@linux-foundation.org, vdavydov.dev@gmail.com, linux-mm@kvack.org, Chris Down , Roman Gushchin , stable@vger.kernel.org Subject: Re: [PATCH] mm, memcg: fix wrong mem cgroup protection Message-ID: <20200424143346.GG11591@dhcp22.suse.cz> References: <20200423061629.24185-1-laoar.shao@gmail.com> <20200424131450.GA495720@cmpxchg.org> <20200424134438.GA496852@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200424134438.GA496852@cmpxchg.org> 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 Fri 24-04-20 09:44:38, Johannes Weiner wrote: > On Fri, Apr 24, 2020 at 09:14:52AM -0400, Johannes Weiner wrote: > > However, mem_cgroup_protected() never expected anybody to look at the > > effective protection values when it indicated that the cgroup is above > > its protection. As a result, a query during limit reclaim may return > > stale protection values that were calculated by a previous reclaim > > cycle in which the cgroup did have siblings. > > Btw, I think there is opportunity to make this a bit less error prone. > > We have a mem_cgroup_protected() that returns yes or no, essentially, > but protection isn't a binary state anymore. > > It's also been a bit iffy that it looks like a simple predicate > function, but it indeed needs to run procedurally for each cgroup in > order for the calculations throughout the tree to be correct. > > It might be better to have a > > mem_cgroup_calculate_protection() > > that runs for every cgroup we visit and sets up the internal state; > then have more self-explanatory query functions on top of that: > > mem_cgroup_below_min() > mem_cgroup_below_low() > mem_cgroup_protection() > > What do you guys think? Fully agreed. I have to say that I have considered the predicate with side effects really confusing. -- Michal Hocko SUSE Labs