rmqueue_pcplist() refills an empty pcp list with rmqueue_bulk(), which spins on zone->lock with IRQs disabled. An interrupt that comes in the meantime will run while the pcp lock is held, meaning the softirqs fall back to taking zone->lock for each page. When the list is empty, disable IRQs before the refill and restore them only after dropping the pcp lock. PREEMPT_RT keeps IRQs enabled. With zone->lock contended in a 128-vCPU guest, tlb_remove_table_rcu() callbacks hitting the fallback went from 7% to 1.5% and the average callback duration from 1.5ms to 0.6ms (the previous commit brought these down from 93% and 14ms, respectively). Note that alloc_pages_bulk_noprof() still refills with IRQs enabled under the pcp lock. This one needs a different fix as it keeps the lock across prep_new_page(), so leave this for future work. Signed-off-by: Joshua Hahn --- mm/page_alloc.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index bc272f8d8ec75..0e669e206d371 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3405,6 +3405,8 @@ static struct page *rmqueue_pcplist(struct zone *preferred_zone, struct per_cpu_pages *pcp; struct list_head *list; struct page *page; + unsigned long flags; + bool refill; /* spin_trylock may fail due to a parallel drain or IRQ reentrancy. */ pcp = pcp_spin_trylock(zone->per_cpu_pageset); @@ -3418,8 +3420,15 @@ static struct page *rmqueue_pcplist(struct zone *preferred_zone, */ pcp->free_count >>= 1; list = &pcp->lists[order_to_pindex(migratetype, order)]; + /* Refilling takes zone->lock, see pcp_spin_unlock_irqrestore() */ + refill = !IS_ENABLED(CONFIG_PREEMPT_RT) && list_empty(list); + if (refill) + local_irq_save(flags); page = __rmqueue_pcplist(zone, order, migratetype, alloc_flags, pcp, list); - pcp_spin_unlock(pcp); + if (refill) + pcp_spin_unlock_irqrestore(pcp, flags); + else + pcp_spin_unlock(pcp); if (page) { __count_zid_vm_events(PGALLOC, page_zonenum(page), 1 << order); zone_statistics(preferred_zone, zone, 1); -- 2.53.1-Meta