The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Hui Zhu" <hui.zhu@linux.dev>
To: Johannes Weiner <hannes@cmpxchg.org>,
	Michal Hocko <mhocko@kernel.org>,
	Roman Gushchin <roman.gushchin@linux.dev>,
	Shakeel Butt <shakeel.butt@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
Cc: Hui Zhu <zhuhui@kylinos.cn>
Subject: [PATCH v2 0/2] mm: memcg: fix memory.high allocator throttling
Date: Fri,  4 Dec 2026 15:18:18 +0800	[thread overview]
Message-ID: <cover.1796367145.git.zhuhui@kylinos.cn> (raw)

From: Hui Zhu <zhuhui@kylinos.cn>

calculate_high_delay() turns how far a cgroup is over memory.high or
memory.swap.high into a sleep penalty. Two independent defects corrupt
that penalty, and since the caller treats "penalty_jiffies <= HZ / 100"
as "nothing to do", a small result silently skips both the throttle and
the MAX_RECLAIM_RETRIES reclaim loop.

1/2: the u64 product is stored into an unsigned long before being shifted
right 34 bits, so on 32-bit kernels it truncates to zero and throttling is
completely inert there. Broken since v5.6.

2/2: the u64 product itself wraps once a cgroup is about 130x over its
limit (at HZ=1000), leaving an arbitrary result that can be exactly zero.
memory.high has no lower bound, so a one-page limit with a few MB of usage
gets there. Affects 64-bit kernels too. Broken since v5.4.

v2 reworks both per Johannes Weiner's review [3] of Zhang Jiao's earlier
patch [1]: the v1 overage cap is replaced by check_mul_overflow(), and
calculate_high_delay() and the caller's penalty_jiffies are now u64, so
the value is narrowed only after the caller's clamp. That also drops v1's
in-function min(), which was undoing commit ff144e69f733 ("mm/memcg: move
penalty delay clamping out of calculate_high_delay()"). The series is now
9 insertions and 5 deletions instead of 19 and 2.

The two problems stay separate patches: different regressions with
different Fixes tags and stable lifetimes (e26733e0d0ec, v5.6, for the
32-bit truncation; 0e4b01df8659, v5.4, for the overflow). Both are Cc'd to
stable.

This series consolidates the earlier duplicate work: Song Hu reported the
overflow, proposed check_mul_overflow() [2] and co-developed the fix, and
Zhang Jiao posted the first fix [1]. I offered Zhang Jiao a combined series
with the overflow fix under his name and followed up a week later, but had
no reply, so I am carrying it forward under my own name with credit to
both.

Verified: built for arm64 and for arm (multi_v7_defconfig plus MEMCG) with
W=1, no warnings; checkpatch --strict is clean. The arithmetic matches
exact 128-bit results across the whole tuning table and a 28M-case sweep:
the reworked version is correct on every case, while the current code is
wrong on 1439 of them at 64-bit and on all of them at 32-bit. Neither
patch was run on real 32-bit hardware.

Hui Zhu (2):
  mm: memcg: fix zero throttle delay on 32-bit kernels
  mm: memcg: fix memory.high throttle lost to u64 overflow

 mm/memcontrol.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

-- 
2.53.0


             reply	other threads:[~2026-12-04  7:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  7:18 Hui Zhu [this message]
2026-12-04  7:18 ` [PATCH v2 1/2] mm: memcg: fix zero throttle delay on 32-bit kernels Hui Zhu
2026-12-04  7:18 ` [PATCH v2 2/2] mm: memcg: fix memory.high throttle lost to u64 overflow Hui Zhu

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=cover.1796367145.git.zhuhui@kylinos.cn \
    --to=hui.zhu@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=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=shakeel.butt@linux.dev \
    --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