Re: [PATCH v2 1/2] mm: memcg: fix zero throttle delay on 32-bit kernels
From: Johannes Weiner
Date: Fri Dec 04 2026 - 09:02:24 EST
On Fri, Dec 04, 2026 at 03:18:19PM +0800, Hui Zhu wrote:
> From: Hui Zhu <zhuhui@xxxxxxxxxx>
>
> calculate_high_delay() stores max_overage * max_overage * HZ, computed as
> u64, into an unsigned long before shifting it right by 34 bits in total.
> On 32-bit kernels the store truncates the value to its low 32 bits, so the
> shift always yields zero: memory.high and memory.swap.high throttling is
> completely inert there. And since the caller reads "penalty_jiffies <=
> HZ / 100" as "nothing to do", the MAX_RECLAIM_RETRIES reclaim loop is
> skipped as well.
>
> Keep the intermediate in u64 so the shifts see the full width. Also make
> the function return u64, and the caller's penalty_jiffies u64, so the
> value is narrowed only after the caller has clamped it to
> MEMCG_MAX_HIGH_DELAY_JIFFIES. Nothing changes on 64-bit kernels, where
> unsigned long is already 64 bits wide.
>
> Fixes: e26733e0d0ec ("mm, memcg: throttle allocators based on ancestral memory.high")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Hui Zhu <zhuhui@xxxxxxxxxx>
Reviewed-by: Johannes Weiner <hannes@xxxxxxxxxxx>