From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.105 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796402187; b=m8UEzMS8ge9eo+nPLI6SX3cJyVpvgRX2JYcrDIDxux4z1K/OJodS97xEBNN3z7EHF36L Msx2ED/JWIslQl4mDc6tbmfrJtPWLbunIvEl31czFh2ALq4InXl77rGXWiEHCkbfXPeRy FHdcHiNme3snEvjaiWhEJl4lJQpFbAiGfUxiQ99l060zQRKjXiFVPzTpJBxCSUh202AK4 RJVuevpTwJKRer3cXMl+COESf7EM46kfiUXL/7mZq1pH5ELo19Gh6sQI2G8yc9bkm6u3Z P1J6xsSShaiiqtpCpL6LjKefm+LhLS3z/1v6cxGVEmQmcZwuG02oARAfazhhebrz7wA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796402187; 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=abTel1JbsmzRB1afUW+Zy74zCi29p9N6w4XQQALz+gadkoI+8EaPJ1zIpSotj5GoNRq4 xRtLiuDHH19JtsUQv383JLmgoZdXXf4jo3qGqA1daQ7NQyBg90lGYxdQEtNaPXAJmwHPx HpKfB1Iabm7d4Ts9TWDdYTJbgplOv66hi4bqVDwROZ+ZR73w3ludHTeX9dFH9H7teDKzg a91ZwAoRQmYbdJezgrVITPZZ6LAkyQAWhKzmrAcEizPfXxBZYUvFXQFb+wN8wG1TGLUBn L3C8XkrgFcAoF4OQjvTupOAMKML/W3Q7GK3snGNMz2K7pUBJXStt3+zc6qwYUIVpYpQ== 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=95.215.58.105 Received: from mta1.migadu.com (out-105.mta1.migadu.com [95.215.58.105]) (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 BAC12606A32F for ; Fri, 4 Dec 2026 16:36:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BAC12606A32F 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: linux-kernel@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: linux-kernel@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: linux-kernel@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