From: Nadav Amit <namit@xxxxxxxxxx> Setting the access-bit and dirty-bit introduces a tradeoff. When the bit is set access/write is faster, but memory reclamation might be slower. Currently, in the common userfaultfd cases the access-bit is not set on and the dirty-bit is set. This is a questionable behavior. Allow userspace to control this behavior through hints access- and write-likely hints. These hints are used to control access- and dirty-bits. For zero-pages that with write-likely hint, allocate a clear page instead of mapping the zero-page. Cc: Mike Kravetz <mike.kravetz@xxxxxxxxxx> Cc: Hugh Dickins <hughd@xxxxxxxxxx> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Cc: Axel Rasmussen <axelrasmussen@xxxxxxxxxx> Cc: Peter Xu <peterx@xxxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: Mike Rapoport <rppt@xxxxxxxxxxxxx> Nadav Amit (5): userfaultfd: introduce uffd_flags userfaultfd: introduce access-likely mode for copy/wp operations userfaultfd: introduce write-likely mode for copy/wp operations userfaultfd: zero access/write hints selftest/userfaultfd: test read/write hints fs/userfaultfd.c | 57 ++++++++--- include/linux/hugetlb.h | 4 +- include/linux/shmem_fs.h | 8 +- include/linux/userfaultfd_k.h | 25 +++-- include/uapi/linux/userfaultfd.h | 33 ++++++- mm/hugetlb.c | 6 +- mm/shmem.c | 9 +- mm/userfaultfd.c | 118 +++++++++++++++++------ tools/testing/selftests/vm/userfaultfd.c | 26 +++++ 9 files changed, 226 insertions(+), 60 deletions(-) -- 2.25.1