From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.193 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796402188; b=dz2l6CVbnqYfz7QaCDafT5H4yC63ZlEbNK/aZtRtm+bgoZ1gfbbfeiPYC9lB2FrJcYTN CRWfu6ie+SM0YdK7nfTvOCUgxSeKHPUQ6M4Fk6x9OS1ZrceInxalYUVvqBZyiOQpG6gx7 nLXcRCYtbpfOb2k7zGzACIbBOTadO0twHVyUb4U1SiY7TuMfkOhqW7xMOL16mu2xouKXo tltfkn5q2x0p3nVEqNUi1QaMCJzZj2bl6JWybq07wxLcmD782ZBXXON5mL1hoajGrKDNj 4JZFBEVzUcZBewQcD/FCx95dm5PXC+HpOydZU9rm5bosMWdNgikopA53nJ+VIHB23fw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796402188; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=Pyb9GkQIWzQCUnpfJa2DRLjbakQGJJ05wdPqP+d8Gg8=; b=iMIi7QUb7reGevmBSTPxHe/YWGS7YbeZpjTOyM8hKN6kMO2UdygieetPUrB3Or1RFFTY iWm6w3fOAnNcMsybMlINA5cdVqutgzI65Ux5UpMYbDIr0LobT93xEaf7ZIWtg79s/Y2N+ UCLu8wp3Uoen0Vgyf/DLeebI8EsIyxxhSDSUDsmVeWHc6B6AVxBu2cncKLSzvUyeQ45QV jWdIvP2CtewZCDpfpCvEcuvkQFPcZnusZmI4fgpZqikxc1neu0WniB5Xl6PHpMPYwFUAz notiCM10nrWVTVPmKZgzPshe+4+2XUSfd0IN+LTNLAerNbRXOOVAKyfXnb4GN/SkOuA== 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=hcBpYMSG; arc=none smtp.remote-ip=91.218.175.193 Received: from mta0.migadu.com (out-193.mta0.migadu.com [91.218.175.193]) (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 AA626606A322 for ; Fri, 4 Dec 2026 16:36:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AA626606A322 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=hcBpYMSG X-Envelope-To: cgroups@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=wVGiZc2BbWO+FNrqePFcxsmP0s6X4u6DnESlyw1xNNs=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796402184; v=1; x=1797006984; b=hcBpYMSGrGmYN6pFvaJxFkxVcuqgmSJRT+B35PBOnJVMTYGeBG2BnnkN4wDKuT69tcdeh+k2 KojxdTEItQi0C1Agw226likO9cyzp/+dQLCaRYGm701IKwu3tm3mazQcPK3g1EGyr+vbLBge+Rq +94juKCfprdaye7hJMc5mMBs= X-Envelope-To: cgroups@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id a4dbaa9ac8ed91ec; Fri, 04 Dec 2026 16:36:24 +0000 X-Mizu-Trace-ID: a4dbaa9ac8ed91ec X-Migadu-Flow: FLOW_OUT Date: Fri, 4 Dec 2026 08:36:19 -0800 From: Shakeel Butt To: Hui Zhu Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , 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, Hui Zhu , stable@vger.kernel.org, Song Hu Subject: Re: [PATCH v2 2/2] mm: memcg: fix memory.high throttle lost to u64 overflow Message-ID: References: <32198723709067dfefc0d7048e03586a25714453.1796367145.git.zhuhui@kylinos.cn> 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <32198723709067dfefc0d7048e03586a25714453.1796367145.git.zhuhui@kylinos.cn> On Fri, Dec 04, 2026 at 03:18:20PM +0800, Hui Zhu wrote: > From: Hui Zhu > > 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. > > 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.chinamobile.com/ > Cc: stable@vger.kernel.org > Co-developed-by: Song Hu > Signed-off-by: Song Hu > Signed-off-by: Hui Zhu Acked-by: Shakeel Butt