mm: thp: khugepaged: flush tlb range to prevent concurrent memory accesses 80/265080/3
authorSung-hun Kim <sfoon.kim@samsung.com>
Fri, 1 Oct 2021 05:15:51 +0000 (14:15 +0900)
committerSung-hun Kim <sfoon.kim@samsung.com>
Tue, 12 Oct 2021 05:25:39 +0000 (14:25 +0900)
commit44021aaaef7f4e80d3ce5886bac8c8ac378aee93
treec9689f75006c902fa65fdac676452abeb0d86683
parent60c6791df949e6ef790a63552e283a747f9d636d
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