linux-stable/arch
Suren Baghdasaryan 46e714c729 arch/mm/fault: fix major fault accounting when retrying under per-VMA lock
A test [1] in Android test suite started failing after [2] was merged.  It
turns out that after handling a major fault under per-VMA lock, the
process major fault counter does not register that fault as major.  Before
[2] read faults would be done under mmap_lock, in which case
FAULT_FLAG_TRIED flag is set before retrying.  That in turn causes
mm_account_fault() to account the fault as major once retry completes. 
With per-VMA locks we often retry because a fault can't be handled without
locking the whole mm using mmap_lock.  Therefore such retries do not set
FAULT_FLAG_TRIED flag.  This logic does not work after [2] because we can
now handle read major faults under per-VMA lock and upon retry the fact
there was a major fault gets lost.  Fix this by setting FAULT_FLAG_TRIED
after retrying under per-VMA lock if VM_FAULT_MAJOR was returned.  Ideally
we would use an additional VM_FAULT bit to indicate the reason for the
retry (could not handle under per-VMA lock vs other reason) but this
simpler solution seems to work, so keeping it simple.

[1] https://cs.android.com/android/platform/superproject/+/master:test/vts-testcase/kernel/api/drop_caches_prop/drop_caches_test.cpp
[2] https://lore.kernel.org/all/20231006195318.4087158-6-willy@infradead.org/

Link: https://lkml.kernel.org/r/20231226214610.109282-1-surenb@google.com
Fixes: 12214eba19 ("mm: handle read faults under the VMA lock")
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-12-29 11:06:49 -08:00
..
alpha TTY/Serial changes for 6.7-rc1 2023-11-03 15:44:25 -10:00
arc kprobes: unify kprobes_exceptions_nofify() prototypes 2023-11-10 19:59:05 +09:00
arm Merge branch 'master' into mm-hotfixes-stable 2023-12-06 17:03:50 -08:00
arm64 arch/mm/fault: fix major fault accounting when retrying under per-VMA lock 2023-12-29 11:06:49 -08:00
csky Kbuild updates for v6.7 2023-11-04 08:07:19 -10:00
hexagon TTY/Serial changes for 6.7-rc1 2023-11-03 15:44:25 -10:00
loongarch loongarch, kexec: change dependency of object files 2023-12-12 17:20:17 -08:00
m68k m68k, kexec: fix the incorrect ifdeffery and build dependency of CONFIG_KEXEC 2023-12-12 17:20:17 -08:00
microblaze asm-generic updates for v6.7 2023-11-01 15:28:33 -10:00
mips mips, kexec: fix the incorrect ifdeffery and dependency of CONFIG_KEXEC 2023-12-12 17:20:18 -08:00
nios2 vgacon, arch/*: remove unused screen_info definitions 2023-10-17 10:17:02 +02:00
openrisc
parisc parisc: Reduce size of the bug_table on 64-bit kernel by half 2023-11-25 09:43:18 +01:00
powerpc arch/mm/fault: fix major fault accounting when retrying under per-VMA lock 2023-12-29 11:06:49 -08:00
riscv arch/mm/fault: fix major fault accounting when retrying under per-VMA lock 2023-12-29 11:06:49 -08:00
s390 arch/mm/fault: fix major fault accounting when retrying under per-VMA lock 2023-12-29 11:06:49 -08:00
sh sh, kexec: fix the incorrect ifdeffery and dependency of CONFIG_KEXEC 2023-12-12 17:20:18 -08:00
sparc kprobes: unify kprobes_exceptions_nofify() prototypes 2023-11-10 19:59:05 +09:00
um um,ethertap: Replace deprecated strncpy() with strscpy() 2023-09-29 11:37:50 -07:00
x86 arch/mm/fault: fix major fault accounting when retrying under per-VMA lock 2023-12-29 11:06:49 -08:00
xtensa TTY/Serial changes for 6.7-rc1 2023-11-03 15:44:25 -10:00
.gitignore
Kconfig