From patchwork Sun Mar 22 01:22:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 228913 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=DKIMWL_WL_HIGH, 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 31A13C4332D for ; Sun, 22 Mar 2020 01:22:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EC80420782 for ; Sun, 22 Mar 2020 01:22:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584840142; bh=AKIThlUcG1GmY0Wte6a3xYrpgomJvThfNHiDtL8Glj8=; h=Date:From:To:Subject:In-Reply-To:List-ID:From; b=ZyrRRuFv7LluaW++UJkI+mn/3Lhp7F2CB37Gc+uK2yfzY9yo6uvqfiP+NrrqiRRi+ TP8vYfFywvUf8gEV8xf8nR4sjV3/z7jnGladGChP9SvKHTtrLu41KU0AC787xAICnr KjSaJAzmWC4Yr68SR0dCPq5/OoQv3ZSeXxQ39efQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728132AbgCVBWV (ORCPT ); Sat, 21 Mar 2020 21:22:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:41124 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726859AbgCVBWV (ORCPT ); Sat, 21 Mar 2020 21:22:21 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (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 85F1E20767; Sun, 22 Mar 2020 01:22:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584840140; bh=AKIThlUcG1GmY0Wte6a3xYrpgomJvThfNHiDtL8Glj8=; h=Date:From:To:Subject:In-Reply-To:From; b=qfzl87JmjK5BBqKpus11yDfCs4/UBONR9bnmVPg9CZtoJBdNH7IubPfsJYp1SsVN5 gmHu2lfMEJaq43zCD4BnUhr8ty33Smnvl3uiB7i8JTfnLiDHgMxAJs3GMdOVnkbYm2 wGrfaGQdBBj7+8JjHApHlOMW5WEeDgG1QoQJwNeo= Date: Sat, 21 Mar 2020 18:22:20 -0700 From: Andrew Morton To: akpm@linux-foundation.org, chris@chrisdown.name, guro@fb.com, hannes@cmpxchg.org, linux-mm@kvack.org, mhocko@kernel.org, mm-commits@vger.kernel.org, natechancellor@gmail.com, stable@vger.kernel.org, tj@kernel.org, torvalds@linux-foundation.org Subject: [patch 04/10] mm, memcg: fix corruption on 64-bit divisor in memory.high throttling Message-ID: <20200322012220.Y-EvF7Agt%akpm@linux-foundation.org> In-Reply-To: <20200321181954.c0564dfd5514cd742b534884@linux-foundation.org> User-Agent: s-nail v14.8.16 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Chris Down Subject: mm, memcg: fix corruption on 64-bit divisor in memory.high throttling 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. Link: http://lkml.kernel.org/r/80780887060514967d414b3cd91f9a316a16ab98.1584036142.git.chris@chrisdown.name Fixes: 0e4b01df8659 ("mm, memcg: throttle allocators when failing reclaim over memory.high") Signed-off-by: Chris Down Reported-by: Johannes Weiner Acked-by: Johannes Weiner Cc: Tejun Heo Cc: Roman Gushchin Cc: Michal Hocko Cc: Nathan Chancellor Cc: [5.4.x+] Signed-off-by: Andrew Morton --- mm/memcontrol.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/memcontrol.c~mm-memcg-fix-corruption-on-64-bit-divisor-in-memoryhigh-throttling +++ a/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)