* + memcg-use-high_work-for-kernel-threads.patch added to mm-new branch
@ 2026-10-30 23:48 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-10-30 23:48 UTC (permalink / raw)
To: mm-commits, tj, roman.gushchin, muchun.song, mhocko, mhocko,
harry, hannes, shakeel.butt, akpm
The patch titled
Subject: memcg: use high_work for kernel threads
has been added to the -mm mm-new branch. Its filename is
memcg-use-high_work-for-kernel-threads.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/memcg-use-high_work-for-kernel-threads.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: Shakeel Butt <shakeel.butt@linux.dev>
Subject: memcg: use high_work for kernel threads
Date: Fri, 30 Oct 2026 13:54:14 -0700
Kernel threads never return to userspace, so deferred memory.high
reclaim does not run. Reclaim and throttling during a charge can also
delay work they do for other tasks.
Treat kernel threads like interrupts. Queue high_work for the first
cgroup over memory.high and skip reclaim and throttling in the charging
thread.
User workers created by create_io_thread() and vhost_task_create() keep
their current behavior. Vhost kernel threads use the new path, even when
they borrow the owner's mm.
The worker requests a fixed batch of pages each time. A fast allocator
can keep usage well above memory.high. Kernel threads also skip
memory.swap.high throttling and its high-event reporting. The memory.max
and memory.swap.max checks stay the same.
Link: https://lore.kernel.org/20261030205418.341214-4-shakeel.butt@linux.dev
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Suggested-by: Tejun Heo <tj@kernel.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: 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: Harry Yoo <harry@kernel.org>
---
mm/memcontrol.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
--- a/mm/memcontrol.c~memcg-use-high_work-for-kernel-threads
+++ a/mm/memcontrol.c
@@ -2714,6 +2714,7 @@ static void memcg_enforce_high(struct me
gfp_t gfp_mask)
{
bool allow_spinning = gfpflags_allow_spinning(gfp_mask);
+ bool use_worker = !in_task() || (current->flags & PF_KTHREAD);
/*
* If the hierarchy is above the normal consumption range, schedule
@@ -2732,8 +2733,12 @@ static void memcg_enforce_high(struct me
swap_high = page_counter_read(&memcg->swap) >
READ_ONCE(memcg->swap.high);
- /* Don't bother a random interrupted task */
- if (!in_task()) {
+ /*
+ * Don't make an unrelated interrupted task handle this charge.
+ * Kernel threads may be working for other tasks, so let a worker
+ * reclaim instead.
+ */
+ if (use_worker) {
if (mem_high) {
if (allow_spinning)
schedule_work(&memcg->high_work);
@@ -2760,6 +2765,10 @@ static void memcg_enforce_high(struct me
}
} while ((memcg = parent_mem_cgroup(memcg)));
+ /* Interrupts and kernel threads stop here. */
+ if (use_worker)
+ return;
+
/*
* Reclaim is set up above to be called from the userland
* return path. But also attempt synchronous reclaim to avoid
_
Patches currently in -mm which might be from shakeel.butt@linux.dev are
memcg-move-memoryhigh-enforcement-out-of-try_charge_memcg.patch
memcg-force-charges-from-reclaim-before-trying-the-limits.patch
memcg-use-high_work-for-kernel-threads.patch
memcg-use-high_work-for-remote-charges.patch
memcg-simplify-high-limit-handling-after-a-charge.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-30 23:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 23:48 + memcg-use-high_work-for-kernel-threads.patch added to mm-new branch Andrew Morton
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.