linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/mm/tlb: ignore f->new_tlb_gen when zero
@ 2022-07-08  0:30 Nadav Amit
  2022-07-08 11:40 ` David Hildenbrand
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Nadav Amit @ 2022-07-08  0:30 UTC (permalink / raw)
  To: linux-kernel, Hugh Dickins, Thomas Gleixner
  Cc: Ingo Molnar, Borislav Petkov, x86, Linux MM, Nadav Amit,
	Dave Hansen, Peter Zijlstra, Andy Lutomirski

From: Nadav Amit <namit@vmware.com>

Commit aa44284960d5 ("x86/mm/tlb: Avoid reading mm_tlb_gen when
possible") introduced an optimization of skipping the flush if the TLB
generation that is flushed (as provided in flush_tlb_info) was already
flushed.

However, arch_tlbbatch_flush() does not provide any generation in
flush_tlb_info. As a result, try_to_unmap_one() would not perform any
TLB flushes.

Fix it by checking whether f->new_tlb_gen is nonzero. Zero value is
anyhow is an invalid generation value.

In addition, add the missing unlikely() and jump to get tracing right.

Fixes: aa44284960d5 ("x86/mm/tlb: Avoid reading mm_tlb_gen when possible")
Reported-by: Hugh Dickins <hughd@google.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Nadav Amit <namit@vmware.com>
---
 arch/x86/mm/tlb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index d9314cc8b81f..d81b4084bb8a 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -771,14 +771,14 @@ static void flush_tlb_func(void *info)
 		return;
 	}
 
-	if (f->new_tlb_gen <= local_tlb_gen) {
+	if (unlikely(f->new_tlb_gen != 0 && f->new_tlb_gen <= local_tlb_gen)) {
 		/*
 		 * The TLB is already up to date in respect to f->new_tlb_gen.
 		 * While the core might be still behind mm_tlb_gen, checking
 		 * mm_tlb_gen unnecessarily would have negative caching effects
 		 * so avoid it.
 		 */
-		return;
+		goto done;
 	}
 
 	/*
-- 
2.25.1



^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-07-11  5:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-08  0:30 [PATCH] x86/mm/tlb: ignore f->new_tlb_gen when zero Nadav Amit
2022-07-08 11:40 ` David Hildenbrand
2022-07-08 15:13   ` Dave Hansen
2022-07-08 16:54     ` Nadav Amit
2022-07-08 17:01       ` Dave Hansen
2022-07-08 17:09         ` Nadav Amit
2022-07-08 18:03           ` Nadav Amit
2022-07-08 14:49 ` Dave Hansen
2022-07-08 17:04   ` Nadav Amit
2022-07-08 18:54     ` Dave Hansen
2022-07-11  5:19       ` Nadav Amit
2022-07-08 19:21 ` Hugh Dickins
2022-07-08 20:02   ` Nadav Amit
2022-07-08 20:48     ` Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox