From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5972A606A335 for ; Fri, 4 Dec 2026 07:18:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=t/HCF6qJ Received: by kanga.kvack.org (Postfix) id 4FF876B05B5; Fri, 4 Dec 2026 02:18:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D7E46B05B6; Fri, 4 Dec 2026 02:18:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 415646B05B7; Fri, 4 Dec 2026 02:18:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 214DB6B05B5 for ; Fri, 4 Dec 2026 02:18:36 -0500 (EST) Received: from smtpin10.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A5F67160233 for ; Fri, 4 Dec 2026 07:18:35 +0000 (UTC) X-FDA: 85505447790.10.FA584FF Received: from mta1.migadu.com (out-47.mta1.migadu.com [95.215.58.47]) by imf19.hostedemail.com (Postfix) with ESMTP id BA1E71A0009 for ; Fri, 4 Dec 2026 07:18:32 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="t/HCF6qJ"; spf=pass (imf19.hostedemail.com: domain of hui.zhu@linux.dev designates 95.215.58.47 as permitted sender) smtp.mailfrom=hui.zhu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796368714; b=xI6LGSr2qwUuQ/VFAgs1c5Dzs7j8x44vOtBSJA0oQjBMdCFB3TPTk8GRT/K4/ZV4LqkyF1 iCrXbhmNIAQS6yJaI1OOVBpYQvCMdGfGhubglSTRNfQlncixoU/lLJ/Aj6euhxBZkKwqxS B+BmG3NToWOZabq5F/5J7eGzTRZsH4Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796368714; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=NG/lCyPS2SdyPa7jUI15lXmRSNg2iYggRdG6fliqSHI=; b=sKtQijBZNpAtTPYqwB2iv/8c2wYR34hXX60t66tqAzOl/CkeksyVAzFEnUqp2+WzSehN/j Bbisp5we+E46IviIrMrmiVsMdGLLVRMFz+c5fXugucRU+pZW7WPVAV25s8RQxwQdSasEji VMyqJ5SyxlgxymclWw2pmGGjt3UOZR0= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="t/HCF6qJ"; spf=pass (imf19.hostedemail.com: domain of hui.zhu@linux.dev designates 95.215.58.47 as permitted sender) smtp.mailfrom=hui.zhu@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Envelope-To: linux-mm@kvack.org DKIM-Signature: a=rsa-sha256; bh=ULPS2nREZt+obO051zjaGVuMaYjI0qBUFnEcFenBQdY=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796368711; v=1; x=1796973511; b=t/HCF6qJ7Q2kJ9we2x9ubKWXtx8s4LzpPbsWNuQ5fVfCXDYfu7WnTE+k4Yo0ioNYdEyi9J/9 qN7wlI3BdhJvTh/24y0pEwCByPk4CXJnatZoyqZ2nLVMDbakErYcMJQ6TRQY238laoK+ekpY1Z7 jsA1fFqqNF7Hp9eBCB1n/J5s= X-Envelope-To: linux-mm@kvack.org Received: by smtp.migadu.com with ESMTPS id 4ef55a4993031340; Fri, 04 Dec 2026 07:18:31 +0000 X-Mizu-Trace-ID: 4ef55a4993031340 X-Migadu-Flow: FLOW_OUT From: "Hui Zhu" To: Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Chris Down , zhangjiao2@cmss.chinamobile.com, Alireza Asgari , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Hui Zhu Subject: [PATCH v2 0/2] mm: memcg: fix memory.high allocator throttling Date: Fri, 4 Dec 2026 15:18:18 +0800 Message-ID: X-Mailer: git-send-email 2.53.0 X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Stat-Signature: i8ocqdxugjzcw96xuq4o6xrienyrssqj X-Rspam-User: X-Rspamd-Queue-Id: BA1E71A0009 X-Rspamd-Server: rspam09 X-Spam-Status: No, score=-14.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-HE-Tag: 1796368712-347754 X-HE-Meta: U2FsdGVkX1+rTPD0zVNIdCZJ68aHolmoKasn3elYecnPqtOLwN7Zl3kLiNeuTntB7an7PhHe/oBQOSGGCNgRaR4WrWb+G9hQIi8nk5zPFZxYwE5BicmnuN2IFDrAOrzH8yDPNVkuPi1aZuVbLx28W2VjUji7IyKN6VpOA2RZXN1b3Sj4tzMaj/U8SzaxC3sAXo0zKqdvJCgAhH8uKKq4qUxR7sMq/cW+Mcs9tUw9g2niF4fBTRI6riwfwQ8HGvD4VZFulJMPBmQ8PUCDOz7qMExxAC3B3/4hiwh10Rp41seaBgqjUxNSthTp7e30XPhc0UlV7Ga2cJBYoBTSKfvfpyUVwIZvyXrEzG5gA1Ymf3cVV+xYkHjDjjeBbu6DC3s8IdkEkAxfZ+ztkgD2pBo//9TNC+siKXdzrJpZsNSr6wEKEnXfKmHzOIuNPIx5rUr8niyEx/BMC3fjpxqkfQWKqf1NQ+BUx7Z2NScxgERenc+aWeAVynehA1DcYthQKMgPSvD9SvRKd7Qs5DfjLn6L3jKdeO3yWm7hCx+1S5OiDJZpdX60ESfLHfOaFJ8MRHVRN92f+3TWYZ7KvmP6iWPmJin8KacUAKGdQoHsOAVRrxFnQQtdA7tf9BNXQwQ7fyuGrFQr+g5wvLtjS3OmuO/kYTydKtnpN2lsIAnsAHUaq2x40cCzIj/0Ui732AGrnJtuSjkFbZHnS0jS+VJQkTXAODO8mKoirgdgYLljN8D5dXRpvfYGMmz9SsvBWyCZFtOT/DaOAvUUepbRDcR4uM2hOJCHZ++E3Bv15ISusZi5nh3zYkig/4HygTbO2wQni6z9NOUgMWEDmgf1eGECIogOjeX4wtexrmYOjF8YQNrXs8rYc0fcfdVR2rWzlRWgq6y0OrDvKtOhcDHBoPt7WNvJZJbIW8sNZed32igE6bbYnX4nVAn0RKPKbbNskg05sFZdM5yYUM69jA9aGd74Iwj C7SVhpQz NMEcSxU03r9lSeYV1RkkCOPhMqpSTNDmDfjK8A+Fn9LupuHaUKvk4wtWzZMAkHzXoeSV+k5M1XDEoTXTA+lVILjD8SDLa/bzHin5lpmWQvRMObKt7l3p3fg/aiGwfvV6qcDqufDHsDWOdMFKWATQZA+5J7wcEgkcqvQ9dGFtDaaZDQRuv2Ityx/sia4zGVgJfhdRNKGz7IH+X0gAfPZ8/mz8Y2etLZPaAx1U8y3fmBIyt0rdEdHKP4Iv1qIva7dvgzJkx5qfWZjbx57W+bpLPiBVMs/eQwrfQesfNbyi5rc7DDgyUkDW/i4R1ssGDR61MwkTx6LMR7Z8/1VgGKhqVN41ftJxnanibYp4k7EFWyCllnLxSWlPAHuZlFPtnkLcuGs3rE4gYL6F6R7uBd0oMUc1yCA== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Hui Zhu calculate_high_delay() turns how far a cgroup is over memory.high or memory.swap.high into a sleep penalty. Two independent defects corrupt that penalty, and since the caller treats "penalty_jiffies <= HZ / 100" as "nothing to do", a small result silently skips both the throttle and the MAX_RECLAIM_RETRIES reclaim loop. 1/2: the u64 product is stored into an unsigned long before being shifted right 34 bits, so on 32-bit kernels it truncates to zero and throttling is completely inert there. Broken since v5.6. 2/2: the u64 product itself wraps once a cgroup is about 130x over its limit (at HZ=1000), leaving an arbitrary result that can be exactly zero. memory.high has no lower bound, so a one-page limit with a few MB of usage gets there. Affects 64-bit kernels too. Broken since v5.4. v2 reworks both per Johannes Weiner's review [3] of Zhang Jiao's earlier patch [1]: the v1 overage cap is replaced by check_mul_overflow(), and calculate_high_delay() and the caller's penalty_jiffies are now u64, so the value is narrowed only after the caller's clamp. That also drops v1's in-function min(), which was undoing commit ff144e69f733 ("mm/memcg: move penalty delay clamping out of calculate_high_delay()"). The series is now 9 insertions and 5 deletions instead of 19 and 2. The two problems stay separate patches: different regressions with different Fixes tags and stable lifetimes (e26733e0d0ec, v5.6, for the 32-bit truncation; 0e4b01df8659, v5.4, for the overflow). Both are Cc'd to stable. This series consolidates the earlier duplicate work: Song Hu reported the overflow, proposed check_mul_overflow() [2] and co-developed the fix, and Zhang Jiao posted the first fix [1]. I offered Zhang Jiao a combined series with the overflow fix under his name and followed up a week later, but had no reply, so I am carrying it forward under my own name with credit to both. Verified: built for arm64 and for arm (multi_v7_defconfig plus MEMCG) with W=1, no warnings; checkpatch --strict is clean. The arithmetic matches exact 128-bit results across the whole tuning table and a 28M-case sweep: the reworked version is correct on every case, while the current code is wrong on 1439 of them at 64-bit and on all of them at 32-bit. Neither patch was run on real 32-bit hardware. Hui Zhu (2): mm: memcg: fix zero throttle delay on 32-bit kernels mm: memcg: fix memory.high throttle lost to u64 overflow mm/memcontrol.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) -- 2.53.0