x86/mm/tlb: Remove 'struct flush_tlb_info' from the stack
authorNadav Amit <namit@vmware.com>
Thu, 25 Apr 2019 23:01:43 +0000 (16:01 -0700)
committerIngo Molnar <mingo@kernel.org>
Fri, 26 Apr 2019 10:01:45 +0000 (12:01 +0200)
commit3db6d5a5ecaf0a778d721ccf9809248350d4bfaf
tree2136fff8b0378ea2cee822cf7f2e0e6dcba49bf9
parentda398dbd7d871bae332a800f7d194af18a2a9058
x86/mm/tlb: Remove 'struct flush_tlb_info' from the stack

Move flush_tlb_info variables off the stack. This allows to align
flush_tlb_info to cache-line and avoid potentially unnecessary cache
line movements. It also allows to have a fixed virtual-to-physical
translation of the variables, which reduces TLB misses.

Use per-CPU struct for flush_tlb_mm_range() and
flush_tlb_kernel_range(). Add debug assertions to ensure there are
no nested TLB flushes that might overwrite the per-CPU data. For
arch_tlbbatch_flush() use a const struct.

Results when running a microbenchmarks that performs 10^6 MADV_DONTEED
operations and touching a page, in which 3 additional threads run a
busy-wait loop (5 runs, PTI and retpolines are turned off):

base off-stack
---- ---------
  avg (usec/op) 1.629 1.570 (-3%)
  stddev 0.014 0.009

Signed-off-by: Nadav Amit <namit@vmware.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20190425230143.7008-1-namit@vmware.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/mm/tlb.c