Kernel hangs when booted up with "xpfotlbflush" option. This is caused
by xpfo_kunmap() fliushing TLB while holding xpfo lock starving other
tasks waiting for the lock. This patch moves tlb flush outside of the
code holding xpfo lock.

Signed-off-by: Khalid Aziz <khalid.a...@oracle.com>
---
 mm/xpfo.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/mm/xpfo.c b/mm/xpfo.c
index 85079377c91d..79ffdba6af69 100644
--- a/mm/xpfo.c
+++ b/mm/xpfo.c
@@ -148,6 +148,8 @@ EXPORT_SYMBOL(xpfo_kmap);
 
 void xpfo_kunmap(void *kaddr, struct page *page)
 {
+       bool flush_tlb = false;
+
        if (!static_branch_unlikely(&xpfo_inited))
                return;
 
@@ -168,10 +170,13 @@ void xpfo_kunmap(void *kaddr, struct page *page)
                if (atomic_read(&page->xpfo_mapcount) == 0) {
                        SetPageXpfoUnmapped(page);
                        set_kpte(kaddr, page, __pgprot(0));
-                       xpfo_cond_flush_kernel_tlb(page, 0);
+                       flush_tlb = true;
                }
                spin_unlock(&page->xpfo_lock);
        }
+
+       if (flush_tlb)
+               xpfo_cond_flush_kernel_tlb(page, 0);
 }
 EXPORT_SYMBOL(xpfo_kunmap);
 
-- 
2.17.1

Reply via email to