Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] mm/page_alloc: drop the pcp lock before re-enabling IRQs
@ 2026-11-25 21:27 Joshua Hahn
  2026-11-25 21:27 ` [PATCH 1/3] mm/page_alloc: drop the pcp lock before enabling IRQs after a drain Joshua Hahn
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Joshua Hahn @ 2026-11-25 21:27 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Vlastimil Babka, Johannes Weiner, Suren Baghdasaryan,
	Michal Hocko, Brendan Jackman, Zi Yan, linux-mm, kernel-team

When the zone lock needs to be acquired from within the pcp lock
(due to refills or drains), IRQs are disabled to prevent deadlocks
with the IRQ handler. Today it looks like this:

pcp lock
  IRQ disabled
    zone lock
    zone unlock
  IRQ enabled
pcp unlock

So any interrupt that queues during the IRQ disabled section fires
before the pcp unlock. This is not a rare operation; the zone lock
remains one of the most contended locks on large systems. 

Together, those two observations mean that any IRQ handler that requires
taking the pcp lock will fire before the interrupted task can let go of
the pcp lock, and the handler will always fall back to the already
contended zone lock.

In Meta production workloads, we've seen softlockups on large machines
where one CPU spent 23s in an RCU softirq freeing page tables, and
taking zone->lock once per page because it had interrupted a task
already holding the pcp lock.

Instead, keep the IRQ disabled until the pcp unlock, so that interrupt
handlers can have a better chance at taking the pcp lock and relieving
contention on the zone lock:

pcp lock
  IRQ disabled
    zone lock
    zone unlock
pcp unlock
  IRQ enabled

This series was tested on a 128-vCPU KVM guest, where every vCPU faults
in and MADV_DONTNEEDs in a loop. The "pcp fallbacks" (taking the zone
lock instead of the pcp lock) and long softirqs were summed across 6
runs of 30 seconds each.

+----------+---------------+-------------------+-----------------+
|          | pcp fallbacks | callback avg (ms) | softirqs > 65ms |
+----------+---------------+-------------------+-----------------+
| mm-new   |        135590 |                14 |             832 |
| +patch 1 |         10481 |               1.5 |             116 |
| +patch 2 |          2327 |               0.6 |              55 |
| +patch 3 |           190 |               0.6 |              10 |
+----------+---------------+-------------------+-----------------+

Running the same tests with PROVE_LOCKING, DEBUG_VM, and DEBUG_PREEMPT
also raised no concerns. 

Joshua Hahn (3):
  mm/page_alloc: drop the pcp lock before enabling IRQs after a drain
  mm/page_alloc: drop the pcp lock before enabling IRQs after a refill
  mm/page_alloc: disable IRQs around the remaining pcp drains

 mm/page_alloc.c | 59 +++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 50 insertions(+), 9 deletions(-)


base-commit: 9f004372ebeb18fdeb699f9880a0e472df90135b
-- 
2.53.1-Meta



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-26 21:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 21:27 [PATCH 0/3] mm/page_alloc: drop the pcp lock before re-enabling IRQs Joshua Hahn
2026-11-25 21:27 ` [PATCH 1/3] mm/page_alloc: drop the pcp lock before enabling IRQs after a drain Joshua Hahn
2026-11-26 21:27   ` sashiko-bot
2026-11-25 21:27 ` [PATCH 2/3] mm/page_alloc: drop the pcp lock before enabling IRQs after a refill Joshua Hahn
2026-11-25 21:27 ` [PATCH 3/3] mm/page_alloc: disable IRQs around the remaining pcp drains Joshua Hahn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox