From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796444906; b=B6SKAyvBeWS2Yq9N9Nd5Evs3qE9zj5wGR8b4m9/QIqPw5IsGVxaNvaPl+YRQCGoUVfVD FnzI6XR8hOuOqFXgxrd5DDkNz92o6WUS26z9XZJNuDE5TCQa/LL7udUdNFg4NNz8ImMMk nIxt1HkpGL0MPsIWBFHcXW0RozlapVurBelFP5C3mAbzU/6+Vb9m3GjpoEx207i7sDMI0 grwWgEbnFjoJ/+zJrJRdOdtTOpdRJWUEFl/GXnh5HJSvf8ejab9qPEw1hVAF/kjMdYhSb Fxxp2F1dt6eQxL8SPbgbXD6yGqwYt+jjKo0MSxSRVX7LVw1EuzlzaKK083F6dzxqhvQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796444906; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Cc:Subject:To:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=g2YVCVGkzJ2NZpSuwAUiZnyA8+ETEkTewsezf99C3tg=; b=h11D2GTzO25NddBd0HyuoIbLli2T0VOPIz2FtZvR2T5zOu7yTj1GWVxeTOlTaxRE5wuT WCnSoF3aWBxbXbdkK1SwaVQE7EOOtJz+R6PPoOce2eOcvaTUx9G1qfmSKusJZo0+SIY+a LpZD8BYvBbhwsOCYjv4GTpJH+SBM//bCscQAWOQ5c5uxefWMPkYfy/2vjD/A4/8Xb9MMn bwasKJER8hQ6kZFJsv/4NSzi9YAZNAuTuwOvrv6PhAGY+LZ07otCqjLPOnNrzM2vfHzK4 Sc4avwMvMmulH5OaL8OFrafwM/gw0nJH0rhyFKZAe3AcZv1fr90yg68eiuTaO4SUu7g== 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=eTy2MmFO; arc=none smtp.remote-ip=91.218.175.42 Received: from mta0.migadu.com (out-42.mta0.migadu.com [91.218.175.42]) (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 178C5606A32F for ; Sat, 5 Dec 2026 04:28:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 178C5606A32F 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=eTy2MmFO X-Envelope-To: stable@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=3Cnv+QFXQsrNb+Ndi0ATvI8QbFm/F0IIP9+nds9405U=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796444904; v=1; x=1797049704; b=eTy2MmFOEEhUdRdelWA+2FkV2aVPNGOrbpMnYcoesYUWt+Bnn1u/3QrbQJncJbTnJ5e8oLjb 67DZaZATJfy255xiOktTpT9U5Uh4sd6wBmJYwiq0gaTfKDnDvnmh5txCBfNTlIa+G6XEdqcHROH Xhp1RREdwrKnPpJBgiuru4JE= X-Envelope-To: stable@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id b0da3c034e956fc4; Sat, 05 Dec 2026 04:28:23 +0000 X-Mizu-Trace-ID: b0da3c034e956fc4 X-Migadu-Flow: FLOW_OUT Message-ID: Date: Sat, 5 Dec 2026 12:28:14 +0800 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 User-Agent: Mozilla Thunderbird Cc: cui.tao@linux.dev, Hui Zhu , stable@vger.kernel.org, Song Hu Subject: Re: [PATCH v2 2/2] mm: memcg: fix memory.high throttle lost to u64 overflow To: Hui Zhu , 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 References: <32198723709067dfefc0d7048e03586a25714453.1796367145.git.zhuhui@kylinos.cn> From: Tao Cui In-Reply-To: <32198723709067dfefc0d7048e03586a25714453.1796367145.git.zhuhui@kylinos.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 2026/12/4 15:18, Hui Zhu 写道: > 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: Tao Cui