From patchwork Tue Mar 31 15:24:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Down X-Patchwork-Id: 11467963 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 98A631667 for ; Tue, 31 Mar 2020 15:24:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6619F208E0 for ; Tue, 31 Mar 2020 15:24:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.b="P8qu2lfT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6619F208E0 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 8B75C6B006C; Tue, 31 Mar 2020 11:24:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8680E6B006E; Tue, 31 Mar 2020 11:24:27 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 77DFE6B0070; Tue, 31 Mar 2020 11:24:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0045.hostedemail.com [216.40.44.45]) by kanga.kvack.org (Postfix) with ESMTP id 5CCAE6B006C for ; Tue, 31 Mar 2020 11:24:27 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 1503F181AC9BF for ; Tue, 31 Mar 2020 15:24:27 +0000 (UTC) X-FDA: 76656028974.22.play41_26cf351168328 X-Spam-Summary: 2,0,0,78342cc4d2dad082,d41d8cd98f00b204,chris@chrisdown.name,,RULES_HIT:41:355:379:800:960:973:988:989:1260:1277:1312:1313:1314:1345:1437:1516:1518:1519:1534:1541:1593:1594:1595:1596:1711:1730:1747:1777:1792:2393:2553:2559:2562:2898:3138:3139:3140:3141:3142:3353:3743:3865:3866:3867:3870:3871:3872:3874:4321:5007:6261:6653:7576:7875:7903:9163:10004:10400:11026:11473:11658:11914:12043:12295:12296:12297:12438:12517:12519:12555:12679:12895:12986:13069:13311:13357:13439:13895:14096:14097:14181:14394:14721:21080:21444:21451:21627:30054:30056:30070:30090,0,RBL:209.85.221.67:@chrisdown.name:.lbl8.mailshell.net-66.201.201.201 62.14.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: play41_26cf351168328 X-Filterd-Recvd-Size: 4378 Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Tue, 31 Mar 2020 15:24:26 +0000 (UTC) Received: by mail-wr1-f67.google.com with SMTP id d5so26577956wrn.2 for ; Tue, 31 Mar 2020 08:24: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:mime-version:content-disposition; bh=6PtH4wzWMiH5JmxAt904ilpPuqtvXlZEsu04wa6si/k=; b=P8qu2lfTpI9t1V10h5AQtX1pY3rsMg/xWtmYiBZTO8QwsPjlZ48gV9R/FoFJmeJWE0 6N9UVOHFvpnOaSH+7UMgcWEAHiG7XS3XGxcYf4DGWJ7JjdHdvf5MBmfs7Auv00Bns8rd 7JaAJ9XeB4dUlJrtAGbvmVJaQ85yG05sxP8nA= 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:mime-version :content-disposition; bh=6PtH4wzWMiH5JmxAt904ilpPuqtvXlZEsu04wa6si/k=; b=WPo+tQ1I/G/VsntSEvshBFg4FNkDQl79dGQVDCuUdnf6F0tMMaZDdTiR1Wti4svsyP zOpUXyF3IhehfEYEYbvD0gHPBv4wGzXa+AjUMUHDYLvrUv5qI3xBSvHRiD0XQd2xq0Un JETzvKKqY+WKwKSGuKrq2M1d8gI0l9dcqKxI8tHJZU8Ja9e3fmHpdWedFrzh3DXbiOno TVCagx/TUEJcGxqXILLrL8vt2cRCZIgrittIZhBMK45PrQYHh/T9KFrqB6mdBJ+yySCi Zyz0EJjyvRSP6XchjGM/+Rdw27dObxmUWH+RBJO4bnjeC6FuK776NfB9bel3wqdlJLz7 h9uQ== X-Gm-Message-State: ANhLgQ3iLlJDnbZtlQg8Ke4acKBRxi/sWoEs652pLTwqMdYXoVi0Y6mj Cgc3efqj/p70sWnhz8hb4wLZOw== X-Google-Smtp-Source: ADFU+vtjJzo7Yj3p4RVYdBmh1TnRGKbfJ5JHTuYQ43/PgPGuhocYfvkpQbIjq4OT3R2JrnctZq7ssQ== X-Received: by 2002:adf:9465:: with SMTP id 92mr21029231wrq.122.1585668265184; Tue, 31 Mar 2020 08:24:25 -0700 (PDT) Received: from localhost ([2620:10d:c092:180::1:27bd]) by smtp.gmail.com with ESMTPSA id c7sm27386436wrn.49.2020.03.31.08.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 08:24:24 -0700 (PDT) Date: Tue, 31 Mar 2020 16:24:24 +0100 From: Chris Down To: Andrew Morton Cc: Johannes Weiner , Jakub Kicinski , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH] mm, memcg: Do not high throttle allocators based on wraparound Message-ID: <20200331152424.GA1019937@chrisdown.name> MIME-Version: 1.0 Content-Disposition: inline X-Bogosity: Ham, tests=bogofilter, spamicity=0.000009, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Jakub Kicinski If a cgroup violates its memory.high constraints, we may end up unduly penalising it. For example, for the following hierarchy: A: max high, 20 usage A/B: 9 high, 10 usage A/C: max high, 10 usage We would end up doing the following calculation below when calculating high delay for A/B: A/B: 10 - 9 = 1... A: 20 - PAGE_COUNTER_MAX = 21, so set max_overage to 21. This gets worse with higher disparities in usage in the parent. I have no idea how this disappeared from the final version of the patch, but it is certainly Not Good(tm). This wasn't obvious in testing because, for a simple cgroup hierarchy with only one child, the result is usually roughly the same. It's only in more complex hierarchies that things go really awry (although still, the effects are limited to a maximum of 2 seconds in schedule_timeout_killable at a maximum). [chris@chrisdown.name: changelog] Fixes: e26733e0d0ec ("mm, memcg: throttle allocators based on ancestral memory.high") Signed-off-by: Jakub Kicinski Signed-off-by: Chris Down Cc: Johannes Weiner Cc: stable@vger.kernel.org # 5.4.x Acked-by: Michal Hocko Acked-by: Johannes Weiner --- mm/memcontrol.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index eecf003b0c56..75a978307863 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2336,6 +2336,9 @@ static unsigned long calculate_high_delay(struct mem_cgroup *memcg, usage = page_counter_read(&memcg->memory); high = READ_ONCE(memcg->high); + if (usage <= high) + continue; + /* * Prevent division by 0 in overage calculation by acting as if * it was a threshold of 1 page