From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.239 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796450342; b=aeB4cYBmqOwB22V5vDJ5oBBmFkTS1CJmg+T7HjGALb5DIeZZ562Vre5FLj4mkDEpWwpn xhOYA8PCIruooTd+UupmhY6G6SO7nRRLtBq6QR4IyBq+ulSEasO8IMVqZYKRBQouOKHi6 cso8vlhIiMgO7nypjwuDMvyehyc+nIle/muV1uL0vt8Fxwp6WW8z9+WMih+9I6p+SIBNz nmPzct8vEZPHZh4xMvjI+e+58rKYA9JWHzHMczBvusVGahOg+x3iREvLaDiC3DWnDBFco teLp5PVW/gil6Dehtx8yuu94UvjvKE1PgBT4O4PqOVv4ousQl2Cz0yIgOMmBq/nHZNA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796450342; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Content-Type:Mime-Version:Subject:From: In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References: To:X-Mailer; bh=7OHn8qwOHNUflRsSyDmZGbsRuaRUoWHimURAtAmlQWg=; b=wXEDqVFmzm4nJLc2RDTts85EU/rab4lbyTeKYqbca/7e4D95lF9b+p+dlq5ZE7/aSSD3 FzrW8hPmxRcids9p/SVXdL4eGTbYUkLfXlg3XAUbbnHl7rXrl1ekvaG8zft/z3s3zIdqI rdvH0eDOmL3WzNNYTn8VY++iuZ0rWArEGLDip86OS/YYOvdZw10R/djDfdsozcewvsOlh WfBnomxJLfFqLpwqDAFuIcGWVRyOV/lw57tlcbiMtgXFd5mgmR3k3OmwHiPFTsyUzUP2x 0pkoh3iZPPpBDwMmyZ7FDzhs2mKOrLEQoBVfdelxmVkHvD+nzowttiyGSRLBRxXX33A== 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=Nh6G8Vl0; arc=none smtp.remote-ip=91.218.175.239 Received: from mta0.migadu.com (out-239.mta0.migadu.com [91.218.175.239]) (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 E901B606A32D for ; Sat, 5 Dec 2026 05:59:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E901B606A32D 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=Nh6G8Vl0 X-Envelope-To: stable@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=7OHn8qwOHNUflRsSyDmZGbsRuaRUoWHimURAtAmlQWg=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796450338; v=1; x=1797055138; b=Nh6G8Vl0RaRbf6vSNZbcVGJT2KF3zrTWT5vQDQD9JaRokeUhAHpWDInyZLLPp4ectre4m1NV 9AEWw1teuWBjX3ZG3mDI2o3q4ggZRtAjrJQ+gDVjBQL4sDPtqxkKR/GFhD24y//oEFF9skTIUz9 76rKefkMKuzlRLhcE6x9xQi4= X-Envelope-To: stable@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 6d6b5e78e569859f; Sat, 05 Dec 2026 05:58:58 +0000 X-Mizu-Trace-ID: 6d6b5e78e569859f X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset=us-ascii X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3901.200.71.1.16\)) Subject: Re: [PATCH v2 2/2] mm: memcg: fix memory.high throttle lost to u64 overflow From: Muchun Song In-Reply-To: <32198723709067dfefc0d7048e03586a25714453.1796367145.git.zhuhui@kylinos.cn> Date: Sat, 5 Dec 2026 13:58:43 +0800 Cc: Muchun Song , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Andrew Morton , Chris Down , zhangjiao2@cmss.chinamobile.com, Alireza Asgari , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hui Zhu , stable@vger.kernel.org, Song Hu Content-Transfer-Encoding: quoted-printable Message-Id: <631E9F89-3A1A-4DFD-9940-80AD198DB2E8@linux.dev> References: <32198723709067dfefc0d7048e03586a25714453.1796367145.git.zhuhui@kylinos.cn> To: Hui Zhu X-Mailer: Apple Mail (2.3901.200.71.1.16) > On Dec 4, 2026, at 15:18, Hui Zhu wrote: >=20 > From: Hui Zhu >=20 > 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=3D1000). 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 <=3D HZ / 100" exit, skipping both the throttle and = the > reclaim retry loop. >=20 > 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. >=20 > 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. >=20 > Fixes: 0e4b01df8659 ("mm, memcg: throttle allocators when failing = reclaim over memory.high") > Link: = https://lore.kernel.org/all/20260818012115.65838-1-husong@kylinos.cn/ > Link: = https://lore.kernel.org/all/20261029073857.974-1-zhangjiao2@cmss.chinamobi= le.com/ > Cc: stable@vger.kernel.org > Co-developed-by: Song Hu > Signed-off-by: Song Hu > Signed-off-by: Hui Zhu Acked-by: Muchun Song (ByteDance) Thanks.