Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4590108ybz; Tue, 28 Apr 2020 14:18:57 -0700 (PDT) X-Google-Smtp-Source: APiQypILjYGo8HM2GOrpqG0yr5P3hWpRCNuwDBk2NeRd+FsjyfjEatYyKV9pIqVbPsQDLd4m9jvl X-Received: by 2002:a50:f74c:: with SMTP id j12mr24770264edn.197.1588108737269; Tue, 28 Apr 2020 14:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588108737; cv=none; d=google.com; s=arc-20160816; b=ioic9rGLN/Tm2PZV5BubP49hA5Qu3LseGB8XgpgUJa9rra8JJLIharjY42aHYhGDeL vjCPYJ0nTnx/luBd7ckvq82/wCcNeOCsZWNGNVaHZV57+SoKy56Xn2NLbyXmb101HPLO DTrXsSN1IyvH52rpHgwFn/olfPM3NRCWcyjdrMfT8FfWXIeEoAT1RjkWfEWhZr9XilBB TAEWdZUS0z9olq3xSLmFySp2JcK9yyj2CLAPiCbpStFOjEPhvLfC6umi77rNS1/sSW+n 6Keld/xjQrgoku1RW1d1FHBsJNvBfXHsLr1q+5S+Thygcizbxl889b32nSorr5XrKbKn 5f5A== 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 :dkim-signature; bh=WE6fRMNAlJdivHdtcAIHzYCELiaeahloDmul9mg0d04=; b=S2j0bmbA5BCneuEyZwFG9eRoDGK9polIrYlupRZPYZzsaRyDlSeuo4rIDbi0fcPFKr ucJOXk3UYgwvbyHtT2Z/l1GZpkfiW0e52Dp7d15P7NbSkCpVsUwOIhLBy3XSwE64NLNE VzWKlh2lctK3SoIC7yIaVu0aTS+oOeHXaZZVgMOAxD4EB5FYFvgEPuibxskGcChC5MZk GHo6t5dytlq364aBRxLdCw34d8c356MwFB8vJimgejGwooV4HBIcxol+b+Y8ilJpehT2 KLlz0YJB+KufebQAt48DULsqF3WJ54CkEflMOlh8SQCMX9pgBb/SLOF8XsSSCO8aH7XS 4cbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=Tqpge43y; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v20si2511667edb.416.2020.04.28.14.18.28; Tue, 28 Apr 2020 14:18:57 -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; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=Tqpge43y; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726483AbgD1VRD (ORCPT + 99 others); Tue, 28 Apr 2020 17:17:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726343AbgD1VRD (ORCPT ); Tue, 28 Apr 2020 17:17:03 -0400 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 394FEC03C1AD for ; Tue, 28 Apr 2020 14:17:03 -0700 (PDT) Received: by mail-qv1-xf44.google.com with SMTP id t8so109452qvw.5 for ; Tue, 28 Apr 2020 14:17:03 -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=WE6fRMNAlJdivHdtcAIHzYCELiaeahloDmul9mg0d04=; b=Tqpge43yY2XClplBd6Cuaaz88Fy6z2Qetea0T++CdEVcloY1WyqWjq9GfNzvdloNf+ QCyDC7llMs9FBzVbURzA6D2Q7zKZX469Z0F+4Nio7TMivfGJKk8UlmDymTXKq+4dgRsO BKbEtWpnzOKtWZMiirCI3Ybp9zHdbKYkkOj3efyJeOoZQARwk13IewUWv53ivh3bZHLE 2sI3P6Qod7o/TOvQCgAECFhN2fPYIXf0l1/OaiDqILqzJXcoiR4TfBzmdOZ880OwlFop grO3SdOEeWLC3XC9c3Td6B2frG8r/+tjxUjk9EGVq9WX7g1l58zDfeurHDEdNkYGStkr ciSg== 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=WE6fRMNAlJdivHdtcAIHzYCELiaeahloDmul9mg0d04=; b=lDHkd65A04OfBCfZwzmi0ihjMA94/fy6W3Wq5yJ5aSSFl4hh4gxj0gaUaVmfg0DNsM b5EuLATM0hZ4jRnDrakxn4mdkbvYhvEmJjfdSVraJSxui1UXFPPRvYj3clgty/mbYglb VpG6iitrsn1nPNT5sb642IF7J8iDfAywjR0AQB7FxsXRMVau3fTrtHU92rxrbg9+O/bz ScYumJmye4HzGv7q15pM1ucbziX3d0gGcmuPljtFyemt1vru6k6MCoqNZC0v0MzIK/x+ v1HgYjgZxAaG/a6wu/ytWVVoeuhmgMBCGEzW4fbY0wOasf6eA6l+onml9YATcaA5dCuj Ew+A== X-Gm-Message-State: AGi0Puad+4LO19SBhzzksPhX+A34yS0OMtAw6j1jOw1TBgnHvETvXQnm 7yQzf7vr97mo78hS/V6oSsQroA== X-Received: by 2002:a0c:8ecf:: with SMTP id y15mr30805391qvb.44.1588108622306; Tue, 28 Apr 2020 14:17:02 -0700 (PDT) Received: from localhost (70.44.39.90.res-cmts.bus.ptd.net. [70.44.39.90]) by smtp.gmail.com with ESMTPSA id u7sm14035646qkj.51.2020.04.28.14.17.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 14:17:01 -0700 (PDT) Date: Tue, 28 Apr 2020 17:16:51 -0400 From: Johannes Weiner To: Chris Down Cc: Andrew Morton , Michal Hocko , Roman Gushchin , Yafang Shao , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] mm, memcg: Avoid stale protection values when cgroup is above protection Message-ID: <20200428211651.GA400178@cmpxchg.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 28, 2020 at 07:26:47PM +0100, Chris Down wrote: > From: Yafang Shao > > 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. > > Fixes: 9783aa9917f8 ("mm, memcg: proportional memory.{low,min} reclaim") > Signed-off-by: Yafang Shao > Signed-off-by: Chris Down > Cc: Johannes Weiner > Cc: Michal Hocko > Cc: Roman Gushchin > > [hannes@cmpxchg.org: rework code comment] > [hannes@cmpxchg.org: changelog] > [chris@chrisdown.name: fix store tear] > [chris@chrisdown.name: retitle] Acked-by: Johannes Weiner