https://github.com/torvalds/linux
Revision 4cd7ba16a0afb36550eed7690e73d3e7a743fa96 authored by Ram Tummala on 10 July 2024, 01:45:39 UTC, committed by Andrew Morton on 26 July 2024, 21:33:09 UTC
Commit 3bd786f76de2 ("mm: convert do_set_pte() to set_pte_range()")
replaced do_set_pte() with set_pte_range() and that introduced a
regression in the following faulting path of non-anonymous vmas which
caused the PTE for the faulting address to be marked as old instead of
young.

handle_pte_fault()
  do_pte_missing()
    do_fault()
      do_read_fault() || do_cow_fault() || do_shared_fault()
        finish_fault()
          set_pte_range()

The polarity of prefault calculation is incorrect.  This leads to prefault
being incorrectly set for the faulting address.  The following check will
incorrectly mark the PTE old rather than young.  On some architectures
this will cause a double fault to mark it young when the access is
retried.

    if (prefault && arch_wants_old_prefaulted_pte())
        entry = pte_mkold(entry);

On a subsequent fault on the same address, the faulting path will see a
non NULL vmf->pte and instead of reaching the do_pte_missing() path, PTE
will then be correctly marked young in handle_pte_fault() itself.

Due to this bug, performance degradation in the fault handling path will
be observed due to unnecessary double faulting.

Link: https://lkml.kernel.org/r/20240710014539.746200-1-rtummala@nvidia.com
Fixes: 3bd786f76de2 ("mm: convert do_set_pte() to set_pte_range()")
Signed-off-by: Ram Tummala <rtummala@nvidia.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Yin Fengwei <fengwei.yin@intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 34e526f
History
Tip revision: 4cd7ba16a0afb36550eed7690e73d3e7a743fa96 authored by Ram Tummala on 10 July 2024, 01:45:39 UTC
mm: fix old/young bit handling in the faulting path
Tip revision: 4cd7ba1
File Mode Size
Documentation
LICENSES
arch
block
certs
crypto
drivers
fs
include
init
io_uring
ipc
kernel
lib
mm
net
rust
samples
scripts
security
sound
tools
usr
virt
.clang-format -rw-r--r-- 21.7 KB
.cocciconfig -rw-r--r-- 59 bytes
.editorconfig -rw-r--r-- 575 bytes
.get_maintainer.ignore -rw-r--r-- 194 bytes
.gitattributes -rw-r--r-- 105 bytes
.gitignore -rw-r--r-- 2.1 KB
.mailmap -rw-r--r-- 40.2 KB
.rustfmt.toml -rw-r--r-- 369 bytes
COPYING -rw-r--r-- 496 bytes
CREDITS -rw-r--r-- 102.5 KB
Kbuild -rw-r--r-- 2.5 KB
Kconfig -rw-r--r-- 555 bytes
MAINTAINERS -rw-r--r-- 754.8 KB
Makefile -rw-r--r-- 66.5 KB
README -rw-r--r-- 726 bytes

README

back to top