From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796393010; b=3zl/QrzdaL0iiXnS6TSrw1+2Km8/tnluim4TzdvlwfT77oXkBcY330OrxDilZuKge5EJ yUt/3lRMoMUl+m5vYzPQMdoRl/CnLkjEnPYY86QktIFOSDd4Vu0aVwSWPfezqAx3lQRuF pSF9PgAH0Wn8WpiRC3PHxedF5LX1q9F+CblNW3jFUmgfJvn4Hzdfdke1v+Y4mzteqsluq S4/4q8ZrV/xRmIxQXPd4SAwfA6jXIGNHBsrtPfpZKSawe5TYeLxv3AVxwm/MCosLDkJfG W/yGAkjWX+DZb6cETAaj1icSicRMTyKj/JkLz9kkxDTsrudPhdOKGjZsbCvd7D9WAsw== 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=4oFazau/QZYe1o6tSU0Xhk1mQJnFBZqS0/XlJwy3BisTVdUB/8O3rR4J5GGvQOeh85C0 8/ti7c7Y+46vwM6aq6YzRAUoEwGklWy4OT7+wFuLoT7XTeXUj6QJ02vbO+wComQbM8uzf Wps+QfH4TcY3hQZ05HpNzqsZg72G6ZvuW6VI3cr0Ur/+n6u00M8auaVc9ZhNqyL5yMN95 fv8/2NC0SPcf0bAMbLrX6oAZnTG4GVbEzQbpi8tMGDNHFDFMrfYak4onml7rCS0LLfxZf eYbqhvesy5LIgc1RgJvAM5WuAywFdzMzBni56EDorFym2z26GZwj1V56idg5ayBKHlw== 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.170 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) (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 7855C606A32C for ; Fri, 4 Dec 2026 14:03:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7855C606A32C 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-f170.google.com with SMTP id 00721157ae682-8b4d5e645d1so4781847b3.1 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=TksldgWU8chJDgBPX3c16X/gJhrgU6VaJ3jZvjC6pa/klBa2w1x0BzTFT2cM+WTBdq 0QHeREX2Zp2iS8hjXBvSjGKfjTc+PmoNcSFQBlB7lwvcKu+HyeobASJ0uOTYVGLo1DIQ Qjta1wtChqB9wdyx0CkWf9BlaMdhYJMWKgoSUc28wX48BX1/9o3+xTpUL/+DDxX1gI2W P/BQjwnxsA3QQ7eaJxK+/KwLobIwC10iRRK7jN8rFIk3POGWc0J9JjlCoT96FqUb/20O d2aTVxQd1HC0/602l3fq7DWWi+hlaYVWHPsXI64NcaytQe8mmGrVp05HDLDWEoW5dypl 0YgA== X-Forwarded-Encrypted: i=1; AL+hErGi4jpKN//XKbUIMvUT804cAbR0PV5h144M28rRlHydhaoyeEq6epsxBQAFgWPZAokLDPI4bJk=@vger.kernel.org X-Gm-Message-State: AB4q+uGPs5zBP1T9trxLWUyxfX5MYj9RY7ERhYUSe0gP0v1EgvLSgOX1 ET1HXryiWJ87QfjJwEOebuow5G6OEw5quupPAx1FKOHgmScmGbmyCPB1OqsX7S0UIQ8= X-Gm-Gg: AZFdTZftcPe/cQL4nZu0SZIIq+3bMBHZ/3dt6t69DgEU+788miWGWZ3hZjCBYfZtr9m pQ4Em1l0K782m76ezRdUe+LGLffmnu38BP2mH8xovjyBMx9KjlSg/Kp2D53lhKQt8dn/UbhN71h EXGqpMq7bhwFaqDt5SXNE/zLHcFXhQXy94r3ZdkyDwYHLIQIymbaMhPmK/XQF9pgfaaiWbEQjue WqMSrk4ZTnU5UAzkrmpTtu/xwKDNZ2tZalx2J2PV+pWM+0sDRzZ9xnKLSecsD+UH/CofPQ+VJjX 2Tdtw7aUrpxS3kzBmaOKqn/IvzkzbaAw/kOsswIisXKFZVvaoNmaycV0qJ8SaFsjgteB+EgDTsM Ou8/8mbDAYM7YBkH9zWA37j2pxF6K56r34qsh810TzVnt6EuPEVkXRe3pY9OSG3Jj8Wu2cQKrVL +P3G/bWJkQ7rt0D6tdDVAp37mxh1oSjnH0p/ujXtvfM9KvGOqoIjLG/9AObGFwveOYYKBYh8Bjm vHjtl65EpyLsV6sUuK56+A00gpWIyhXwBNEw5tNH7HQXKR3IYeTNBAoiu8VVl8xPb971CBwueFF ulKd2Dljz9H1CJno13LHvE1ESw== 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: stable@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?