From 02cc4239c1bf1d7a3f5837d1a1681a71192d6718 Mon Sep 17 00:00:00 2001 From: Nadav Amit Date: Fri, 9 Jul 2021 09:47:05 +0000 Subject: [PATCH] x86/mm/tlb: Do not make is_lazy dirty for no reason mainline inclusion from mainline-v5.13-rc1 commit 09c5272e48614a30598e759c3c7bed126d22037d category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I3ZV2C CVE: NA ------------------------------------------------- Blindly writing to is_lazy for no reason, when the written value is identical to the old value, makes the cacheline dirty for no reason. Avoid making such writes to prevent cache coherency traffic for no reason. Suggested-by: Dave Hansen Signed-off-by: Nadav Amit Signed-off-by: Ingo Molnar Reviewed-by: Dave Hansen Link: https://lore.kernel.org/r/20210220231712.2475218-7-namit@vmware.com Signed-off-by: Tong Tiangen Reviewed-by: Chen Wandun Signed-off-by: Zheng Zengkai --- arch/x86/mm/tlb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index 345a0aff5de4..17ec4bfeee67 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -469,7 +469,8 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, __flush_tlb_all(); } #endif - this_cpu_write(cpu_tlbstate_shared.is_lazy, false); + if (was_lazy) + this_cpu_write(cpu_tlbstate_shared.is_lazy, false); /* * The membarrier system call requires a full memory barrier and -- GitLab