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.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, 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 10B74C3A5A9 for ; Sat, 2 May 2020 14:44:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 99B3821835 for ; Sat, 2 May 2020 14:44:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="uc0B0Fkh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 99B3821835 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3131C8E0005; Sat, 2 May 2020 10:44:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C4428E0001; Sat, 2 May 2020 10:44:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B3538E0005; Sat, 2 May 2020 10:44:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0080.hostedemail.com [216.40.44.80]) by kanga.kvack.org (Postfix) with ESMTP id 027F48E0001 for ; Sat, 2 May 2020 10:44:36 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id AB2C9181AEF10 for ; Sat, 2 May 2020 14:44:36 +0000 (UTC) X-FDA: 76772050152.03.pail55_62684b32d5a09 X-HE-Tag: pail55_62684b32d5a09 X-Filterd-Recvd-Size: 4868 Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Sat, 2 May 2020 14:44:36 +0000 (UTC) Received: by mail-qk1-f193.google.com with SMTP id l78so12098395qke.7 for ; Sat, 02 May 2020 07:44:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=s7iLIy2ytelKstpKKn8I8WpXJGgRforYLOl6q2Xy6qc=; b=uc0B0FkhG1LNuxznjJbmVGFPzIpXfOveDMjBcU4CM1DQruvFtZ1H9GUhKYu+4cEO5G vA0XQpu+fiaZqHk6vEvVtEPEFp3I/VY1BxAjkzy0//GNhMrO8Wym8+3Du3O+4Ts7wbBW Fvaysk24eYIDnF4hskTNwOKwrOJmLxr6s00AiVARVNi/DJ00VamuWD84g67r0ffe7ViL eVcuJMCRG29vsx0Glq/z/icVaq+M/SeRe5/kLDgiwYSOvq91uLV0XxWrfnDfOs+5LQPb vItmRohHIACzVIHYM86NFJTNbVF/lvTBS23WP79rkagAwRYT7Z2uKUIf3j1lf+b66fWV UdTw== 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=s7iLIy2ytelKstpKKn8I8WpXJGgRforYLOl6q2Xy6qc=; b=fgHjrQuRyth6i0yQOkUT8WrZDp/ZZiZfsOHNKEJogOK0mEUkLvAn9dRlKWSC/ycj1t QFbl2MIhN2B1Kb+KcAsrMCrfpJ1H8G0ObvJ5YeV3dEMYtPWOUL0YuLIcVXj6gFgW16Ob TxtRm20+SwsSuOwYKJ9smhHPSXtAi+aJl8NwlgUqvLuOU2G7pgZXk2cblHgvzWdOSNl5 OCW1zlSH+ePJ19nmEyUFWE66uIhBg6OI7+Zd0tTSh579AvBRoNxENIkQ86eO7LkEJAsw 26UA5p6yNV7je3rJO/ENXmorbUeNUIw1AkpcY5+xEtxERX1jo/k5q5hRmGu1xLcl67HE Wtig== X-Gm-Message-State: AGi0PuYh2MRfRuVJMOqZnx2RV+3GuQQ4ArEQs0cla+PMwCMPUieTp8vX Rq4RPw1g9JQyqQJRL92ehNx7Ow== X-Google-Smtp-Source: APiQypKRUyKfwBpM9aoSDtJ5RS1o3m2ke5/e5UdqDTUyl75ZKksWS/y9L7/r4szkA63gkhfe1RSM0g== X-Received: by 2002:a05:620a:127a:: with SMTP id b26mr8172054qkl.219.1588430674905; Sat, 02 May 2020 07:44:34 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:1439]) by smtp.gmail.com with ESMTPSA id x125sm5358509qke.34.2020.05.02.07.44.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 May 2020 07:44:34 -0700 (PDT) Date: Sat, 2 May 2020 10:44:22 -0400 From: Johannes Weiner To: Yafang Shao Cc: akpm@linux-foundation.org, mhocko@kernel.org, chris@chrisdown.name, 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: <20200502144422.GA51551@cmpxchg.org> 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 Content-Disposition: inline In-Reply-To: <20200502135910.7255-2-laoar.shao@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, May 02, 2020 at 09:59:09AM -0400, Yafang Shao wrote: > 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 Acked-by: Johannes Weiner