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=-3.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 A4401C3A5A9 for ; Sat, 2 May 2020 14:12:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 62D7721775 for ; Sat, 2 May 2020 14:12:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.b="I+0sYCOq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 62D7721775 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chrisdown.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 01E0A8E0005; Sat, 2 May 2020 10:12:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F10048E0001; Sat, 2 May 2020 10:12:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E26618E0005; Sat, 2 May 2020 10:12:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0130.hostedemail.com [216.40.44.130]) by kanga.kvack.org (Postfix) with ESMTP id CA7928E0001 for ; Sat, 2 May 2020 10:12:27 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 91CA61EF1 for ; Sat, 2 May 2020 14:12:27 +0000 (UTC) X-FDA: 76771969134.26.drop37_6cbd20a7f8c03 X-HE-Tag: drop37_6cbd20a7f8c03 X-Filterd-Recvd-Size: 4592 Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Sat, 2 May 2020 14:12:27 +0000 (UTC) Received: by mail-wr1-f66.google.com with SMTP id x17so15273150wrt.5 for ; Sat, 02 May 2020 07:12:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Tj6qsI67eLVtnE50+TBlOYqLjMlCcpsf76VAnTvQO0U=; b=I+0sYCOqSVlRkFWjFUJZ9VuiitwrIhK/O+L0RsTcTa1N4a6Hxzcml6GjlyqxMCuBPx MVn/Iy93wGxNQpUd9joTeKzVA2RMX7oYPM26gF67ybs6Jcs0/CQvvhJDehzJr+20C7DK wog/Lkdt03dkJlCV5xF6Ql3KrZbm6qLKs7uPA= 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=Tj6qsI67eLVtnE50+TBlOYqLjMlCcpsf76VAnTvQO0U=; b=CDuVc/GkjUgKn5qPgOCe8V1WLgSUaH2JzD60xeYDwSLWeFmfJCZcf91Y8GSnxemFcc ZIDnnA6zLa1mQyLxT5VGFHzgnqijgeOKWD/afVkKceUcmyiuYCvheowo3h27oMBQdoaq /xeT8D9Z8iqswJPFJbYo0qpSjL1+JCnsLs+DGngAcj/YwZi7KZG24/3q7EmkQ2cQJhrZ /lWyMNVMVyODmQjk8uQarXsA4o0v0TV+HfTyOcl/o+BP9hbtjq9cCZkEH1Br/bUM1H8r Hu7n1acpAnoXgoXmvFwPMfbBpEFyQc6eXkFARcgh2N25Y/OPzdGG9dETKeiSQ85czhOR NPpA== X-Gm-Message-State: AGi0PuZvunZzGl7jBOOAmaw9VenW2PNTMZDtwYhGMxlKD0tVcggmmdys 2dfQHLcRdvi8AH6Ie5s0ef1fEg== X-Google-Smtp-Source: APiQypIwFnrD+iJOrV/+X+JuDcqImCD/abtPVruSckLNGMk304D4kk1kjkw+ZpU8mqJvUwJBCQU8Ig== X-Received: by 2002:a5d:4711:: with SMTP id y17mr7049455wrq.49.1588428745838; Sat, 02 May 2020 07:12:25 -0700 (PDT) Received: from localhost ([2a01:4b00:8432:8a00:56e1:adff:fe3f:49ed]) by smtp.gmail.com with ESMTPSA id r17sm9400505wrn.43.2020.05.02.07.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 May 2020 07:12:25 -0700 (PDT) Date: Sat, 2 May 2020 15:12:24 +0100 From: Chris Down To: Yafang Shao Cc: akpm@linux-foundation.org, mhocko@kernel.org, hannes@cmpxchg.org, guro@fb.com, linux-mm@kvack.org Subject: Re: [PATCH v2 1/2] mm, memcg: Avoid stale protection values when cgroup is above protection Message-ID: <20200502141224.GA1973@chrisdown.name> References: <20200502135910.7255-1-laoar.shao@gmail.com> <20200502135910.7255-2-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200502135910.7255-2-laoar.shao@gmail.com> 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: Yafang Shao writes: >A cgroup can have both memory protection and a memory limit to isolate >it from its siblings in both directions - for example, to prevent it >from being shrunk below 2G under high pressure from outside, but also >from growing beyond 4G under low pressure. > >Commit 9783aa9917f8 ("mm, memcg: proportional memory.{low,min} reclaim") >implemented proportional scan pressure so that multiple siblings in >excess of their protection settings don't get reclaimed equally but >instead in accordance to their unprotected portion. > >During limit reclaim, this proportionality shouldn't apply of course: >there is no competition, all pressure is from within the cgroup and >should be applied as such. Reclaim should operate at full efficiency. > >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. > >When this happens, reclaim is unnecessarily hesitant and potentially >slow to meet the desired limit. In theory this could lead to premature >OOM kills, although it's not obvious this has occurred in practice. > >[hannes@cmpxchg.org: changelog] >[mhocko@kernel.org: rework code comment] >[chris@chrisdown.name: retitle] >Fixes: 9783aa9917f8 ("mm, memcg: proportional memory.{low,min} reclaim") >Signed-off-by: Yafang Shao >Acked-by: Roman Gushchin >Cc: Michal Hocko >Cc: Johannes Weiner >Cc: Chris Down Thanks! Acked-by: Chris Down