Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp783563ybh; Thu, 12 Mar 2020 11:03:54 -0700 (PDT) X-Google-Smtp-Source: ADFU+vu8JRlnz2FXD5myFUgtzSBkYq62w66vQTrzok0+CzBSkOiZXFuSHpF30VeqxhTyTq1QGyx6 X-Received: by 2002:a9d:734f:: with SMTP id l15mr681008otk.55.1584036234039; Thu, 12 Mar 2020 11:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584036234; cv=none; d=google.com; s=arc-20160816; b=qeuYFgblYgW+Fc7egfNo/q8XXVWB8LPzNLgeUwdMO8vWPjYLLrTaBUM2ZmY4CdL2q9 00je0qDXnxXDCVwvNTiBkAE7rIvamx8mZKDjjOyZRkCAuNAaeDZ7M4quEGK/ceC6d/gZ udR0BJgGogs/74lIxEwVwo4PrPPiVgqaTAQ6ngF5wwWCf7/EmkX09i2zQcXkDZsQzVn0 geGawnlDmbHWele/SSODrftnkLW0HA0bcZ0IAbsZPkle/X4bUHrOFw1g8lX9g0Tysxg2 5hrYEdqW51RpDTqytbmOy6Jw14Kyz4c78uzws8d9UlCKWWl7/NT5WTXrkk+E9EnMq2tX ngPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=CRd8IUcL1IWZS04LIYFbzj4WsXVZJS20ANjjPe46vbU=; b=S00jrljoPi8LmGoYfrJnGAip6CxbXSUg/jNtTiCq9txjdeO8FEx/QFA8kGPgx8W0Sl 6hmCQBIET9sjc53fk96mbapatvNct8/f3Iyao8RgTS3drDkbHc2IXTPiHbD4Wr72J53u 4XZ1fecNrMW2PWhwuM1fm0BhOWjgiKDQnwZ3Lg+zft5azv+fyQbBs5C4ySm7PGaEPtMR ZsqztL730ZIs/ecJOFliMws0qNoscbAZ9mhbslBOehzGQIjKQEQQFaXx85RgxcALftEp DK0WNcPfX3Q9coHDjebm3g6rr75ptBosPlAwTyZM7yOB1WxEY4HUT5RnU2ohVk9tyEoR /n4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=Haae2SBu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y2si3222566oto.123.2020.03.12.11.03.36; Thu, 12 Mar 2020 11:03:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=Haae2SBu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726535AbgCLSC6 (ORCPT + 99 others); Thu, 12 Mar 2020 14:02:58 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:39020 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbgCLSC6 (ORCPT ); Thu, 12 Mar 2020 14:02:58 -0400 Received: by mail-wr1-f65.google.com with SMTP id r15so8684281wrx.6 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=luMCTmp6pxsJaXSkLf1CtP0bcDMoJAdZtOGqeHXXL80oVy4/oaE3IKQSo62DDfTdZp /PC+EH35OQAcH1Y10qbUClRCgdWE9MTTg+bzlmjwMFXT8aNXCzQ4ElJ/mJfNhlbEf3Rp /T43+G5EH8ck9V+g3qMXTTEVNF0L2gAbohpYxvy3gy4KCgomTtPTaJmFusMcbwXYjHVE e+1IHkIWc6pWDdPCdAGCqDUgSQAaK3diKnz2RrVSkPXnh30QGCHj/SCWhXdtHZDda36z 9na/5RwWsPNNnsWvdvNwtriBY4Nba+qezQ3YTZyRKFcL2mQgT3qHxeQ4mc3GNRKQ/sGV e6dg== X-Gm-Message-State: ANhLgQ2cYw33TWDnpmyY2yVsMbddjfZE4Doh2uir0fO63yIv4Rbd54e6 AoI0dF55umBDzwTsvcdTkvdceQ== 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-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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) -- 2.25.1