From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.237 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796450341; b=CZjbEx41LFJXPqE8xM6lwk4tE+vW7dif9Vd92M3XciTWf0/1qu/POztRH2zd1m3cbaOZ iYYObmF+0Z2CP1GC59f2FaA9DPL8M5O4lAYP6wLREd36kmdrnzlGEckPwyVaod7CduTDh Y683gjiuLYs5wtgoayZJ68/gGK5Zxee0htr9JXdrMhyKYdvT+SQILuw4+JzY68xl8Gg6e LaQlyja8wJJBb7zFbAQaKfBwVl6EwgI/ZMT+w+D8G2hVbB6no1MT+t+e4KqNZ01ERVnfZ Id1+RyU22vkh/0ZrbmKIs5Nfl6klypXtyMMiKpEHewJdw3c0e8YkdLLFWOSD20r5r8g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796450341; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Content-Type:Mime-Version:Subject:From: In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References: To:X-Mailer; bh=7OHn8qwOHNUflRsSyDmZGbsRuaRUoWHimURAtAmlQWg=; b=rXHh97fadhboR0o79dJrx/Z3ABBnJIFwO6KE2lQ5NVEaL/FzV+IN8ee2BV0C1dBNpVhq VdwoYf4YZ+pPPFldX0u5KxbWLkJnrAQ0Eyv5NSh2G75TZ5NjxkLSDjCit5MqcHUWr5GrN Yw2nkkZMrXiAy3ZlmOSLQK3j6omejqe6DiCjCOatPTmOyoYGcJgq8aK/Ydabj2qrCfmXm bkH9bFB1i5HUrqyo9adLyYHFLQArsq8lKFfeuSVUPsL1DbqK2+ca81ZdiAbbf3mV4uOAw g9komdU2whKC79P6A7TEUGN23pcGB8KSB1YzhY2WhlTdebvhlLPaiyez14iRaEifTCw== 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=Nh6G8Vl0; arc=none smtp.remote-ip=91.218.175.237 Received: from mta0.migadu.com (out-237.mta0.migadu.com [91.218.175.237]) (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 02DC4606A32F for ; Sat, 5 Dec 2026 05:59:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 02DC4606A32F 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=Nh6G8Vl0 X-Envelope-To: cgroups@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=7OHn8qwOHNUflRsSyDmZGbsRuaRUoWHimURAtAmlQWg=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796450338; v=1; x=1797055138; b=Nh6G8Vl0RaRbf6vSNZbcVGJT2KF3zrTWT5vQDQD9JaRokeUhAHpWDInyZLLPp4ectre4m1NV 9AEWw1teuWBjX3ZG3mDI2o3q4ggZRtAjrJQ+gDVjBQL4sDPtqxkKR/GFhD24y//oEFF9skTIUz9 76rKefkMKuzlRLhcE6x9xQi4= X-Envelope-To: cgroups@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 6d6b5e78e569859f; Sat, 05 Dec 2026 05:58:58 +0000 X-Mizu-Trace-ID: 6d6b5e78e569859f X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset=us-ascii 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 (Mac OS X Mail 16.0 \(3901.200.71.1.16\)) Subject: Re: [PATCH v2 2/2] mm: memcg: fix memory.high throttle lost to u64 overflow From: Muchun Song In-Reply-To: <32198723709067dfefc0d7048e03586a25714453.1796367145.git.zhuhui@kylinos.cn> Date: Sat, 5 Dec 2026 13:58:43 +0800 Cc: Muchun Song , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , 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 Content-Transfer-Encoding: quoted-printable Message-Id: <631E9F89-3A1A-4DFD-9940-80AD198DB2E8@linux.dev> References: <32198723709067dfefc0d7048e03586a25714453.1796367145.git.zhuhui@kylinos.cn> To: Hui Zhu X-Mailer: Apple Mail (2.3901.200.71.1.16) > On Dec 4, 2026, at 15:18, Hui Zhu wrote: >=20 > From: Hui Zhu >=20 > 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=3D1000). 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 <=3D HZ / 100" exit, skipping both the throttle and = the > reclaim retry loop. >=20 > 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. >=20 > 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. >=20 > 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.chinamobi= le.com/ > Cc: stable@vger.kernel.org > Co-developed-by: Song Hu > Signed-off-by: Song Hu > Signed-off-by: Hui Zhu Acked-by: Muchun Song (ByteDance) Thanks.