[PATCH v4 05/10] userfaultfd/selftests: use memfd_create for shmem test type

2021-04-20 Thread Axel Rasmussen
userfaultfd behavior being introduced in this series. Also, a small fix in the area we're changing: when the hugetlb setup fails in main(), pass in the right argv[] so we actually print out the hugetlb file path. Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm

[PATCH v4 10/10] userfaultfd: update documentation to mention shmem minor faults

2021-04-20 Thread Axel Rasmussen
Generally, the documentation we wrote for hugetlbfs-based minor faults still all applies. The only missing piece is to mention the new feature flag which indicates that the kernel supports this for shmem as well. Signed-off-by: Axel Rasmussen --- Documentation/admin-guide/mm/userfaultfd.rst | 3

[PATCH v4 09/10] userfaultfd/shmem: modify shmem_mcopy_atomic_pte to use install_pte()

2021-04-20 Thread Axel Rasmussen
which would double-count since shmem_add_to_page_cache() also does this. Signed-off-by: Axel Rasmussen --- include/linux/userfaultfd_k.h | 5 mm/shmem.c| 53 --- mm/userfaultfd.c | 17 --- 3 files changed, 22 insertions(

[PATCH v4 08/10] userfaultfd/selftests: exercise minor fault handling shmem support

2021-04-20 Thread Axel Rasmussen
Enable test_uffdio_minor for test_type == TEST_SHMEM, and modify the test slightly to pass in / check for the right feature flags. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 29 1 file changed, 25 insertions(+), 4 deletions(-) diff

[PATCH v4 07/10] userfaultfd/selftests: reinitialize test context in each test

2021-04-20 Thread Axel Rasmussen
tlb, as we don't mremap in that case. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 215 --- 1 file changed, 116 insertions(+), 99 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 1f

[PATCH v4 06/10] userfaultfd/selftests: create alias mappings in the shmem test

2021-04-20 Thread Axel Rasmussen
, we'll leverage this setup to exercise minor fault handling support for shmem, just like we do in the hugetlb_shared test. Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 22 +++--- 1 file changed, 19 insertions(+), 3 deletions

[PATCH v4 02/10] userfaultfd/shmem: combine shmem_{mcopy_atomic,mfill_zeropage}_pte

2021-04-20 Thread Axel Rasmussen
statements. This means the line number reported when the BUG is hit specifies exactly which condition was true. Reviewed-by: Peter Xu Acked-by: Hugh Dickins Signed-off-by: Axel Rasmussen --- include/linux/shmem_fs.h | 17 ++--- mm/shmem.c | 52

[PATCH v4 03/10] userfaultfd/shmem: support UFFDIO_CONTINUE for shmem

2021-04-20 Thread Axel Rasmussen
it as a separate change. Signed-off-by: Axel Rasmussen --- mm/userfaultfd.c | 172 ++- 1 file changed, 127 insertions(+), 45 deletions(-) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 23fa2583bbd1..51d8c0127161 100644 --- a/mm/userfaultfd.c +++ b

[PATCH v4 04/10] userfaultfd/shmem: support minor fault registration for shmem

2021-04-20 Thread Axel Rasmussen
a way to resolve such faults. Acked-by: Peter Xu Signed-off-by: Axel Rasmussen --- fs/userfaultfd.c | 6 +++--- include/uapi/linux/userfaultfd.h | 7 ++- mm/memory.c | 8 +--- mm/shmem.c | 12 +++- 4 files changed, 25

[PATCH v4 01/10] userfaultfd/hugetlbfs: avoid including userfaultfd_k.h in hugetlb.h

2021-04-20 Thread Axel Rasmussen
Minimizing header file inclusion is desirable. In this case, we can do so just by forward declaring the enumeration our signature relies upon. Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen --- include/linux/hugetlb.h | 4 +++- mm/hugetlb.c| 1 + 2 files changed, 4 insertions

[PATCH v4 00/10] userfaultfd: add minor fault handling for shmem

2021-04-20 Thread Axel Rasmussen
ssary page copying (ioctl(UFFDIO_COPY)) would be required." [1] https://lore.kernel.org/patchwork/cover/1388144/ [2] https://lore.kernel.org/patchwork/patch/1408161/ [3] https://lore.kernel.org/linux-fsdevel/20210301222728.176417-1-axelrasmus...@google.com/T/#t Axel Rasmussen (10): userf

Re: [PATCH v3 00/10] userfaultfd: add minor fault handling for shmem

2021-04-20 Thread Axel Rasmussen
On Thu, Apr 15, 2021 at 12:13 PM Hugh Dickins wrote: > > On Thu, 15 Apr 2021, Axel Rasmussen wrote: > > > Base > > > > > > This series is based on (and therefore should apply cleanly to) the tag > > "v5.12-rc7-mmots-2021-04-11-20-49"

Re: [PATCH v2 9/9] userfaultfd/shmem: modify shmem_mcopy_atomic_pte to use install_ptes

2021-04-20 Thread Axel Rasmussen
On Fri, Apr 16, 2021 at 5:34 PM Hugh Dickins wrote: > > On Mon, 12 Apr 2021, Axel Rasmussen wrote: > > > In a previous commit, we added the mcopy_atomic_install_ptes() helper. > > This helper does the job of setting up PTEs for an existing page, to map > > it into a gi

Re: [PATCH v2 4/9] userfaultfd/shmem: support UFFDIO_CONTINUE for shmem

2021-04-20 Thread Axel Rasmussen
On Fri, Apr 16, 2021 at 4:47 PM Hugh Dickins wrote: > > On Mon, 12 Apr 2021, Axel Rasmussen wrote: > > > With this change, userspace can resolve a minor fault within a > > shmem-backed area with a UFFDIO_CONTINUE ioctl. The semantics for this > > match those

[PATCH v3 10/10] userfaultfd: update documentation to mention shmem minor faults

2021-04-15 Thread Axel Rasmussen
Generally, the documentation we wrote for hugetlbfs-based minor faults still all applies. The only missing piece is to mention the new feature flag which indicates that the kernel supports this for shmem as well. Signed-off-by: Axel Rasmussen --- Documentation/admin-guide/mm/userfaultfd.rst | 3

[PATCH v3 07/10] userfaultfd/selftests: reinitialize test context in each test

2021-04-15 Thread Axel Rasmussen
tlb, as we don't mremap in that case. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 215 --- 1 file changed, 116 insertions(+), 99 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 1f

[PATCH v3 09/10] userfaultfd/shmem: modify shmem_mcopy_atomic_pte to use install_ptes

2021-04-15 Thread Axel Rasmussen
which would double-count since shmem_add_to_page_cache() also does this. Signed-off-by: Axel Rasmussen --- include/linux/userfaultfd_k.h | 5 mm/shmem.c| 52 +++ mm/userfaultfd.c | 25 - 3 files changed, 27 inse

[PATCH v3 08/10] userfaultfd/selftests: exercise minor fault handling shmem support

2021-04-15 Thread Axel Rasmussen
Enable test_uffdio_minor for test_type == TEST_SHMEM, and modify the test slightly to pass in / check for the right feature flags. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 29 1 file changed, 25 insertions(+), 4 deletions(-) diff

[PATCH v3 05/10] userfaultfd/selftests: use memfd_create for shmem test type

2021-04-15 Thread Axel Rasmussen
userfaultfd behavior being introduced in this series. Also, a small fix in the area we're changing: when the hugetlb setup fails in main(), pass in the right argv[] so we actually print out the hugetlb file path. Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm

[PATCH v3 06/10] userfaultfd/selftests: create alias mappings in the shmem test

2021-04-15 Thread Axel Rasmussen
, we'll leverage this setup to exercise minor fault handling support for shmem, just like we do in the hugetlb_shared test. Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 22 +++--- 1 file changed, 19 insertions(+), 3 deletions

[PATCH v3 04/10] userfaultfd/shmem: support minor fault registration for shmem

2021-04-15 Thread Axel Rasmussen
a way to resolve such faults. Acked-by: Peter Xu Signed-off-by: Axel Rasmussen --- fs/userfaultfd.c | 6 +++--- include/uapi/linux/userfaultfd.h | 7 ++- mm/memory.c | 8 +--- mm/shmem.c | 12 +++- 4 files changed, 25

[PATCH v3 03/10] userfaultfd/shmem: support UFFDIO_CONTINUE for shmem

2021-04-15 Thread Axel Rasmussen
it as a separate change. Signed-off-by: Axel Rasmussen --- mm/userfaultfd.c | 176 +++ 1 file changed, 131 insertions(+), 45 deletions(-) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 23fa2583bbd1..8df0438f5d6a 100644 --- a/mm/userfaultfd.c +++ b

[PATCH v3 01/10] userfaultfd/hugetlbfs: avoid including userfaultfd_k.h in hugetlb.h

2021-04-15 Thread Axel Rasmussen
Minimizing header file inclusion is desirable. In this case, we can do so just by forward declaring the enumeration our signature relies upon. Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen --- include/linux/hugetlb.h | 4 +++- mm/hugetlb.c| 1 + 2 files changed, 4 insertions

[PATCH v3 02/10] userfaultfd/shmem: combine shmem_{mcopy_atomic,mfill_zeropage}_pte

2021-04-15 Thread Axel Rasmussen
statements. This means the line number reported when the BUG is hit specifies exactly which condition was true. Reviewed-by: Peter Xu Acked-by: Hugh Dickins Signed-off-by: Axel Rasmussen --- include/linux/shmem_fs.h | 17 ++--- mm/shmem.c | 52

[PATCH v3 00/10] userfaultfd: add minor fault handling for shmem

2021-04-15 Thread Axel Rasmussen
Without this feature, uneccessary page copying (ioctl(UFFDIO_COPY)) would be required." [1] https://lore.kernel.org/patchwork/cover/1388144/ [2] https://lore.kernel.org/patchwork/patch/1408161/ [3] https://lore.kernel.org/linux-fsdevel/20210301222728.176417-1-axelrasmus...@google.co

Re: [PATCH 4/9] userfaultfd/shmem: support UFFDIO_CONTINUE for shmem

2021-04-15 Thread Axel Rasmussen
On Tue, Apr 13, 2021 at 11:12 AM Peter Xu wrote: > > On Mon, Apr 12, 2021 at 09:40:22PM -0700, Axel Rasmussen wrote: > > On Mon, Apr 12, 2021 at 4:17 PM Peter Xu wrote: > > > > > > On Thu, Apr 08, 2021 at 04:43:22PM -0700, Axel Rasmussen wrote: > > >

Re: [PATCH v2 7/9] userfaultfd/selftests: reinitialize test context in each test

2021-04-15 Thread Axel Rasmussen
On Tue, Apr 13, 2021 at 1:15 PM Peter Xu wrote: > > On Mon, Apr 12, 2021 at 10:17:19PM -0700, Axel Rasmussen wrote: > > Currently, the context (fds, mmap-ed areas, etc.) are global. Each test > > mutates this state in some way, in some cases really "clobbering it"

[PATCH v2 6/9] userfaultfd/selftests: create alias mappings in the shmem test

2021-04-12 Thread Axel Rasmussen
, we'll leverage this setup to exercise minor fault handling support for shmem, just like we do in the hugetlb_shared test. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 22 +++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tools

[PATCH v2 8/9] userfaultfd/selftests: exercise minor fault handling shmem support

2021-04-12 Thread Axel Rasmussen
Enable test_uffdio_minor for test_type == TEST_SHMEM, and modify the test slightly to pass in / check for the right feature flags. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 29 1 file changed, 25 insertions(+), 4 deletions(-) diff

[PATCH v2 7/9] userfaultfd/selftests: reinitialize test context in each test

2021-04-12 Thread Axel Rasmussen
tlb, as we don't mremap in that case. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 221 +-- 1 file changed, 127 insertions(+), 94 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 1f

[PATCH v2 4/9] userfaultfd/shmem: support UFFDIO_CONTINUE for shmem

2021-04-12 Thread Axel Rasmussen
it as a separate change. Signed-off-by: Axel Rasmussen --- mm/userfaultfd.c | 176 +++ 1 file changed, 131 insertions(+), 45 deletions(-) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 23fa2583bbd1..8df0438f5d6a 100644 --- a/mm/userfaultfd.c +++ b

[PATCH v2 2/9] userfaultfd/shmem: combine shmem_{mcopy_atomic,mfill_zeropage}_pte

2021-04-12 Thread Axel Rasmussen
statements. This means the line number reported when the BUG is hit specifies exactly which condition was true. Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen --- include/linux/shmem_fs.h | 15 +--- mm/shmem.c | 52 +--- mm

[PATCH v2 5/9] userfaultfd/selftests: use memfd_create for shmem test type

2021-04-12 Thread Axel Rasmussen
userfaultfd behavior being introduced in this series. Also, a small fix in the area we're changing: when the hugetlb setup fails in main(), pass in the right argv[] so we actually print out the hugetlb file path. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 16

[PATCH v2 9/9] userfaultfd/shmem: modify shmem_mcopy_atomic_pte to use install_ptes

2021-04-12 Thread Axel Rasmussen
which would double-count since shmem_add_to_page_cache() also does this. Signed-off-by: Axel Rasmussen --- include/linux/userfaultfd_k.h | 5 mm/shmem.c| 52 +++ mm/userfaultfd.c | 25 - 3 files changed, 27 inse

[PATCH v2 3/9] userfaultfd/shmem: support minor fault registration for shmem

2021-04-12 Thread Axel Rasmussen
a way to resolve such faults. Signed-off-by: Axel Rasmussen --- fs/userfaultfd.c | 6 +++--- include/uapi/linux/userfaultfd.h | 7 ++- mm/memory.c | 8 +--- mm/shmem.c | 10 +- 4 files changed, 23 insertions(+), 8

[PATCH v2 1/9] userfaultfd/hugetlbfs: avoid including userfaultfd_k.h in hugetlb.h

2021-04-12 Thread Axel Rasmussen
Minimizing header file inclusion is desirable. In this case, we can do so just by forward declaring the enumeration our signature relies upon. Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen --- include/linux/hugetlb.h | 4 +++- mm/hugetlb.c| 1 + 2 files changed, 4 insertions

[PATCH v2 0/9] userfaultfd: add minor fault handling for shmem

2021-04-12 Thread Axel Rasmussen
, uneccessary page copying (ioctl(UFFDIO_COPY)) would be required." [1] https://lore.kernel.org/patchwork/cover/1388144/ [2] https://lore.kernel.org/patchwork/patch/1408161/ [3] https://lore.kernel.org/linux-fsdevel/20210301222728.176417-1-axelrasmus...@google.com/T/#t Axel Rasmussen (9): userf

Re: [PATCH 4/9] userfaultfd/shmem: support UFFDIO_CONTINUE for shmem

2021-04-12 Thread Axel Rasmussen
On Mon, Apr 12, 2021 at 4:17 PM Peter Xu wrote: > > On Thu, Apr 08, 2021 at 04:43:22PM -0700, Axel Rasmussen wrote: > > +/* > > + * Install PTEs, to map dst_addr (within dst_vma) to page. > > + * > > + * This function handles MCOPY_ATOMIC_CONTINUE (wh

Re: [PATCH 0/9] userfaultfd: add minor fault handling for shmem

2021-04-09 Thread Axel Rasmussen
On Thu, Apr 8, 2021 at 10:04 PM Andrew Morton wrote: > > On Thu, 8 Apr 2021 16:43:18 -0700 Axel Rasmussen > wrote: > > > The idea is that it will apply cleanly to akpm's tree, *replacing* the > > following > > patches (i.e., drop these first, and then apply thi

[PATCH 7/9] userfaultfd/selftests: reinitialize test context in each test

2021-04-08 Thread Axel Rasmussen
tlb, as we don't mremap in that case. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 221 +-- 1 file changed, 129 insertions(+), 92 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 4b

[PATCH 8/9] userfaultfd/selftests: exercise minor fault handling shmem support

2021-04-08 Thread Axel Rasmussen
Enable test_uffdio_minor for test_type == TEST_SHMEM, and modify the test slightly to pass in / check for the right feature flags. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 29 1 file changed, 25 insertions(+), 4 deletions(-) diff

[PATCH 3/9] userfaultfd/shmem: support minor fault registration for shmem

2021-04-08 Thread Axel Rasmussen
a way to resolve such faults. Signed-off-by: Axel Rasmussen --- fs/userfaultfd.c | 6 +++--- include/uapi/linux/userfaultfd.h | 7 ++- mm/memory.c | 8 +--- mm/shmem.c | 20 4 files changed, 30 insertions

[PATCH 5/9] userfaultfd/selftests: use memfd_create for shmem test type

2021-04-08 Thread Axel Rasmussen
userfaultfd behavior being introduced in this series. Also, a small fix in the area we're changing: when the hugetlb setup fails in main(), pass in the right argv[] so we actually print out the hugetlb file path. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 18

[PATCH 6/9] userfaultfd/selftests: create alias mappings in the shmem test

2021-04-08 Thread Axel Rasmussen
, we'll leverage this setup to exercise minor fault handling support for shmem, just like we do in the hugetlb_shared test. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 22 +++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/tools

[PATCH 4/9] userfaultfd/shmem: support UFFDIO_CONTINUE for shmem

2021-04-08 Thread Axel Rasmussen
it as a separate change. Signed-off-by: Axel Rasmussen --- mm/userfaultfd.c | 176 +++ 1 file changed, 131 insertions(+), 45 deletions(-) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 60ae22207761..a539fe18b9a7 100644 --- a/mm/userfaultfd.c +++ b

[PATCH 9/9] userfaultfd/shmem: modify shmem_mcopy_atomic_pte to use install_ptes

2021-04-08 Thread Axel Rasmussen
which would double-count since shmem_add_to_page_cache() also does this. Signed-off-by: Axel Rasmussen --- include/linux/userfaultfd_k.h | 5 mm/shmem.c| 52 +++ mm/userfaultfd.c | 25 - 3 files changed, 27 inse

[PATCH 1/9] userfaultfd/hugetlbfs: avoid including userfaultfd_k.h in hugetlb.h

2021-04-08 Thread Axel Rasmussen
Minimizing header file inclusion is desirable. In this case, we can do so just by forward declaring the enumeration our signature relies upon. Signed-off-by: Axel Rasmussen --- include/linux/hugetlb.h | 5 - mm/hugetlb.c| 1 + 2 files changed, 5 insertions(+), 1 deletion

[PATCH 2/9] userfaultfd/shmem: combine shmem_{mcopy_atomic,mfill_zeropage}_pte

2021-04-08 Thread Axel Rasmussen
statements. This means the line number reported when the BUG is hit specifies exactly which condition was true. Signed-off-by: Axel Rasmussen --- include/linux/shmem_fs.h | 15 +--- mm/shmem.c | 52 +--- mm/userfaultfd.c | 10

[PATCH 0/9] userfaultfd: add minor fault handling for shmem

2021-04-08 Thread Axel Rasmussen
.org/linux-fsdevel/20210301222728.176417-1-axelrasmus...@google.com/T/#t Axel Rasmussen (9): userfaultfd/hugetlbfs: avoid including userfaultfd_k.h in hugetlb.h userfaultfd/shmem: combine shmem_{mcopy_atomic,mfill_zeropage}_pte userfaultfd/shmem: support minor fault registration for shmem u

Re: [PATCH v5] userfaultfd/shmem: fix MCOPY_ATOMIC_CONTINUE behavior

2021-04-08 Thread Axel Rasmussen
On Tue, Apr 6, 2021 at 4:49 PM Peter Xu wrote: > > On Mon, Apr 05, 2021 at 10:19:17AM -0700, Axel Rasmussen wrote: > > Previously, the continue implementation in shmem_mcopy_atomic_pte was > > incorrect for two main reasons: > > > > - It didn't correctly skip so

Re: [PATCH v4] userfaultfd/shmem: fix MCOPY_ATOMIC_CONTINUE behavior

2021-04-07 Thread Axel Rasmussen
Thanks for the thorough and insightful review, Hugh! On Tue, Apr 6, 2021 at 11:14 PM Hugh Dickins wrote: > > [PATCH v4] userfaultfd/shmem: fix MCOPY_ATOMIC_CONTINUE behavior > was a significant rework, so here I'm reviewing a synthetic patch > merged from 5.12-rc5's 2021-03-31 mmotm patches: >

[PATCH v5] userfaultfd/shmem: fix MCOPY_ATOMIC_CONTINUE behavior

2021-04-05 Thread Axel Rasmussen
;userfaultfd: support minor fault handling for shmem") Signed-off-by: Axel Rasmussen --- mm/shmem.c | 56 +++ mm/userfaultfd.c | 183 --- tools/testing/selftests/vm/userfaultfd.c | 12 ++ 3 files changed, 168 insertion

[PATCH v4] userfaultfd/shmem: fix MCOPY_ATOMIC_CONTINUE behavior

2021-04-01 Thread Axel Rasmussen
- Fix unconditional ClearPageDirty(). - Don't pte_mkwrite() when is_continue && !VM_SHARED. [1] https://lore.kernel.org/patchwork/patch/1392464/ Fixes: 00da60b9d0a0 ("userfaultfd: support minor fault handling for shmem") Signed-off-by: Axel Rasmussen --- mm/shmem.c | 56 +

Re: [PATCH v3] userfaultfd/shmem: fix MCOPY_ATOMIC_CONTNUE behavior

2021-03-30 Thread Axel Rasmussen
On Tue, Mar 30, 2021 at 1:55 PM Peter Xu wrote: > > On Mon, Mar 29, 2021 at 04:41:31PM -0700, Axel Rasmussen wrote: > > Previously, we shared too much of the code with COPY and ZEROPAGE, so we > > manipulated things in various invalid ways: > > > > - Previou

[PATCH v3] userfaultfd/shmem: fix MCOPY_ATOMIC_CONTNUE behavior

2021-03-29 Thread Axel Rasmussen
factor to skip ahead with goto, instead of adding several more "if (!is_continue)". - Fix unconditional ClearPageDirty(). - Don't pte_mkwrite() when is_continue && !VM_SHARED. Fixes: 00da60b9d0a0 ("userfaultfd: support minor fault handling for shmem"

[PATCH v2] userfaultfd/shmem: fix MCOPY_ATOMIC_CONTNUE behavior

2021-03-29 Thread Axel Rasmussen
pte_mkwrite() when is_continue && !VM_SHARED. Fixes: 00da60b9d0a0 ("userfaultfd: support minor fault handling for shmem") Signed-off-by: Axel Rasmussen --- mm/shmem.c | 67 ++-- tools/testing/selftests/vm/userfaultfd.c | 12 +

[PATCH] userfaultfd/shmem: fix MCOPY_ATOMIC_CONTNUE error handling + accounting

2021-03-25 Thread Axel Rasmussen
accounted for the RAM usage when the page was originally allocated (since at this point it's already in the page cache). So, doing it in the continue case causes us to double-count. Fixes: 00da60b9d0a0 ("userfaultfd: support minor fault handling for shmem") Signed-off-by: Axel Rasmusse

Re: [PATCH] userfaultfd/shmem: fix minor fault page leak

2021-03-24 Thread Axel Rasmussen
On Wed, Mar 24, 2021 at 5:52 PM Peter Xu wrote: > > Hi, Andrew, > > On Wed, Mar 24, 2021 at 04:20:27PM -0700, Andrew Morton wrote: > > On Mon, 22 Mar 2021 13:48:35 -0700 Axel Rasmussen > > wrote: > > > > > This fix is analogous to Peter Xu's fix for

[PATCH] userfaultfd/shmem: fix minor fault page leak

2021-03-22 Thread Axel Rasmussen
steadily decreasing with each run of the test. With the fix, memory is correctly freed after the test program exits. Fixes: 00da60b9d0a0 ("userfaultfd: support minor fault handling for shmem") Signed-off-by: Axel Rasmussen --- mm/shmem.c | 1 + 1 file changed, 1 insertion(+) diff

Re: [PATCH] userfaultfd/hugetlbfs: Fix minor fault page leak

2021-03-22 Thread Axel Rasmussen
gt; mode, then cat /proc/meminfo. > > Cc: Axel Rasmussen > Cc: Andrea Arcangeli > Cc: Mike Kravetz > Cc: Mike Rapoport > Cc: Andrew Morton > Fixes: f2bf15fb0969 ("userfaultfd: add minor fault registration mode") > Signed-off-by: Peter Xu > --- > mm/

Re: [PATCH v2] mm/shmem: Enclose shmem_mcopy_atomic_pte() with 'CONFIG_USERFAULTFD'

2021-03-16 Thread Axel Rasmussen
Sorry for the build failure! I sent a new version of my patch with this same fix on the 10th (https://lore.kernel.org/patchwork/patch/1392464/), and I believe Andrew has already included it in his tree. On Tue, Mar 16, 2021 at 8:40 AM SeongJae Park wrote: > > From: SeongJae Park > > Commit

[PATCH] regulator: mt6315: Fix off-by-one for .n_voltages

2021-03-10 Thread Axel Lin
The valid selector is 0 ~ 0xbf, so the .n_voltages should be 0xc0. Signed-off-by: Axel Lin --- drivers/regulator/mt6315-regulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/regulator/mt6315-regulator.c b/drivers/regulator/mt6315-regulator.c index fc7654624dd6

Re: [PATCH 0/5] userfaultfd/selftests: A few cleanups

2021-03-10 Thread Axel Rasmussen
These look like good cleanups to me! I reviewed all of the patches, and tried out the resulting selftest program, it seems to work correctly. So, for what it's worth: Reviewed-by: Axel Rasmussen On Tue, Mar 9, 2021 at 4:45 PM Peter Xu wrote: > > Based on v5.12-rc2-mmots-2021-03-08

Re: [PATCH v2.5] userfaultfd: support minor fault handling for shmem

2021-03-09 Thread Axel Rasmussen
+Stephen to CC, as an FYI. On Tue, Mar 9, 2021 at 2:58 PM Axel Rasmussen wrote: > > Modify the userfaultfd register API to allow registering shmem VMAs in > minor mode. Modify the shmem mcopy implementation to support > UFFDIO_CONTINUE in order to resolve such faults. > > Combi

Re: linux-next: build failure after merge of the akpm-current tree

2021-03-09 Thread Axel Rasmussen
On Tue, Mar 9, 2021 at 7:16 PM Stephen Rothwell wrote: > > Hi all, > > After merging the akpm-current tree, today's linux-next build (powerpc > ppc64_defconfig) failed like this: Hi Stephen, Sorry about the failure! Indeed, I had guarded this in the header, but not in the .c file. I sent a v2.5

[PATCH v2.5] userfaultfd: support minor fault handling for shmem

2021-03-09 Thread Axel Rasmussen
. This matches how the hugetlbfs implementation is structured, and lets us remove a good chunk of boilerplate. Signed-off-by: Axel Rasmussen --- fs/userfaultfd.c | 6 +- include/linux/shmem_fs.h | 26 - include/uapi/linux/userfaultfd.h | 4 +- mm/memory.c

Re: [PATCH v2 1/5] userfaultfd: support minor fault handling for shmem

2021-03-09 Thread Axel Rasmussen
On Tue, Mar 9, 2021 at 11:52 AM Zi Yan wrote: > > On 1 Mar 2021, at 19:01, Axel Rasmussen wrote: > > > Modify the userfaultfd register API to allow registering shmem VMAs in > > minor mode. Modify the shmem mcopy implementation to support > > UFFDIO_CONTINUE in o

Re: [PATCH v2 0/4] man2: udpate mm/userfaultfd manpages to latest

2021-03-04 Thread Axel Rasmussen
more things, e.g. UFFDIO_COPY_MODE_WP; and also on how to resolve a > wr-protect page fault. > > There're two features missing in current manpage, namely: > > (1) Userfaultfd Thread-ID feature > (2) Userfaultfd write protect mode > > There's also a 3rd one which was just co

Re: [PATCH] spi: mediatek: Re-license MTK SPI driver as Dual MIT/GPL

2021-03-03 Thread Axel Lin
Leilk Liu 於 2021年3月3日 週三 上午10:57寫道: > > From: "leilk.liu" > > It is wanted to use MTK spi bus driver with GPL-2.0 or MIT license. > But now it is only licensed as GPL-2.0, so re-license it as dual > MIT/GPL. > > Signed-off-by: leilk.liu Acked-by: Axel Lin

[PATCH v2 1/5] userfaultfd: support minor fault handling for shmem

2021-03-01 Thread Axel Rasmussen
. This matches how the hugetlbfs implementation is structured, and lets us remove a good chunk of boilerplate. Signed-off-by: Axel Rasmussen --- fs/userfaultfd.c | 6 +-- include/linux/shmem_fs.h | 26 - include/uapi/linux/userfaultfd.h | 4 +- mm/memory.c

[PATCH v2 5/5] userfaultfd/selftests: exercise minor fault handling shmem support

2021-03-01 Thread Axel Rasmussen
Enable test_uffdio_minor for test_type == TEST_SHMEM, and modify the test slightly to pass in / check for the right feature flags. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 19 ++- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git

[PATCH v2 3/5] userfaultfd/selftests: create alias mappings in the shmem test

2021-03-01 Thread Axel Rasmussen
, we'll leverage this setup to exercise minor fault handling support for shmem, just like we do in the hugetlb_shared test. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 29 +--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/tools

[PATCH v2 2/5] userfaultfd/selftests: use memfd_create for shmem test type

2021-03-01 Thread Axel Rasmussen
userfaultfd behavior being introduced in this series. Also, a small fix in the area we're changing: when the hugetlb setup fails in main(), pass in the right argv[] so we actually print out the hugetlb file path. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 35

[PATCH v2 4/5] userfaultfd/selftests: reinitialize test context in each test

2021-03-01 Thread Axel Rasmussen
tlb, as we don't mremap in that case. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 249 ++- 1 file changed, 151 insertions(+), 98 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 4a

[PATCH v2 0/5] userfaultfd: support minor fault handling for shmem

2021-03-01 Thread Axel Rasmussen
feature, uneccessary page copying (ioctl(UFFDIO_COPY)) would be required." Axel Rasmussen (5): userfaultfd: support minor fault handling for shmem userfaultfd/selftests: use memfd_create for shmem test type userfaultfd/selftests: create alias mappings in the shmem test userfaul

[PATCH v9 4/6] userfaultfd: add UFFDIO_CONTINUE ioctl

2021-03-01 Thread Axel Rasmussen
eviewed-by: Peter Xu Signed-off-by: Axel Rasmussen --- fs/userfaultfd.c | 67 include/linux/hugetlb.h | 3 ++ include/linux/userfaultfd_k.h| 18 + include/uapi/linux/userfaultfd.h | 21 +- mm/hugetlb.c

[PATCH v9 5/6] userfaultfd: update documentation to describe minor fault handling

2021-03-01 Thread Axel Rasmussen
ING faults, whereas CONTINUE is used for MINOR faults. Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen --- Documentation/admin-guide/mm/userfaultfd.rst | 107 --- 1 file changed, 66 insertions(+), 41 deletions(-) diff --git a/Documentation/admin-guide/mm/userfaultfd.rst b/Doc

[PATCH v9 6/6] userfaultfd/selftests: add test exercising minor fault handling

2021-03-01 Thread Axel Rasmussen
INUE ioctl, to setup the mapping and resolve the fault. The reading thread should wake up and see this modification. Currently the minor fault test is only enabled in hugetlb_shared mode, as this is the only configuration the kernel feature supports. Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen

[PATCH v9 3/6] userfaultfd: hugetlbfs: only compile UFFD helpers if config enabled

2021-03-01 Thread Axel Rasmussen
-off-by: Axel Rasmussen --- include/linux/hugetlb.h | 4 mm/hugetlb.c| 2 ++ 2 files changed, 6 insertions(+) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index c0b10f0c7f23..7b86bf809d7a 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -134,11

[PATCH v9 2/6] userfaultfd: disable huge PMD sharing for MINOR registered VMAs

2021-03-01 Thread Axel Rasmussen
PMD sharing would prevent these faults from occurring for suitably aligned areas, so disable it upon UFFD registration. Reviewed-by: Peter Xu Reviewed-by: Mike Kravetz Signed-off-by: Axel Rasmussen --- include/linux/userfaultfd_k.h | 13 ++--- 1 file changed, 10 insertions(+), 3

[PATCH v9 0/6] userfaultfd: add minor fault handling

2021-03-01 Thread Axel Rasmussen
eries is more mature than the shmem support at this point, and the functionality works fully on hugetlbfs, so this series can be merged first and then shmem support will follow. Axel Rasmussen (6): userfaultfd: add minor fault registration mode userfaultfd: disable huge PMD sharing for MINOR

[PATCH v9 1/6] userfaultfd: add minor fault registration mode

2021-03-01 Thread Axel Rasmussen
ps://lore.kernel.org/patchwork/patch/1380226/ Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen --- arch/arm64/Kconfig | 1 + arch/x86/Kconfig | 1 + fs/proc/task_mmu.c | 3 ++ fs/userfaultfd.c | 78 ++

Re: [PATCH 1/5] userfaultfd: support minor fault handling for shmem

2021-02-25 Thread Axel Rasmussen
On Wed, Feb 24, 2021 at 6:14 PM Axel Rasmussen wrote: > > Modify the userfaultfd register API to allow registering shmem VMAs in > minor mode. Modify the shmem mcopy implementation to support > UFFDIO_CONTINUE in order to resolve such faults. > > Combine the shmem mcopy

Re: [PATCH v7 1/6] userfaultfd: add minor fault registration mode

2021-02-25 Thread Axel Rasmussen
On Wed, Feb 24, 2021 at 4:26 PM Mike Kravetz wrote: > > On 2/18/21 4:48 PM, Axel Rasmussen wrote: > > > @@ -401,8 +398,10 @@ vm_fault_t handle_userfault(struct vm_fault *vmf, > > unsigned long reason) > > > > BUG_ON(ctx->mm != mm); > > >

[PATCH 4/5] userfaultfd/selftests: reinitialize test context in each test

2021-02-24 Thread Axel Rasmussen
tlb, as we don't mremap in that case. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 249 ++- 1 file changed, 151 insertions(+), 98 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index 4a

[PATCH 1/5] userfaultfd: support minor fault handling for shmem

2021-02-24 Thread Axel Rasmussen
. This matches how the hugetlbfs implementation is structured, and lets us remove a good chunk of boilerplate. Signed-off-by: Axel Rasmussen --- fs/userfaultfd.c | 6 +-- include/linux/shmem_fs.h | 26 -- include/uapi/linux/userfaultfd.h | 4 +- mm/memory.c

[PATCH 3/5] userfaultfd/selftests: create alias mappings in the shmem test

2021-02-24 Thread Axel Rasmussen
, we'll leverage this setup to exercise minor fault handling support for shmem, just like we do in the hugetlb_shared test. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 29 +--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/tools

[PATCH 5/5] userfaultfd/selftests: exercise minor fault handling shmem support

2021-02-24 Thread Axel Rasmussen
Enable test_uffdio_minor for test_type == TEST_SHMEM, and modify the test slightly to pass in / check for the right feature flags. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 19 ++- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git

[PATCH 2/5] userfaultfd/selftests: use memfd_create for shmem test type

2021-02-24 Thread Axel Rasmussen
userfaultfd behavior being introduced in this series. Also, a small fix in the area we're changing: when the hugetlb setup fails in main(), pass in the right argv[] so we actually print out the hugetlb file path. Signed-off-by: Axel Rasmussen --- tools/testing/selftests/vm/userfaultfd.c | 35

[PATCH 0/5] userfaultfd: support minor fault handling for shmem

2021-02-24 Thread Axel Rasmussen
garbage collector using this feature (a paper describing a somewhat similar approach: https://arxiv.org/pdf/1902.04738.pdf). Axel Rasmussen (5): userfaultfd: support minor fault handling for shmem userfaultfd/selftests: use memfd_create for shmem test type userfaultfd/selftests: create alias

[PATCH v8 6/6] userfaultfd/selftests: add test exercising minor fault handling

2021-02-24 Thread Axel Rasmussen
INUE ioctl, to setup the mapping and resolve the fault. The reading thread should wake up and see this modification. Currently the minor fault test is only enabled in hugetlb_shared mode, as this is the only configuration the kernel feature supports. Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen

[PATCH v8 5/6] userfaultfd: update documentation to describe minor fault handling

2021-02-24 Thread Axel Rasmussen
ING faults, whereas CONTINUE is used for MINOR faults. Signed-off-by: Axel Rasmussen --- Documentation/admin-guide/mm/userfaultfd.rst | 107 --- 1 file changed, 66 insertions(+), 41 deletions(-) diff --git a/Documentation/admin-guide/mm/userfaultfd.rst b/Documentation/admi

[PATCH v8 4/6] userfaultfd: add UFFDIO_CONTINUE ioctl

2021-02-24 Thread Axel Rasmussen
IO_ZEROPAGE case, so just extend that design: add an enum for the three modes of operation, and make the small adjustments needed for the MCOPY_ATOMIC_CONTINUE case. (Basically, look up the existing page, and avoid adding the existing page to the page cache or calling set_page_huge_active() on it.)

[PATCH v8 1/6] userfaultfd: add minor fault registration mode

2021-02-24 Thread Axel Rasmussen
ps://lore.kernel.org/patchwork/patch/1380226/ Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen --- arch/arm64/Kconfig | 1 + arch/x86/Kconfig | 1 + fs/proc/task_mmu.c | 3 ++ fs/userfaultfd.c | 78 +++

[PATCH v8 2/6] userfaultfd: disable huge PMD sharing for MINOR registered VMAs

2021-02-24 Thread Axel Rasmussen
PMD sharing would prevent these faults from occurring for suitably aligned areas, so disable it upon UFFD registration. Reviewed-by: Peter Xu Signed-off-by: Axel Rasmussen --- include/linux/userfaultfd_k.h | 13 ++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git

[PATCH v8 3/6] userfaultfd: hugetlbfs: only compile UFFD helpers if config enabled

2021-02-24 Thread Axel Rasmussen
-off-by: Axel Rasmussen --- include/linux/hugetlb.h | 4 mm/hugetlb.c| 2 ++ 2 files changed, 6 insertions(+) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index ef5b55dbeb9a..7e6d2f126df3 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -134,11

[PATCH v8 0/6] userfaultfd: add minor fault handling

2021-02-24 Thread Axel Rasmussen
IO_WRITEPROTECT simply doesn't work with shared memory, and returns -ENOENT in that case (regardless of the kind of fault). Future Work === Currently the patchset only supports hugetlbfs. There is no reason it can't work with shmem, but I expect hugetlbfs to be much more commonly used

Re: [PATCH v7 4/6] userfaultfd: add UFFDIO_CONTINUE ioctl

2021-02-23 Thread Axel Rasmussen
On Tue, Feb 23, 2021 at 7:38 AM Peter Xu wrote: > > On Thu, Feb 18, 2021 at 04:48:22PM -0800, Axel Rasmussen wrote: > > @@ -4645,8 +4646,18 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct > > *dst_mm, > > spinlock_t *ptl; > > int ret; > >

[PATCH v7 4/6] userfaultfd: add UFFDIO_CONTINUE ioctl

2021-02-18 Thread Axel Rasmussen
IO_ZEROPAGE case, so just extend that design: add an enum for the three modes of operation, and make the small adjustments needed for the MCOPY_ATOMIC_CONTINUE case. (Basically, look up the existing page, and avoid adding the existing page to the page cache or calling set_page_huge_active() on it.)

[PATCH v7 3/6] userfaultfd: hugetlbfs: only compile UFFD helpers if config enabled

2021-02-18 Thread Axel Rasmussen
-off-by: Axel Rasmussen --- include/linux/hugetlb.h | 4 mm/hugetlb.c| 2 ++ 2 files changed, 6 insertions(+) diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index ef5b55dbeb9a..7e6d2f126df3 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h @@ -134,11

  1   2   3   4   5   6   7   8   9   10   >