From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.248 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796444906; b=rcdDkh+IIEGfoOkfA4jJtuqNjFeO874heE2hwjUqPiGw3VbCHKFVKXhWdEaBdee6DEXj OVhGO4w9HPYqgFf9shQ4nV4/QZniQAq8dGXM2SIP/Jr8LkAUZISgHyLVibWgIxNPz5skY tXTg1ACMz/NaRwsdeICki22BVXimtuo+4riqxh/dMMEQsuO8vxj2QwIteMzEYN2G1vpAx iAVP33IeifrlXV0j9tZoQBgj4Z6jNitH6Y4J4FburSRAyVVQDppdnDhOAR2FupLykJoVL ipsL8QwaWcUoLO/F4lyvnrO+izbly6/cM4BK6nvfDEUusLPdZBnwAprf8ZbyJDNkGcg== 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=jIQI3YBYY/sc7ERcgRTdeSpCteYiiSpcilu2MHZBtvnySW1N8OCIpis2mT9AgnL7ptbI n00XS3fBlovpBZCbpzWZDCD7IsnIWx8DztwQ4vw2wZxA5ykADVM1zTKT2QugW3Fnm/VgK WqrMze/NYiidev9/7Pa0bc5FxE+mvxwlYz1gXDdR9JbaImxF/1nrWcw0EXVNMH67zXr4S 4yeUBZL2GPR5Gy+9gsTWbpDfik6O9y2sZFYc70LumKu+5vQsysaAuZdOcPszI9rBivq2o bF33c0Ad8uvFn6clEPSSPZhbi9ILKrSq28C8PHnoF59Jzx37Mg8yBOvCRRMgsMvyHYQ== 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=95.215.58.248 Received: from mta1.migadu.com (out-248.mta1.migadu.com [95.215.58.248]) (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 ED564606A322 for ; Sat, 5 Dec 2026 04:28:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ED564606A322 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: linux-kernel@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: linux-kernel@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: linux-kernel@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