Skip to contentSkip to conversation

mm: fix kmap_high deadlock

PATCH New [email protected] 1 participant 1 message Jun 30, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: fix kmap_high deadlock

From: "zhang.chun" <[email protected]>

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);

---
 mm/highmem.c | 2 ++
 1 file changed, 2 insertions(+)
mm/highmem.c +2 -0
index bd48ba445dd4..12d20e551579 100644
@@ -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)
Signature · 1 line
2.34.1