From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,zhangjiao2@cmss.chinamobile.com,
stable@vger.kernel.org,shakeel.butt@linux.dev,roman.gushchin@linux.dev,
muchun.song@linux.dev,mhocko@kernel.org,husong@kylinos.cn,hannes@cmpxchg.org,
cuitao@kylinos.cn,chris@chrisdown.name,alireza@asgari.net,zhuhui@kylinos.cn,
akpm@linux-foundation.org
Subject: + mm-memcg-fix-zero-throttle-delay-on-32-bit-kernels.patch added to mm-new branch
Date: Fri, 04 Dec 2026 23:32:17 -0800 [thread overview]
Message-ID: <20261205073217.C486D1F0092B@smtp.kernel.org> (raw)
In-Reply-To: <1ef1fa130f9bd4a94bf92335486729f05034c30d.1796367145.git.zhuhui@kylinos.cn>
The patch titled
Subject: mm: memcg: fix zero throttle delay on 32-bit kernels
has been added to the -mm mm-new branch. Its filename is
mm-memcg-fix-zero-throttle-delay-on-32-bit-kernels.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-memcg-fix-zero-throttle-delay-on-32-bit-kernels.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Hui Zhu <zhuhui@kylinos.cn>
Subject: mm: memcg: fix zero throttle delay on 32-bit kernels
Date: Fri, 04 Dec 2026 15:18:19 +0800
Patch series "mm: memcg: fix memory.high allocator throttling", v2.
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.
This patch (of 2):
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.
Link: https://lore.kernel.org/cover.1796367145.git.zhuhui@kylinos.cn
Link: https://patch.msgid.link/1ef1fa130f9bd4a94bf92335486729f05034c30d.1796367145.git.zhuhui@kylinos.cn
Fixes: e26733e0d0ec ("mm, memcg: throttle allocators based on ancestral memory.high")
Signed-off-by: Hui Zhu <zhuhui@kylinos.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Shakeel Butt <shakeel.butt@linux.dev>
Reviewed-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Chris Down <chris@chrisdown.name>
Cc: Alireza Asgari <alireza@asgari.net>
Cc: zhang jiao <zhangjiao2@cmss.chinamobile.com>
Cc: Song Hu <husong@kylinos.cn>
Cc: Tao Cui <cuitao@kylinos.cn>
Cc: <stable@vger.kernel.org>
mm/memcontrol.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/mm/memcontrol.c~mm-memcg-fix-zero-throttle-delay-on-32-bit-kernels
+++ a/mm/memcontrol.c
@@ -2623,10 +2623,10 @@ static u64 swap_find_max_overage(struct
* Get the number of jiffies that we should penalise a mischievous cgroup which
* is exceeding its memory.high by checking both it and its ancestors.
*/
-static unsigned long calculate_high_delay(unsigned int nr_pages,
- u64 max_overage)
+static u64 calculate_high_delay(unsigned int nr_pages,
+ u64 max_overage)
{
- unsigned long penalty_jiffies;
+ u64 penalty_jiffies;
if (!max_overage)
return 0;
@@ -2660,7 +2660,7 @@ static unsigned long calculate_high_dela
*/
void __mem_cgroup_handle_over_high(gfp_t gfp_mask)
{
- unsigned long penalty_jiffies;
+ u64 penalty_jiffies;
unsigned long pflags;
unsigned long nr_reclaimed;
unsigned int nr_pages = current->memcg_nr_pages_over_high;
_
Patches currently in -mm which might be from zhuhui@kylinos.cn are
mm-vmstat-annotate-data-race-in-zone_page_state_snapshot.patch
mm-mglru-use-a-smaller-batch-in-fill-drain_evictable.patch
mm-mglru-reset-the-mm-iteration-cursor-in-try_to_inc_max_seq_nowalk.patch
mm-compaction-annotate-data-race-for-zone-free_areanr_free.patch
mm-memcg-fix-zero-throttle-delay-on-32-bit-kernels.patch
mm-memcg-fix-memoryhigh-throttle-lost-to-u64-overflow.patch
next prev parent reply other threads:[~2026-12-05 7:32 UTC|newest]
Thread overview: 11+ 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-05 7:32 ` Andrew Morton [this message]
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
2026-12-05 4:28 ` Tao Cui
2026-12-05 5:58 ` Muchun Song
2026-12-05 7:32 ` + mm-memcg-fix-memoryhigh-throttle-lost-to-u64-overflow.patch added to mm-new branch Andrew Morton
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=20261205073217.C486D1F0092B@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=alireza@asgari.net \
--cc=chris@chrisdown.name \
--cc=cuitao@kylinos.cn \
--cc=hannes@cmpxchg.org \
--cc=husong@kylinos.cn \
--cc=mhocko@kernel.org \
--cc=mm-commits@vger.kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.