linux-stable/arch/x86
Nadav Amit 4f83145721 mm: avoid unnecessary flush on change_huge_pmd()
Calls to change_protection_range() on THP can trigger, at least on x86,
two TLB flushes for one page: one immediately, when pmdp_invalidate() is
called by change_huge_pmd(), and then another one later (that can be
batched) when change_protection_range() finishes.

The first TLB flush is only necessary to prevent the dirty bit (and with a
lesser importance the access bit) from changing while the PTE is modified.
However, this is not necessary as the x86 CPUs set the dirty-bit
atomically with an additional check that the PTE is (still) present.  One
caveat is Intel's Knights Landing that has a bug and does not do so.

Leverage this behavior to eliminate the unnecessary TLB flush in
change_huge_pmd().  Introduce a new arch specific pmdp_invalidate_ad()
that only invalidates the access and dirty bit from further changes.

Link: https://lkml.kernel.org/r/20220401180821.1986781-4-namit@vmware.com
Signed-off-by: Nadav Amit <namit@vmware.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
Cc: Yu Zhao <yuzhao@google.com>
Cc: Nick Piggin <npiggin@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2022-05-13 07:20:05 -07:00
..
boot memcpy updates for v5.18-rc1 2022-03-26 12:19:04 -07:00
coco x86/coco: Add API to handle encryption mask 2022-02-23 19:14:29 +01:00
configs x86/config: Make the x86 defconfigs a bit more usable 2022-03-27 20:58:35 +02:00
crypto This push fixes the following issues: 2022-03-31 11:17:39 -07:00
entry Kbuild updates for v5.18 2022-03-31 11:59:03 -07:00
events perf/x86/cstate: Add SAPPHIRERAPIDS_X CPU support 2022-04-19 21:15:42 +02:00
hyperv
ia32
include mm: avoid unnecessary flush on change_huge_pmd() 2022-05-13 07:20:05 -07:00
kernel x86/kvm: Preserve BSP MSR_KVM_POLL_CONTROL across suspend/resume 2022-04-21 13:16:14 -04:00
kvm KVM: SEV: add cache flush to solve SEV cache incoherency issues 2022-04-21 15:41:00 -04:00
lib x86: __memcpy_flushcache: fix wrong alignment if size > 2^32 2022-04-20 11:38:49 -07:00
math-emu
mm mm: avoid unnecessary flush on change_huge_pmd() 2022-05-13 07:20:05 -07:00
net x86,bpf: Avoid IBT objtool warning 2022-04-07 11:27:02 +02:00
pci
platform objtool,efi: Update __efi64_thunk annotation 2022-03-15 10:32:32 +01:00
power x86/speculation: Restore speculation related MSRs during S3 resume 2022-04-05 10:18:31 -07:00
purgatory
ras
realmode
tools
um Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2022-04-01 19:57:03 -07:00
video
xen xen: branch for v5.18-rc1 2022-03-28 14:32:39 -07:00
.gitignore
Kbuild x86/cc: Move arch/x86/{kernel/cc_platform.c => coco/core.c} 2022-02-23 18:25:58 +01:00
Kconfig mm: hugetlb_vmemmap: cleanup CONFIG_HUGETLB_PAGE_FREE_VMEMMAP* 2022-04-28 23:16:15 -07:00
Kconfig.assembler
Kconfig.cpu
Kconfig.debug
Makefile x86: Remove toolchain check for X32 ABI capability 2022-03-15 10:32:48 +01:00
Makefile.um
Makefile_32.cpu