Re: [PATCH 0/2] mm: memcg: fix memory.high allocator throttling

From: Hui Zhu

Date: Wed Nov 18 2026 - 00:38:59 EST



2026/11/18 06:17, Chris Down:
Hi Hui,

Thanks for fixing these, I've verified that these fix the issues
reported.

That said, Zhang Jiao sent a fix for the same two problems a few weeks
ago, and Johannes thought the overage cap there was a bit of a magic
value, which we have plenty of in mm already, and I agree we shouldn't
add more [1].

Could you please coordinate so we don't have two patchsets doing the
same thing?

Chris

[1] https://lore.kernel.org/all/auNrakxaET8qkuAn@xxxxxxxxxxx/

Hi Chris, Joshua, Zhang Jiao,

Chris: thanks for the pointer, and apologies for the duplicate. I missed
Zhang Jiao's patch [1], and Song Hu's earlier report of the overflow, which
already proposed check_mul_overflow() [2]. I've added Zhang Jiao to the
thread so we can settle the coordination here rather than off-list.

You and Johannes are right about the cap. I've dropped
MEMCG_MAX_DELAY_OVERAGE and reworked 2/2 into the shape Johannes suggested,
with calculate_high_delay() and the caller's penalty_jiffies both in u64 so
the value is narrowed only after the caller's clamp. That also removes the
in-function min() from 1/2, which was undoing ff144e69f733 ("mm/memcg: move
penalty delay clamping out of calculate_high_delay()"). The series shrinks
from 19 insertions to 9.

Joshua: the Fixes tag is the right one, though I can see why the diff
suggested otherwise. The division comes from 0e4b01df8659; my patch only
touched that line to add the clamp. The bug is the reordering in
e26733e0d0ec, which replaced

    penalty_jiffies = ((u64)overage * overage * HZ)
        >> (MEMCG_DELAY_PRECISION_SHIFT + MEMCG_DELAY_SCALING_SHIFT);

with

    penalty_jiffies = max_overage * max_overage * HZ;
    penalty_jiffies >>= MEMCG_DELAY_PRECISION_SHIFT;
    penalty_jiffies >>= MEMCG_DELAY_SCALING_SHIFT;

Before that, the shift ran on the u64 temporary and the narrowing into
unsigned long happened afterwards. After it, the value is narrowed
first, so shifting it right by 34 always yields zero. The division plays
no part, and in v2 the diff no longer goes near it. Your other point is
settled by the same rework: with the clamp gone, the comment goes too.

How I'd like to proceed:

 - Zhang Jiao: would it be OK if I send the combined series? The overflow
   fix stays under your name and keeps your changelog, in the shape
   Johannes suggested, and I'd carry the 32-bit truncation alongside it in
   the same series. If you would rather send it yourself, or split it
   differently, say so and I'll follow.

 - Song Hu and I have been in touch off-list, and they are working in this
   area as well, so the patches under my name will carry them as
   Co-developed-by.

 - v2 will include what was missing before: a Fixes tag for each of the two
   regressions (e26733e0d0ec, v5.6, for the 32-bit truncation;
   0e4b01df8659, v5.4, for the overflow), Cc: stable, a changelog that says
   plainly that throttling was completely inert on 32-bit, and the wrap
   threshold corrected to about 130x at HZ=1000 -- the 4096x figure misses
   the HZ factor.

Two separate patches rather than one, because they are different
regressions with different lifetimes, which matters for the stable
backports.

One number that may be worth putting in the changelog: the smallest
exact-zero case is memory.high at one page with usage at 2049 pages, where
max_overage is exactly 2^31 and the product wraps to zero.

Thanks,
Hui

[1] https://lore.kernel.org/all/20261029073857.974-1-zhangjiao2@xxxxxxxxxxxxxxxxxxxx/
[2] https://lore.kernel.org/all/20260818012115.65838-1-husong@xxxxxxxxxx/