From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.247 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796444907; b=W1b42pbrqJuTOJX4PsX01fGn7VMphGlZpGWnvmIsMl7T0KHG+PwSRYdiCXbADwJ1z7Xd qNiekBDXXQTa699m5UXUk08OufDl+Jf1cgR9+vU71HDAP/1Ss1H72baVwGoWpKwH1Blqo beVItrnl3WNSM0zOrIE59pwkX52vJ0AtdQgcZBduGuVMt+Ibacg01PQYDM7xv4PS8Mt0o 7dFTxi+ksx5B5UQZIWG1McNp9clxQIFVhH+nI5TEkko+CTBTE/Cl3myGF4CNw2q0FZU+7 fR9R2S2YKMwmCI7R69G5GVlfEobTNWEO80PrtTi7Ad52qss95caJ1L1AnSi3i3yg7Jg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796444907; 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=St7zkwI8cvFSQ+UqJUzK1S0NtJCtSukbeB2FQM9VEEJ6kf7yt4Z5zZDXN+rLRwMbq1MW vrzws+kVMolP+gKEOj02iM9sw8efdNoDoMX3hfS9XM1yy3qns4VfXtCSkjlnjFKxxbXqV ZLKxZVZvE+6K3EghBBZpmxqLVDo2NsA5R8uo5XYjP05ysGRMWdyOB5ZbkkNqFHzz3LUrG IW8FadsJsw/VNKYtenMTsaXGUj+q1K2nRy4yjhOGqILOl/hCQz4gxgMTXBuNtsuMwYK7K sRSeuI0/RfxY0yYTSYnKMR9cM7501LmRRnDIrZTGe2O9T52K7ZwDZpcPh2se9gFMCFg== 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.247 Received: from mta1.migadu.com (out-247.mta1.migadu.com [95.215.58.247]) (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 ED583606A32D for ; Sat, 5 Dec 2026 04:28:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ED583606A32D 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: cgroups@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: cgroups@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: cgroups@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