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, 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 1D43BC83007 for ; Tue, 28 Apr 2020 21:17:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B8E8C206D6 for ; Tue, 28 Apr 2020 21:17:04 +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="Tqpge43y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8E8C206D6 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 1B2C68E0005; Tue, 28 Apr 2020 17:17:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 163178E0001; Tue, 28 Apr 2020 17:17:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A0A38E0005; Tue, 28 Apr 2020 17:17:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0254.hostedemail.com [216.40.44.254]) by kanga.kvack.org (Postfix) with ESMTP id E32BB8E0001 for ; Tue, 28 Apr 2020 17:17:03 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9E410180AD80F for ; Tue, 28 Apr 2020 21:17:03 +0000 (UTC) X-FDA: 76758523926.15.dirt98_5aada4c8fb319 X-HE-Tag: dirt98_5aada4c8fb319 X-Filterd-Recvd-Size: 5161 Received: from mail-qv1-f68.google.com (mail-qv1-f68.google.com [209.85.219.68]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Tue, 28 Apr 2020 21:17:02 +0000 (UTC) Received: by mail-qv1-f68.google.com with SMTP id ep1so126022qvb.0 for ; Tue, 28 Apr 2020 14:17:02 -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=WWrnsD36oOuilTSXzDBTC16te4SHEa8VgRR8Q/taiWeLtDq8fKc1usNQ31LRLA6bgk nPmt9VaMXh0gYEG0hiM+Dx2nUr69yte8UnCBysYOLTVMCNY2TPnC/RTQEJb+b91Acu/F OKMzuXVNyJCnM2ZUOd1UmWVutIJ/kJGUFonPbyd4W02+4zAZ8Hdz0YnsVW5RuyAYEcqe FzgWm3aaID7cVL4ablJ05f4rgoyd5k6qaMLRik0OaVlT2qfFkllmy9uJ3KLSJ1F0PDJm L5E8Fp2C67E54fjhg4x2AeArOC42i/uj6PAHCqQ454RosProo5DAMFYMT82ay4bX4mNM MkHg== X-Gm-Message-State: AGi0PubGRyNh9MxGjU/PCljG23KzWXTM45tMdpSmBQcYAPFBVPC2P9K4 OABBqNfp8mrh+kIRtW/egP9vmQ== X-Google-Smtp-Source: APiQypJWl8lRQzqib+jNVx+26p3v6+O+XdKVsDcIn39jYHtyA8sdXsPU0dP7yEIFCdl0sSPFRPzytQ== 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: 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 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