From patchwork Thu Mar 12 18:02:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Down X-Patchwork-Id: 11435161 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 A5F2F14B4 for ; Thu, 12 Mar 2020 18:02:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5E09420663 for ; Thu, 12 Mar 2020 18:02:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.b="Haae2SBu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E09420663 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 714796B0003; Thu, 12 Mar 2020 14:02:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6C5626B0006; Thu, 12 Mar 2020 14:02:58 -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 5B3606B0007; Thu, 12 Mar 2020 14:02:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0190.hostedemail.com [216.40.44.190]) by kanga.kvack.org (Postfix) with ESMTP id 409326B0003 for ; Thu, 12 Mar 2020 14:02:58 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id F40AD9888 for ; Thu, 12 Mar 2020 18:02:57 +0000 (UTC) X-FDA: 76587481194.14.knee87_19d8decf38314 X-Spam-Summary: 2,0,0,905296714babeafd,d41d8cd98f00b204,chris@chrisdown.name,,RULES_HIT:41:355:379:800:960:973:988:989:1260:1277:1312:1313:1314:1345:1431:1437:1516:1518:1519:1534:1541:1593:1594:1595:1596:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3871:3872:3873:3874:5007:6261:6653:7875:10004:10400:10450:10455:11026:11473:11658:11914:12043:12297:12438:12517:12519:12555:12679:12895:13069:13161:13221:13229:13255:13311:13357:13439:13846:13895:14096:14097:14181:14394:14721:19904:19999:21080:21444:21451:21627:21939:30054:30064,0,RBL:209.85.221.68:@chrisdown.name:.lbl8.mailshell.net-62.2.0.100 66.100.201.201,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:24,LUA_SUMMARY:none X-HE-Tag: knee87_19d8decf38314 X-Filterd-Recvd-Size: 3920 Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by imf31.hostedemail.com (Postfix) with ESMTP for ; Thu, 12 Mar 2020 18:02:57 +0000 (UTC) Received: by mail-wr1-f68.google.com with SMTP id l18so8641978wru.11 for ; Thu, 12 Mar 2020 11:02:57 -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=CRd8IUcL1IWZS04LIYFbzj4WsXVZJS20ANjjPe46vbU=; b=Haae2SBurX0dFdW2FA0odm7mGIYVgXxbkX+kRhvt4ySMuKlguBzaUtjNrkfEaiED2N mbGRZT1Dix/XuTr0AVw4HxlQ1lhNxqlheMxxT7Vxz3Cz1I+Ulb5n/EARnD4G3g00Lwwn 6gqr2BrDtb+6qJLFLYJHzj2AY9s6hHt0U7yk0= 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=CRd8IUcL1IWZS04LIYFbzj4WsXVZJS20ANjjPe46vbU=; b=RPMSZDfA4b1SLtAyImMsOwlrn2eTZsjQdG5+pLd6u9Ws8L+HWO8y4BIzzGagefAVEz VoXnjb2mUsrOlSCZh9ipPM/3YFPjzeoHQUAs4BydXs7wwA4Mgj9fNRSCb/Tz+tkCQKqp bhfFFuUkqrGktIuDbH2aXoMkgpxb7IblLTp1uNcIKQsJVuay8bK3csvCmh4/1Qvp13nn tkISxyBELJ0XV6fLWKjnNUxSKY3P9AHreIng99CCeQe2o94Mi+0QvmBW4mDaJbu4DB91 K55OvK/eTfRbihACD4/qHInfTiQojI0RWwPao9q+zpP+JYcd+sdRoB56rZi56diD6Uel GZyw== X-Gm-Message-State: ANhLgQ0cLWoKbXHhPewW968ECTT2WXzX9dvCX2MGU2B3tTFrgeUvBxUN fHtbf/SHXYZ5OSXRCxDudHqQ/Q== X-Google-Smtp-Source: ADFU+vsZkrnnVJ1X3zqzCkFEciPWmkOFQhOVZNvmD7Ds5YPo0PFp30zOhwIn2DsIoCNmjexoQjXayA== X-Received: by 2002:a5d:4f0e:: with SMTP id c14mr12216319wru.100.1584036176193; Thu, 12 Mar 2020 11:02:56 -0700 (PDT) Received: from localhost ([89.32.122.5]) by smtp.gmail.com with ESMTPSA id i6sm11878144wru.40.2020.03.12.11.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Mar 2020 11:02:55 -0700 (PDT) Date: Thu, 12 Mar 2020 18:02:54 +0000 From: Chris Down To: Andrew Morton Cc: Johannes Weiner , Tejun Heo , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 1/2] mm, memcg: Fix corruption on 64-bit divisor in memory.high throttling Message-ID: <80780887060514967d414b3cd91f9a316a16ab98.1584036142.git.chris@chrisdown.name> MIME-Version: 1.0 Content-Disposition: inline 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: 0e4b01df8659 had a bunch of fixups to use the right division method. However, it seems that after all that it still wasn't right -- div_u64 takes a 32-bit divisor. The headroom is still large (2^32 pages), so on mundane systems you won't hit this, but this should definitely be fixed. Fixes: 0e4b01df8659 ("mm, memcg: throttle allocators when failing reclaim over memory.high") Reported-by: Johannes Weiner Signed-off-by: Chris Down Cc: Andrew Morton Cc: Tejun Heo Cc: linux-mm@kvack.org Cc: cgroups@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: kernel-team@fb.com Cc: stable@vger.kernel.org # 5.4.x Acked-by: Johannes Weiner --- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 63bb6a2aab81..a70206e516fe 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2339,7 +2339,7 @@ void mem_cgroup_handle_over_high(void) */ clamped_high = max(high, 1UL); - overage = div_u64((u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT, + overage = div64_u64((u64)(usage - high) << MEMCG_DELAY_PRECISION_SHIFT, clamped_high); penalty_jiffies = ((u64)overage * overage * HZ)