The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Shakeel Butt <shakeel.butt@linux.dev>
To: Hui Zhu <hui.zhu@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	 Roman Gushchin <roman.gushchin@linux.dev>,
	Muchun Song <muchun.song@linux.dev>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Chris Down <chris@chrisdown.name>,
	 zhangjiao2@cmss.chinamobile.com,
	Alireza Asgari <alireza@asgari.net>,
	cgroups@vger.kernel.org,  linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, Hui Zhu <zhuhui@kylinos.cn>,
	 stable@vger.kernel.org, Song Hu <husong@kylinos.cn>
Subject: Re: [PATCH v2 2/2] mm: memcg: fix memory.high throttle lost to u64 overflow
Date: Fri, 4 Dec 2026 08:36:19 -0800	[thread overview]
Message-ID: <axLr7FjjNvqOT1XB@linux.dev> (raw)
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 <zhuhui@kylinos.cn>
> 
> 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 <husong@kylinos.cn>
> Signed-off-by: Song Hu <husong@kylinos.cn>
> Signed-off-by: Hui Zhu <zhuhui@kylinos.cn>

Acked-by: Shakeel Butt <shakeel.butt@linux.dev>

      parent reply	other threads:[~2026-12-04 16:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  7:18 [PATCH v2 0/2] mm: memcg: fix memory.high allocator throttling Hui Zhu
2026-12-04  7:18 ` [PATCH v2 1/2] mm: memcg: fix zero throttle delay on 32-bit kernels Hui Zhu
2026-12-04 14:02   ` Johannes Weiner
2026-12-04 16:30   ` Shakeel Butt
2026-12-04  7:18 ` [PATCH v2 2/2] mm: memcg: fix memory.high throttle lost to u64 overflow Hui Zhu
2026-12-04 14:03   ` Johannes Weiner
2026-12-04 16:36   ` Shakeel Butt [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=axLr7FjjNvqOT1XB@linux.dev \
    --to=shakeel.butt@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=alireza@asgari.net \
    --cc=cgroups@vger.kernel.org \
    --cc=chris@chrisdown.name \
    --cc=hannes@cmpxchg.org \
    --cc=hui.zhu@linux.dev \
    --cc=husong@kylinos.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=muchun.song@linux.dev \
    --cc=roman.gushchin@linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=zhangjiao2@cmss.chinamobile.com \
    --cc=zhuhui@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox