mm: thp: khugepaged: flush tlb range to prevent concurrent memory accesses
authorSung-hun Kim <sfoon.kim@samsung.com>
Fri, 1 Oct 2021 05:15:51 +0000 (14:15 +0900)
committerHoegeun Kwon <hoegeun.kwon@samsung.com>
Mon, 7 Feb 2022 08:01:41 +0000 (17:01 +0900)
commit5338d6493b4bfa6af640794f45c4247fe7a18a50
tree8613580352181681e810aed44def0f8d75a061e9
parentf93b06761aa75cfc2e8b91fe700d254bbdf76405
mm: thp: khugepaged: flush tlb range to prevent concurrent memory accesses

When khugepaged creates a hugepage while a user accesses memory,
khugepaged should prohibit current accesses to scanning area
because it can make a race condition.

Before creating a hugepage, khugepaged holds a lock of mm_struct
then flushes tlbs of scanning range. For 64KB hugepage, however,
it does not flush tlbs before it installs a new hugepage into the
page table. In this case, the user can lose their progress because
the user process still have memory map in its TLB entries.

By flushing TLBs right after acquiring mmap_lock, the process can
stall before reusing their memory contents.

Change-Id: I408662d69fa68e6210be8ad0b585943bfb8894e8
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
mm/khugepaged.c