From 6debcdd43eb422e1f672b1d3efeff11c7ecd0dbf Mon Sep 17 00:00:00 2001 From: meganz009 Date: Sun, 4 Jun 2023 20:32:48 +0800 Subject: [PATCH] x86/mm/pat: disable preemption __split_large_page() after spin_lock() commit 3596d839ec05c759a409ec3c9fb058b89bc43de8 upstream. Commit "x86/mm/pat: Disable preemption around __flush_tlb_all()" added a warning if __flush_tlb_all() is invoked in preemptible context. On !RT the warning does not trigger because a spin lock is acquired which disables preemption. On RT the spin lock does not disable preemption and so the warning is seen. Disable preemption to avoid the warning __flush_tlb_all(). Signed-off-by: Sebastian Andrzej Siewior --- arch/x86/mm/pageattr.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c index 9eedb67d4d57..d0d56cc63283 100644 --- a/arch/x86/mm/pageattr.c +++ b/arch/x86/mm/pageattr.c @@ -947,12 +947,18 @@ __split_large_page(struct cpa_data *cpa, pte_t *kpte, unsigned long address, pte_t *tmp; spin_lock(&pgd_lock); + /* + * Keep preemption disabled after __flush_tlb_all() which expects not be + * preempted during the flush of the local TLB. + */ + preempt_disable(); /* * Check for races, another CPU might have split this page * up for us already: */ tmp = _lookup_address_cpa(cpa, address, &level); if (tmp != kpte) { + preempt_enable(); spin_unlock(&pgd_lock); return 1; } @@ -988,6 +994,7 @@ __split_large_page(struct cpa_data *cpa, pte_t *kpte, unsigned long address, break; default: + preempt_enable(); spin_unlock(&pgd_lock); return 1; } @@ -1026,6 +1033,7 @@ __split_large_page(struct cpa_data *cpa, pte_t *kpte, unsigned long address, * going on. */ __flush_tlb_all(); + preempt_enable(); spin_unlock(&pgd_lock); return 0; -- Gitee