From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796393010; b=i8+h2IhvihS3P/AT5ew/8tQrbS4TlC7DTf4JlJgbLFbkngFuEH4GV3vyMShfsDz4urLF Ha6mjLI2vfxis+JsqJ2+FLKQuylV8zvnhV83rAYbzTpVa3e/Xl1gTXh3MoUv6Zwh4/0um sxHmy1v5iC033QH970W4adyuBrZVOCB7siaIMGVBM164LW3bn6FRSbWXclnMeL3/kch5G F1mDGXLXCAENKrHdJ9P7UvAk+FXNpxuBtDIJ17z7wF1E1BaFzTeqv4iHYfGTYrtqORCyN aIpPY4IedJ7Pcg4M/NcLuyg/3wOB3Z98+GQyR/84ikZeZeO9CBkyHjPZKfqOvrg2mxw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796393010; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=9GssfkuMGb4wrhpEbEwLqAB/nsLgsTHBOULzF6uGB00=; b=H9TGj9fLBmS/5X9koSzeHT7aKDyQdnDJfW4YakF/A3S48l6ATDLXotn0UTU4fusYrrcQ TgAyt70mb4Z9M3o0LHxOc6hgYYSPdBSfgqT70I/h9DCbNbuWJPEJxxC/N4y9D3Rjfk5fY el3JLdh6dJPDzC/Z/f+sJ1ch0QHNZr/u/BwGrwqf1DayIpcsEbfYqx/jwCPohT4kzkY3s 4mFsewrkP05hgF/s0XJS+njN17rYYblPj3isXIQ/J38jCy1Nldkik53GKDyhxt8izsM1A 6z0obD6dEUWUCcjRSQ7EH6j+UdGAF0euOhM/shBiLzAIhFhe/at9aeSum/ihY1bxOTA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass header.d=cmpxchg.org header.i=@cmpxchg.org header.a=rsa-sha256 header.s=google header.b=AAqkuqKA; arc=none smtp.remote-ip=209.85.128.181 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (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 542C0606A322 for ; Fri, 4 Dec 2026 14:03:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 542C0606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.a=rsa-sha256 header.s=google header.b=AAqkuqKA Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-8b60548d721so6516487b3.2 for ; Fri, 04 Dec 2026 06:03:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1796393009; x=1796997809; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=9GssfkuMGb4wrhpEbEwLqAB/nsLgsTHBOULzF6uGB00=; b=AAqkuqKAVua68qcTTnoAx76uv/8hzO8qnKbpJ1kEsZNoJ0i7cOsfCwf+sg9y/R+YxW jFw3rnP0XFWJbmwgyP9TSBG2pu7Lykl21ZqmWD9n32ud7NXQGdVOuJ6zrQuTEahTbFo3 WwWcyOzTVK7P7C3Trl0gKXltdxVo6JVhagPUhfk/F5UJeuo29yT+uWpjbr0NuJh+zHop iybpbNAcF4H6phSvdfbW4OtIluq/+1C9OKFJDiP2t4lsGk7W5O1M4SpZQPfPzeGBevY8 01gZNc3ZZcNSuGp39CTEEhi2/Eps6VOKOmrTSi8ww2Ivohu85z7UGts/cWFEP7vvcehI Mh+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796393009; x=1796997809; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9GssfkuMGb4wrhpEbEwLqAB/nsLgsTHBOULzF6uGB00=; b=iYq7pb4YIi+kr2iP19Mf1H8kcxpTERipivgL3GNAUlEKn0uESstI88wSdK8MMeA9NY ueafH91hxzXorFZ+aR2vXsaHyftEkNVMkdbkllqhUg/kxEXTvoXJHW+xVzd+R16l/BY7 TOuRdVJWwJXwdNmsEzeyZhVDqkza/rPLvV1Iu40HX5YhfnGheZq4D1gkQ0sIbKGPZ9kv /omw4KzSetPaNOdqUDXH8GpBcc21E+70o0hhcLeTU7YndglI5UeD7EMWglS9CE4GbEpF PAky3feYjKHokqb4bjc2Xn6IWkdZuZOOatt4Sy9P9xOgZjL1AYoFQs75GXVMfgm8R0iH PWbg== X-Forwarded-Encrypted: i=1; AL+hErGBd8BK6N7DfT7muAItlnFvgs350pHBNzOz/MDRyV8mG4hyqpHtC+E2ql4dsBXlHRxLPbvrqMGtUWpxDpA=@vger.kernel.org X-Gm-Message-State: AB4q+uF2wBc2Azzc0+qyDk4b5XqItKBZC2jsejFFeoeprBJnXwuNk1SF UBw7Qa/7y29mJKC4eUVKITYfzi9F1mZBoJlI7aTYmPqF/3miIYtGh6ZG2ezdvZcv2x8= X-Gm-Gg: AZFdTZebkAmI/ckaSyy6FhZVq8bjenOaeibeBNkTVvKhYLtYZqWO9WA2dG24C/JqGUh BJm4ZJKRw7gU1bc+7DmXTuD8qRxIdvmcy/jrft3dEgvascOntX9al0A6/wrrrcAg64GOvMFFyCC +yoMc5oFECLHZssrurhsAmtsidQBK2I8ivsHBIF30oXGWdEandcFT1qNhcFE3lITudmp9JWmSgR HKEJYobEjICiS33DodiFbiOktz3NxYUtiLE8lpYyBtJZp3VMvOILLbd8yucHS+bZEllfLoBXxXT g7lCFYdJRbdJclMS/WV6PXOU5UTfYpGRBsiuDjAFqvJwkSErIIFaL0D+OBojg5nkhJjyaYOCZU+ qtW/jqApeVj6yLCM+ufTpUYz6OcAZyU9+RMg8ymo/ioRC/nQs0k0m4/Cwb9+6v+ppkm6sOLLmt4 P968676EAMXYnjXSoOUb3WShqUJCCIoD6Mp0yk8tRAg+8/Qukj5gbcaWtK06KZBnYnNyXMnmtxG spDhPY2+yV8lAcvF324I3aeF9XcvSRFDR8Kht55t+UkMQfmRBuldR4WLEIbzfxCb6ngG4SaipLl o3jpuSAY1gFhDqHQX+BO1EQNNg== X-Received: by 2002:a05:690c:6806:b0:8b2:ff8c:63b5 with SMTP id 00721157ae682-8b660d78611mr9145397b3.46.1796393009344; Fri, 04 Dec 2026 06:03:29 -0800 (PST) Received: from localhost ([2605:8600:200:dc6:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id 00721157ae682-8b660869004sm9808797b3.10.2026.12.04.06.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Dec 2026 06:03:28 -0800 (PST) Date: Fri, 4 Dec 2026 09:03:28 -0500 From: Johannes Weiner To: Hui Zhu Cc: 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, 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 Reviewed-by: Johannes Weiner Andrew, could you please pick those for 7.4 still?