From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796368715; b=srK6nky8P9fFSCbD8FdKptbhIrp8+OvdxfDquZigiYlnTLAITSAXpfxdLh8khZfbQGFt h414vAlE2FY6fC5A7N3BJDmzB+znfXOTjcLrjJaj0Emq+U9BbXabpNOmqm1pmsGM3ZYCP 5rgUWkjSrwlpn/pBeKzFnNyYsLu4NG+aaUPj6EGwumVRmyi7+TgFq3NEUO0KYRdW3klg9 QNhGpi/2b+7kTp3XxcADosz5FgZ3C7cln4NHtVCr1qm2oZaPxI699TMDZZe/NfWXmU4Z2 P0xyuBnWUrgtvKTvmXPtiuSjw4O611EDeV+anqUe/mlQ5YYxrMewPXOe5zASMPLOLlw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796368715; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:MIME-Version:Content-Transfer-Encoding; bh=NG/lCyPS2SdyPa7jUI15lXmRSNg2iYggRdG6fliqSHI=; b=K/WfcQ06Uy0KdY345/7tLH7ppBfIkGhUbeO3g0YXVSq4eHPWHB0ny3fbAs5mXnwE98vz 3HhJnT1s9MaVcLkxkUJokeC3wpeAm+z7bUCchWJQua250vRiiLviBsIPjMPYD+Yvhu7p0 mrtT5b0eoZ5FOp+J2vcgptbSqrClPAUm5ut490McB59qsx/qxrpLy6VHPX3pH6LguhQX5 BhTWwxSE7lp+aQI+chPrY1beCaK6kdi6aDy8RyxIX4CBA+GsWe/0e+boFuS2j7eUGltm+ MPDP4Y6VKNQxjM9dT6/BwfthzJz2sH11/oYwPpGogW9byiixJjWo+DMaTf/Vqgu7SGA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="t/HCF6qJ"; arc=none smtp.remote-ip=95.215.58.45 Received: from mta1.migadu.com (out-45.mta1.migadu.com [95.215.58.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D689606A339 for ; Fri, 4 Dec 2026 07:18:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3D689606A339 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev 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 X-Envelope-To: cgroups@vger.kernel.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: cgroups@vger.kernel.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-Mailing-List: cgroups@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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