]> git.baikalelectronics.ru Git - kernel.git/commit
mm, thp: Do not make pmd/pud dirty without a reason
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Mon, 27 Nov 2017 03:21:26 +0000 (06:21 +0300)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 27 Nov 2017 20:26:29 +0000 (12:26 -0800)
commit014220bac999d8757f02885d0368c2ec392a71ea
tree19bd28f0ea6af08ba14ae4bfd841b5256f888ee7
parentafa166c5321a2eeee3d7162e23c6646c136ab017
mm, thp: Do not make pmd/pud dirty without a reason

Currently we make page table entries dirty all the time regardless of
access type and don't even consider if the mapping is write-protected.
The reasoning is that we don't really need dirty tracking on THP and
making the entry dirty upfront may save some time on first write to the
page.

Unfortunately, such approach may result in false-positive
can_follow_write_pmd() for huge zero page or read-only shmem file.

Let's only make page dirty only if we about to write to the page anyway
(as we do for small pages).

I've restructured the code to make entry dirty inside
maybe_p[mu]d_mkwrite(). It also takes into account if the vma is
write-protected.

Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/huge_memory.c
mm/internal.h
mm/khugepaged.c
mm/memory.c
mm/migrate.c