Skip to content

Commit 953753d

Browse files
rikvanrielIngo Molnar
authored andcommitted
x86/mm/tlb: Also remove local CPU from mm_cpumask if stale
The code in flush_tlb_func() that removes a remote CPU from the cpumask if it is no longer running the target mm is also needed on the originating CPU of a TLB flush, now that CPUs are no longer cleared from the mm_cpumask at context switch time. Flushing the TLB when we are not running the target mm is harmless, because the CPU's tlb_gen only gets updated to match the mm_tlb_gen, but it does hit this warning: WARN_ON_ONCE(local_tlb_gen > mm_tlb_gen); [ 210.343902][ T4668] WARNING: CPU: 38 PID: 4668 at arch/x86/mm/tlb.c:815 flush_tlb_func (arch/x86/mm/tlb.c:815) Removing both local and remote CPUs from the mm_cpumask when doing a flush for a not currently loaded mm avoids that warning. Reported-by: kernel test robot <[email protected]> Tested-by: kernel test robot <[email protected]> Signed-off-by: Rik van Riel <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Mathieu Desnoyers <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/r/20241205104630.755706ca@fangorn Closes: https://lore.kernel.org/oe-lkp/[email protected]
1 parent 2815a56 commit 953753d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arch/x86/mm/tlb.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -756,13 +756,13 @@ static void flush_tlb_func(void *info)
756756
if (!local) {
757757
inc_irq_stat(irq_tlb_count);
758758
count_vm_tlb_event(NR_TLB_REMOTE_FLUSH_RECEIVED);
759+
}
759760

760-
/* Can only happen on remote CPUs */
761-
if (f->mm && f->mm != loaded_mm) {
762-
cpumask_clear_cpu(raw_smp_processor_id(), mm_cpumask(f->mm));
763-
trace_tlb_flush(TLB_REMOTE_WRONG_CPU, 0);
764-
return;
765-
}
761+
/* The CPU was left in the mm_cpumask of the target mm. Clear it. */
762+
if (f->mm && f->mm != loaded_mm) {
763+
cpumask_clear_cpu(raw_smp_processor_id(), mm_cpumask(f->mm));
764+
trace_tlb_flush(TLB_REMOTE_WRONG_CPU, 0);
765+
return;
766766
}
767767

768768
if (unlikely(loaded_mm == &init_mm))

0 commit comments

Comments
 (0)