linux_dsm_epyc7002/arch/sh/include/asm
Minchan Kim 99baac21e4 mm: fix MADV_[FREE|DONTNEED] TLB flush miss problem
Nadav reported parallel MADV_DONTNEED on same range has a stale TLB
problem and Mel fixed it[1] and found same problem on MADV_FREE[2].

Quote from Mel Gorman:
 "The race in question is CPU 0 running madv_free and updating some PTEs
  while CPU 1 is also running madv_free and looking at the same PTEs.
  CPU 1 may have writable TLB entries for a page but fail the pte_dirty
  check (because CPU 0 has updated it already) and potentially fail to
  flush.

  Hence, when madv_free on CPU 1 returns, there are still potentially
  writable TLB entries and the underlying PTE is still present so that a
  subsequent write does not necessarily propagate the dirty bit to the
  underlying PTE any more. Reclaim at some unknown time at the future
  may then see that the PTE is still clean and discard the page even
  though a write has happened in the meantime. I think this is possible
  but I could have missed some protection in madv_free that prevents it
  happening."

This patch aims for solving both problems all at once and is ready for
other problem with KSM, MADV_FREE and soft-dirty story[3].

TLB batch API(tlb_[gather|finish]_mmu] uses [inc|dec]_tlb_flush_pending
and mmu_tlb_flush_pending so that when tlb_finish_mmu is called, we can
catch there are parallel threads going on.  In that case, forcefully,
flush TLB to prevent for user to access memory via stale TLB entry
although it fail to gather page table entry.

I confirmed this patch works with [4] test program Nadav gave so this
patch supersedes "mm: Always flush VMA ranges affected by zap_page_range
v2" in current mmotm.

NOTE:

This patch modifies arch-specific TLB gathering interface(x86, ia64,
s390, sh, um).  It seems most of architecture are straightforward but
s390 need to be careful because tlb_flush_mmu works only if
mm->context.flush_mm is set to non-zero which happens only a pte entry
really is cleared by ptep_get_and_clear and friends.  However, this
problem never changes the pte entries but need to flush to prevent
memory access from stale tlb.

[1] http://lkml.kernel.org/r/20170725101230.5v7gvnjmcnkzzql3@techsingularity.net
[2] http://lkml.kernel.org/r/20170725100722.2dxnmgypmwnrfawp@suse.de
[3] http://lkml.kernel.org/r/BD3A0EBE-ECF4-41D4-87FA-C755EA9AB6BD@gmail.com
[4] https://patchwork.kernel.org/patch/9861621/

[minchan@kernel.org: decrease tlb flush pending count in tlb_finish_mmu]
  Link: http://lkml.kernel.org/r/20170808080821.GA31730@bbox
Link: http://lkml.kernel.org/r/20170802000818.4760-7-namit@vmware.com
Signed-off-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Nadav Amit <namit@vmware.com>
Reported-by: Nadav Amit <namit@vmware.com>
Reported-by: Mel Gorman <mgorman@techsingularity.net>
Acked-by: Mel Gorman <mgorman@techsingularity.net>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Nadav Amit <nadav.amit@gmail.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-08-10 15:54:07 -07:00
..
adc.h
addrspace.h
alignment.h
asm-offsets.h
atomic-grb.h locking/atomic, arch/sh: Implement atomic_fetch_{add,sub,and,or,xor}() 2016-06-16 10:48:29 +02:00
atomic-irq.h locking/atomic, arch/sh: Implement atomic_fetch_{add,sub,and,or,xor}() 2016-06-16 10:48:29 +02:00
atomic-llsc.h locking/atomic, arch/sh: Fix ATOMIC_FETCH_OP() 2016-09-22 14:47:02 +02:00
atomic.h sh: add J2 atomics using the cas.l instruction 2016-08-05 03:29:34 +00:00
barrier.h sh: add J2 atomics using the cas.l instruction 2016-08-05 03:29:34 +00:00
bitops-cas.h sh: add J2 atomics using the cas.l instruction 2016-08-05 03:29:34 +00:00
bitops-grb.h
bitops-llsc.h
bitops-op32.h
bitops.h sh: add J2 atomics using the cas.l instruction 2016-08-05 03:29:34 +00:00
bl_bit_32.h Disintegrate asm/system.h for SH 2012-03-28 18:30:03 +01:00
bl_bit_64.h Disintegrate asm/system.h for SH 2012-03-28 18:30:03 +01:00
bl_bit.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
bug.h Merge branch 'core-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-07-21 10:41:19 -07:00
bugs.h
cache_insns_32.h Disintegrate asm/system.h for SH 2012-03-28 18:30:03 +01:00
cache_insns_64.h Disintegrate asm/system.h for SH 2012-03-28 18:30:03 +01:00
cache_insns.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
cache.h
cacheflush.h
checksum_32.h ipv6: Pass proto to csum_ipv6_magic as __u8 instead of unsigned short 2016-03-13 23:55:13 -04:00
checksum.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
clock.h sh: sh header sh_clk_ops rename 2012-03-12 22:19:10 +01:00
cmpxchg-cas.h sh: add J2 atomics using the cas.l instruction 2016-08-05 03:29:34 +00:00
cmpxchg-grb.h sh: support 1 and 2 byte xchg 2016-01-12 20:47:01 +02:00
cmpxchg-irq.h sh: support 1 and 2 byte xchg 2016-01-12 20:47:01 +02:00
cmpxchg-llsc.h sh: move xchg_cmpxchg to a header by itself 2016-01-12 20:47:02 +02:00
cmpxchg-xchg.h sh: cmpxchg: fix a bit shift bug in big_endian os 2016-07-31 03:33:32 +00:00
cmpxchg.h sh: add J2 atomics using the cas.l instruction 2016-08-05 03:29:34 +00:00
device.h sh: Defer to asm-generic/device.h. 2012-01-13 16:27:38 +09:00
dma-mapping.h sh: remove DMA_ERROR_CODE 2017-06-20 11:13:06 +02:00
dma-register.h dmaengine: shdma: Add more register documentation 2014-07-09 10:55:57 +02:00
dma.h sh: Kill off MAX_DMA_ADDRESS leftovers. 2012-05-19 18:50:09 +09:00
dmabrg.h
dwarf.h
elf.h sh: Fix FDPIC binary loader 2013-01-11 21:02:57 +09:00
entry-macros.S
extable.h sh: switch to extable.h 2017-03-28 18:23:59 -04:00
fb.h
fixmap.h sh: use generic fixmap.h 2014-01-23 16:36:54 -08:00
flat.h binfmt_flat: flat_{get,put}_addr_from_rp() should be able to fail 2017-07-03 18:44:02 -04:00
fpu.h sched/headers: Remove <asm/ptrace.h> from <linux/sched.h> 2017-03-03 01:45:33 +01:00
freq.h
ftrace.h ftrace: Format MCOUNT_ADDR address as type unsigned long 2015-07-20 22:30:53 -04:00
futex-cas.h sh: add working futex atomic ops on userspace addresses for smp 2016-08-05 03:29:36 +00:00
futex-irq.h sh: add working futex atomic ops on userspace addresses for smp 2016-08-05 03:29:36 +00:00
futex-llsc.h sh: add working futex atomic ops on userspace addresses for smp 2016-08-05 03:29:36 +00:00
futex.h sh: add working futex atomic ops on userspace addresses for smp 2016-08-05 03:29:36 +00:00
gpio.h sh: Remove unused sh_pfc_register_info() function 2013-01-25 09:24:30 +09:00
hardirq.h
hd64461.h
heartbeat.h
hugetlb.h mm/hugetlb: remove arch_prepare/release_hugepage from arch headers 2015-06-25 17:00:35 -07:00
hw_breakpoint.h UAPI: (Scripted) Disintegrate arch/sh/include/asm 2012-10-09 09:47:37 +01:00
hw_irq.h
i2c-sh7760.h sh: edosk7760 evt2irq migration. 2012-05-18 14:52:31 +09:00
io_generic.h
io_noioport.h sh: fix build error by adding generic ioport_{map/unmap}() 2014-08-06 18:01:13 -07:00
io_trapped.h Kconfig: rename HAS_IOPORT to HAS_IOPORT_MAP 2014-04-07 16:36:11 -07:00
io.h libnvdimm for 4.3: 2015-09-08 14:35:59 -07:00
irq.h sh: Kill off machvec IRQ hinting. 2012-05-21 17:54:01 +09:00
irqflags.h
Kbuild sh: move generic-y of exported headers to uapi/asm/Kbuild 2017-07-11 21:33:51 +09:00
kdebug.h sh64: Convert to unwinder API. 2012-05-24 15:03:46 +09:00
kexec.h
kgdb.h sh: kgdb: Unset CACHE_FLUSH_IS_SAFE for SMP. 2012-04-11 10:48:24 +09:00
kmap_types.h
kprobes.h kprobes: move kprobe declarations to asm-generic/kprobes.h 2017-02-27 18:43:45 -08:00
linkage.h
machvec.h Kconfig: rename HAS_IOPORT to HAS_IOPORT_MAP 2014-04-07 16:36:11 -07:00
mmu_context_32.h
mmu_context_64.h
mmu_context.h sched/headers: Prepare to remove the <linux/mm_types.h> dependency from <linux/sched.h> 2017-03-02 08:42:37 +01:00
mmu.h
mmzone.h
module.h Make most arch asm/module.h files use asm-generic/module.h 2012-09-28 14:31:03 +09:30
page.h sh: add copy_user_page() alias for __copy_user() 2015-10-16 11:42:28 -07:00
pci.h sh/PCI: Use generic pci_mmap_resource_range() 2017-04-20 08:47:47 -05:00
perf_event.h
pgalloc.h tree wide: get rid of __GFP_REPEAT for order-0 allocations part I 2016-06-24 17:23:52 -07:00
pgtable_32.h sh: drop _PAGE_FILE and pte_file()-related helpers 2015-02-10 14:30:33 -08:00
pgtable_64.h sh: drop _PAGE_FILE and pte_file()-related helpers 2015-02-10 14:30:33 -08:00
pgtable-2level.h arch, mm: convert all architectures to use 5level-fixup.h 2017-03-09 11:48:47 -08:00
pgtable-3level.h arch, mm: convert all architectures to use 5level-fixup.h 2017-03-09 11:48:47 -08:00
pgtable.h mm: make FIRST_USER_ADDRESS unsigned long on all archs 2015-02-11 17:06:03 -08:00
posix_types.h UAPI: (Scripted) Disintegrate arch/sh/include/asm 2012-10-09 09:47:37 +01:00
processor_32.h sh: move fpu_counter into ARCH specific thread_struct 2013-11-13 12:09:13 +09:00
processor_64.h sh: move fpu_counter into ARCH specific thread_struct 2013-11-13 12:09:13 +09:00
processor.h locking/core: Provide common cpu_relax_yield() definition 2016-11-17 08:17:36 +01:00
ptrace_32.h UAPI: (Scripted) Disintegrate arch/sh/include/asm 2012-10-09 09:47:37 +01:00
ptrace_64.h UAPI: (Scripted) Disintegrate arch/sh/include/asm 2012-10-09 09:47:37 +01:00
ptrace.h UAPI: (Scripted) Disintegrate arch/sh/include/asm 2012-10-09 09:47:37 +01:00
push-switch.h
reboot.h
romimage-macros.h
rtc.h rtc: sh: provide rtc_class_ops directly 2016-06-04 00:22:46 +02:00
seccomp.h
sections.h nosave: consolidate __nosave_{begin,end} in <asm/sections.h> 2014-10-09 22:26:04 -04:00
segment.h sh: macro whitespace fixes 2015-01-13 15:24:08 +02:00
setup.h UAPI: (Scripted) Disintegrate arch/sh/include/asm 2012-10-09 09:47:37 +01:00
sfp-machine.h
sh7760fb.h
sh_bios.h
shmparam.h
siu.h sh: remove unused DMA device pointer from SIU platform data 2012-07-20 11:23:44 +05:30
smc37c93x.h
smp-ops.h
smp.h sh: fix smp-shx3 build regression from removal of arch localtimer 2016-03-29 22:03:50 +00:00
sparsemem.h
spi.h
spinlock_types.h
spinlock-cas.h sh: add J2 atomics using the cas.l instruction 2016-08-05 03:29:34 +00:00
spinlock-llsc.h sh: add J2 atomics using the cas.l instruction 2016-08-05 03:29:34 +00:00
spinlock.h sh: add J2 atomics using the cas.l instruction 2016-08-05 03:29:34 +00:00
sram.h
stackprotector.h sh64: ascii armor the sh64 boot init stack canary 2017-07-12 16:26:03 -07:00
stacktrace.h
string_32.h
string_64.h
string.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
suspend.h SH: cpuidle: check error code at init 2013-04-22 00:35:53 +02:00
switch_to_32.h sched, sh: Fold finish_arch_switch() into switch_to() 2015-08-04 09:38:05 +02:00
switch_to_64.h Disintegrate asm/system.h for SH 2012-03-28 18:30:03 +01:00
switch_to.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
syscall_32.h SH: define syscall_get_arch() for superh 2014-09-23 16:20:01 -04:00
syscall_64.h SH: define syscall_get_arch() for superh 2014-09-23 16:20:01 -04:00
syscall.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
syscalls_32.h sh: push extra copy of r0-r2 for syscall parameters 2014-04-03 16:20:52 -07:00
syscalls_64.h sh: switch to generic fork/vfork/clone 2012-11-28 22:36:47 -05:00
syscalls.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
thread_info.h signal: consolidate {TS,TLF}_RESTORE_SIGMASK code 2016-08-02 19:35:23 -04:00
timex.h
tlb_64.h
tlb.h mm: fix MADV_[FREE|DONTNEED] TLB flush miss problem 2017-08-10 15:54:07 -07:00
tlbflush.h
topology.h sh: fix function signature of cpu_coregroup_mask to match pointer type 2016-03-30 00:47:49 +00:00
traps_32.h sh: don't pass saved userspace state to exception handlers 2014-04-03 16:20:52 -07:00
traps_64.h sh64: Provide EXPEVT helper. 2012-05-14 13:04:08 +09:00
traps.h UAPI: (Scripted) Convert #include "..." to #include <path/...> in kernel system headers 2012-10-02 18:01:25 +01:00
types.h UAPI: (Scripted) Disintegrate arch/sh/include/asm 2012-10-09 09:47:37 +01:00
uaccess_32.h sh: use the new generic strnlen_user() function 2012-06-13 10:28:37 +09:00
uaccess_64.h sh64: failing __get_user() should zero 2016-09-13 17:50:14 -04:00
uaccess.h kill strlen_user() 2017-05-15 23:40:22 -04:00
unaligned-sh4a.h
unaligned.h
uncached.h
unistd.h sys_sgetmask/sys_ssetmask: add CONFIG_SGETMASK_SYSCALL 2014-06-04 16:54:14 -07:00
unwinder.h
user.h
vga.h
vmlinux.lds.h
watchdog.h
word-at-a-time.h sh: use the new generic strnlen_user() function 2012-06-13 10:28:37 +09:00