[PATCH] mm: fix kmap_high deadlock

shaohaojize@126.com posted 1 patch 1 year, 5 months ago
There is a newer version of this series
mm/highmem.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] mm: fix kmap_high deadlock
Posted by shaohaojize@126.com 1 year, 5 months ago
From: "zhang.chun" <zhang.chuna@h3c.com>

I work with zhangzhansheng(from h3c) find that some situation may casue
deadlock when we use kmap_highand kmap_XXX or kumap_xxx between
 differt cores at the same time.kmap_high->map_new_virtual->
flush_all_zero_pkmaps->flush_tlb_kernel_range->on_each_cpu,
On this condition, kmap_high
hold the kmap_lock, wait the other cores ack. But the others
may disable irq and wait kmap_lock, this is some deadlock condition.
I think it's necessary to give kmap_lock before call
flush_tlb_kernel_range.
Like this:
spin_unlock(&kmap_lock);
flush_tlb_kernel_range(xxx);
spin_lock(&kmap_lock);

Signed-off-by: zhang.chun <zhang.chuna@h3c.com>
---
 mm/highmem.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/mm/highmem.c b/mm/highmem.c
index bd48ba445dd4..12d20e551579 100644
--- a/mm/highmem.c
+++ b/mm/highmem.c
@@ -221,7 +221,9 @@ static void flush_all_zero_pkmaps(void)
 		need_flush = 1;
 	}
 	if (need_flush)
+		spin_unlock(&kmap_lock);
 		flush_tlb_kernel_range(PKMAP_ADDR(0), PKMAP_ADDR(LAST_PKMAP));
+		spin_lock(&kmap_lock);
 }
 
 void __kmap_flush_unused(void)
-- 
2.34.1