From patchwork Wed May 27 19:58:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 11573859 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 EADAC159A for ; Wed, 27 May 2020 19:58:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B91A820899 for ; Wed, 27 May 2020 19:58:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="OQCR2Mo9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B91A820899 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5B949800B6; Wed, 27 May 2020 15:58:52 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 545F080010; Wed, 27 May 2020 15:58:52 -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 0D818800B6; Wed, 27 May 2020 15:58:52 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0136.hostedemail.com [216.40.44.136]) by kanga.kvack.org (Postfix) with ESMTP id EB03180010 for ; Wed, 27 May 2020 15:58:51 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A2B0A180AD815 for ; Wed, 27 May 2020 19:58:51 +0000 (UTC) X-FDA: 76863562062.23.blood61_4d4d5429c4d4b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 8282337604 for ; Wed, 27 May 2020 19:58:51 +0000 (UTC) X-Spam-Summary: 2,0,0,9e7c237974146b05,d41d8cd98f00b204,kuba@kernel.org,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1437:1515:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:2693:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:3874:4321:4605:5007:6261:6653:7875:7901:8660:9592:10004:11026:11473:11658:11914:12043:12114:12220:12296:12297:12438:12517:12519:12555:12895:12986:13069:13148:13230:13311:13357:13869:13894:14096:14181:14384:14394:14721:21080:21451:21611:21627:21740:21939:21990:30005:30054,0,RBL:198.145.29.99:@kernel.org:.lbl8.mailshell.net-64.100.201.201 62.2.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: blood61_4d4d5429c4d4b X-Filterd-Recvd-Size: 3322 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Wed, 27 May 2020 19:58:51 +0000 (UTC) Received: from kicinski-fedora-PC1C0HJN.thefacebook.com (unknown [163.114.132.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EA1D12100A; Wed, 27 May 2020 19:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590609530; bh=j9Z01ym8A482OzEXrkei7XMFsMhiBRz05m+BDsqzMdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OQCR2Mo9NIBT6oXmeAvtSnzNMDXtZYqKEPCqDxC8IJy0nHK6OZeA5InMESztTBoFg bOSy98Rv7ep7gRDQGm/rUs+XNkwcfpv7bbcn5/LT9/iWfslXHFJdhkyT5NJ27w8Z+z Vdp+9uOsyuW5UG3UYdYmxMr9itIh6k62YV1QWYl0= From: Jakub Kicinski To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, kernel-team@fb.com, tj@kernel.org, hannes@cmpxchg.org, chris@chrisdown.name, cgroups@vger.kernel.org, shakeelb@google.com, mhocko@kernel.org, Jakub Kicinski Subject: [PATCH mm v6 2/4] mm: move penalty delay clamping out of calculate_high_delay() Date: Wed, 27 May 2020 12:58:44 -0700 Message-Id: <20200527195846.102707-3-kuba@kernel.org> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200527195846.102707-1-kuba@kernel.org> References: <20200527195846.102707-1-kuba@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8282337604 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: We will want to call calculate_high_delay() twice - once for memory and once for swap, and we should apply the clamp value to sum of the penalties. Clamping has to be applied outside of calculate_high_delay(). Signed-off-by: Jakub Kicinski Reviewed-by: Shakeel Butt Acked-by: Johannes Weiner --- mm/memcontrol.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 20ea7aea2292..3751e849f443 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2367,14 +2367,7 @@ static unsigned long calculate_high_delay(struct mem_cgroup *memcg, * MEMCG_CHARGE_BATCH pages is nominal, so work out how much smaller or * larger the current charge patch is than that. */ - penalty_jiffies = penalty_jiffies * nr_pages / MEMCG_CHARGE_BATCH; - - /* - * Clamp the max delay per usermode return so as to still keep the - * application moving forwards and also permit diagnostics, albeit - * extremely slowly. - */ - return min(penalty_jiffies, MEMCG_MAX_HIGH_DELAY_JIFFIES); + return penalty_jiffies * nr_pages / MEMCG_CHARGE_BATCH; } /* @@ -2402,6 +2395,13 @@ void mem_cgroup_handle_over_high(void) penalty_jiffies = calculate_high_delay(memcg, nr_pages, mem_find_max_overage(memcg)); + /* + * Clamp the max delay per usermode return so as to still keep the + * application moving forwards and also permit diagnostics, albeit + * extremely slowly. + */ + penalty_jiffies = min(penalty_jiffies, MEMCG_MAX_HIGH_DELAY_JIFFIES); + /* * Don't sleep if the amount of jiffies this memcg owes us is so low * that it's not even worth doing, in an attempt to be nice to those who