From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796455940; b=2RroycFiMjwnhPN3FnsXRI8d/zwJKe3VMYEHHygarGcm9X0QQ/IPzKWpAt+KCxk5gAzJ 19+l3YtCTI6hmf/G+3gAuWwe080OM7ir4O5O67FaqbaOVaTYh8yu3KM2oLdQhkBCDTcFE uzcT9+KbkZAecdoH2iYnl+cpnp6aDVWSTswGHRmyT5QLK5+za51hWeJwT08I8+DDL0R+j tF8Vr+r7vWMHDNtowJlb8p/W4pWClk9lb0LnwB0YJ62V91rFkLndwybSm34BIzTAVA+Ff wotMQwf5cflxe5zbb/FtO7AqRUup5M42S2qIW29a5xD+S8u3I3I0eo0gv0EUifYhI+w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796455940; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=Unp6g/RpUDlVTkYvgGByPsR1uHb6KVceAIcRqKscZNU=; b=fQEllJi2lPG2oQ4T6EWH7ZIxmMYudufHXJ8f+uIbnjJNrhO0K21fkpouIVfTKzCBcL9h /RuD4PH71rrRFLhapaQLmzlDaIKvznw/WPkeaF3V+gvLgVgXbpEKl9q1btQC4vlICZaor cOyTvMkvuwgISQm3JyKU+iUirrvUiMDdcyjZGhzTkAAIFJMuZVlH50SleNEyhLHxQntbq Kb3zSlla6SWB/x+5AvIrIV5pkK07XEpO5xj3I5nrF/6QR27CKbkfBmhARx3JYfSIca6O/ QRrXO5H5OeB9psifMOzG0pN8Aq9Slri5Qw2UNN3G1qB19sjIAPWqNIcgT+6r920Jjxw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=fT8IW5c3; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8324A606A333; Sat, 5 Dec 2026 07:32:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=fT8IW5c3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 205DA1F00936; Sat, 5 Dec 2026 07:32:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796455940; bh=Unp6g/RpUDlVTkYvgGByPsR1uHb6KVceAIcRqKscZNU=; h=Date:To:From:In-Reply-To:References:Subject; b=fT8IW5c37U+FxCxT9mMdlUN0ZVXsDOuZAjBvSPMKMag0gwM2EiH2rWs5WzyUmXLFw llgfIb+3i14ejzcQMkWW3UkE6At+kPCtT/6HJ+ewAJI+NgVoKNwKrnCFPdnsQQ6Inl ZN6W00ymxV3RLUiPSrSS8AR6C78Sokf3eQDAlPGs= Date: Fri, 04 Dec 2026 23:32:19 -0800 To: mm-commits@vger.kernel.org,zhangjiao2@cmss.chinamobile.com, stable@vger.kernel.org,shakeel.butt@linux.dev,roman.gushchin@linux.dev, muchun.song@linux.dev,mhocko@kernel.org,husong@kylinos.cn,hannes@cmpxchg.org, cui.tao@linux.dev,cuitao@kylinos.cn,chris@chrisdown.name,alireza@asgari.net, zhuhui@kylinos.cn,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <32198723709067dfefc0d7048e03586a25714453.1796367145.git.zhuhui@kylinos.cn> References: <32198723709067dfefc0d7048e03586a25714453.1796367145.git.zhuhui@kylinos.cn> Subject: + mm-memcg-fix-memoryhigh-throttle-lost-to-u64-overflow.patch added to mm-new branch Message-Id: <20261205073220.205DA1F00936@smtp.kernel.org> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: mm: memcg: fix memory.high throttle lost to u64 overflow has been added to the -mm mm-new branch. Its filename is mm-memcg-fix-memoryhigh-throttle-lost-to-u64-overflow.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-memcg-fix-memoryhigh-throttle-lost-to-u64-overflow.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Hui Zhu Subject: mm: memcg: fix memory.high throttle lost to u64 overflow Date: Fri, 04 Dec 2026 15:18:20 +0800 calculate_high_delay() squares max_overage and scales it by HZ in u64. max_overage is the ratio ((usage - high) << 20) / high, and memory.high has no lower bound, so the product wraps once a cgroup is about 130x over its limit (at HZ=1000). The wrapped value is arbitrary and can be exactly zero: with memory.high set to one page and usage at 2049 pages, max_overage is 2^31, the product wraps to zero and the penalty comes out 0 jiffies instead of the 2 seconds the formula calls for. The caller then takes its "penalty_jiffies <= HZ / 100" exit, skipping both the throttle and the reclaim retry loop. Use check_mul_overflow() for the two multiplications and return MEMCG_MAX_HIGH_DELAY_JIFFIES when either of them wraps. An overflow means the exact product is at least 2^64, so the delay is past its cap even when nr_pages is a single page, and the caller clamps to the same value anyway. Song Hu reported this and proposed check_mul_overflow(). Zhang Jiao posted an earlier fix using an overage cap; per Johannes Weiner's review this version uses check_mul_overflow() instead. Link: https://patch.msgid.link/32198723709067dfefc0d7048e03586a25714453.1796367145.git.zhuhui@kylinos.cn Link: https://lore.kernel.org/all/20260818012115.65838-1-husong@kylinos.cn/ Link: https://lore.kernel.org/all/20261029073857.974-1-zhangjiao2@cmss.chinamobile.com/ Fixes: 0e4b01df8659 ("mm, memcg: throttle allocators when failing reclaim over memory.high") Signed-off-by: Song Hu Signed-off-by: Hui Zhu Signed-off-by: Andrew Morton Co-developed-by: Song Hu Acked-by: Muchun Song (ByteDance) Acked-by: Shakeel Butt Reviewed-by: Johannes Weiner Reviewed-by: Tao Cui Cc: Michal Hocko Cc: Roman Gushchin Cc: Chris Down Cc: Alireza Asgari Cc: zhang jiao Cc: Tao Cui Cc: mm/memcontrol.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/mm/memcontrol.c~mm-memcg-fix-memoryhigh-throttle-lost-to-u64-overflow +++ a/mm/memcontrol.c @@ -2639,7 +2639,11 @@ static u64 calculate_high_delay(unsigned * its crazy behaviour, so we exponentially increase the delay based on * overage amount. */ - penalty_jiffies = max_overage * max_overage * HZ; + /* An overflow puts the delay far past the cap the caller applies. */ + if (check_mul_overflow(max_overage, max_overage, &penalty_jiffies) || + check_mul_overflow(penalty_jiffies, (u64)HZ, &penalty_jiffies)) + return MEMCG_MAX_HIGH_DELAY_JIFFIES; + penalty_jiffies >>= MEMCG_DELAY_PRECISION_SHIFT; penalty_jiffies >>= MEMCG_DELAY_SCALING_SHIFT; _ Patches currently in -mm which might be from zhuhui@kylinos.cn are mm-vmstat-annotate-data-race-in-zone_page_state_snapshot.patch mm-mglru-use-a-smaller-batch-in-fill-drain_evictable.patch mm-mglru-reset-the-mm-iteration-cursor-in-try_to_inc_max_seq_nowalk.patch mm-compaction-annotate-data-race-for-zone-free_areanr_free.patch mm-memcg-fix-zero-throttle-delay-on-32-bit-kernels.patch mm-memcg-fix-memoryhigh-throttle-lost-to-u64-overflow.patch