All of lore.kernel.org
 help / color / mirror / Atom feed
* [to-be-updated] memcg-dont-call-schedule_work-when-no-spinning-is-allowed.patch removed from -mm tree
@ 2026-09-04 18:10 Andrew Morton
  0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-09-04 18:10 UTC (permalink / raw)
  To: mm-commits, vbabka, surenb, shakeel.butt, roman.gushchin,
	muchun.song, mhocko, ljs, liam, hannes, david, stevensd, akpm


The quilt patch titled
     Subject: memcg: don't call schedule_work when no spinning is allowed
has been removed from the -mm tree.  Its filename was
     memcg-dont-call-schedule_work-when-no-spinning-is-allowed.patch

This patch was dropped because an updated version will be issued

------------------------------------------------------
From: David Stevens <stevensd@google.com>
Subject: memcg: don't call schedule_work when no spinning is allowed
Date: Mon, 31 Aug 2026 16:43:39 -0700

Memcg charging can be done from any context, but calling schedule_work()
isn't safe from an NMI.  If memory.high is breached from a context where
spinning isn't allowed, use irq_work to schedule the reclaim work.

Link: https://lore.kernel.org/20260831234339.280376-1-stevensd@google.com
Fixes: 3ac4638a734a ("memcg: make memcg_rstat_updated nmi safe")
Signed-off-by: David Stevens <stevensd@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: David Hildenbrand <david@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 include/linux/memcontrol.h |    1 +
 mm/memcontrol.c            |   12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

--- a/include/linux/memcontrol.h~memcg-dont-call-schedule_work-when-no-spinning-is-allowed
+++ a/include/linux/memcontrol.h
@@ -206,6 +206,7 @@ struct mem_cgroup {
 	spinlock_t	 peaks_lock;
 
 	/* Range enforcement for interrupt charges */
+	struct irq_work high_irq_work;
 	struct work_struct high_work;
 
 #ifdef CONFIG_ZSWAP
--- a/mm/memcontrol.c~memcg-dont-call-schedule_work-when-no-spinning-is-allowed
+++ a/mm/memcontrol.c
@@ -2440,6 +2440,11 @@ static void high_work_func(struct work_s
 	reclaim_high(memcg, MEMCG_CHARGE_BATCH, GFP_KERNEL);
 }
 
+static void high_irq_work_func(struct irq_work *work)
+{
+	schedule_work(&container_of(work, struct mem_cgroup, high_irq_work)->high_work);
+}
+
 /*
  * Clamp the maximum sleep time per allocation batch to 2 seconds. This is
  * enough to still cause a significant slowdown in most cases, while still
@@ -2848,7 +2853,10 @@ done_restock:
 		/* Don't bother a random interrupted task */
 		if (!in_task()) {
 			if (mem_high) {
-				schedule_work(&memcg->high_work);
+				if (allow_spinning)
+					schedule_work(&memcg->high_work);
+				else
+					irq_work_queue(&memcg->high_irq_work);
 				break;
 			}
 			continue;
@@ -4223,6 +4231,7 @@ static struct mem_cgroup *mem_cgroup_all
 		goto fail;
 
 	INIT_WORK(&memcg->high_work, high_work_func);
+	init_irq_work(&memcg->high_irq_work, high_irq_work_func);
 	vmpressure_init(&memcg->vmpressure);
 	INIT_LIST_HEAD(&memcg->memory_peaks);
 	INIT_LIST_HEAD(&memcg->swap_peaks);
@@ -4431,6 +4440,7 @@ static void mem_cgroup_css_free(struct c
 		static_branch_dec(&memcg_bpf_enabled_key);
 
 	vmpressure_cleanup(&memcg->vmpressure);
+	irq_work_sync(&memcg->high_irq_work);
 	cancel_work_sync(&memcg->high_work);
 	free_shrinker_info(memcg);
 	mem_cgroup_free(memcg);
_

Patches currently in -mm which might be from stevensd@google.com are



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-04 18:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04 18:10 [to-be-updated] memcg-dont-call-schedule_work-when-no-spinning-is-allowed.patch removed from -mm tree 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.