pports that (hugetlbfs_punch_hole()). But I agree with you on
what you said should be good enough. Thanks,
--
Peter Xu
r = mfill_atomic_pte(dst_mm, dst_pmd, dst_vma, dst_addr,
> -src_addr, &page, zeropage, wp_copy);
> +src_addr, &page, mcopy_mode, wp_copy);
> cond_resched();
>
> if (unlikely(err == -ENOENT)) {
> @@ -626,14 +660,22 @@ ssize_t mcopy_atomic(struct mm_struct *dst_mm, unsigned
> long dst_start,
>unsigned long src_start, unsigned long len,
>bool *mmap_changing, __u64 mode)
> {
> - return __mcopy_atomic(dst_mm, dst_start, src_start, len, false,
> - mmap_changing, mode);
> + return __mcopy_atomic(dst_mm, dst_start, src_start, len,
> + MCOPY_ATOMIC_NORMAL, mmap_changing, mode);
> }
>
> ssize_t mfill_zeropage(struct mm_struct *dst_mm, unsigned long start,
> unsigned long len, bool *mmap_changing)
> {
> - return __mcopy_atomic(dst_mm, start, 0, len, true, mmap_changing, 0);
> + return __mcopy_atomic(dst_mm, start, 0, len, MCOPY_ATOMIC_ZEROPAGE,
> + mmap_changing, 0);
> +}
> +
> +ssize_t mcopy_continue(struct mm_struct *dst_mm, unsigned long start,
> +unsigned long len, bool *mmap_changing)
> +{
> + return __mcopy_atomic(dst_mm, start, 0, len, MCOPY_ATOMIC_CONTINUE,
> + mmap_changing, 0);
> }
>
> int mwriteprotect_range(struct mm_struct *dst_mm, unsigned long start,
> --
> 2.30.0.284.gd98b1dd5eaa7-goog
>
--
Peter Xu
still the simplest way to fix the
problem for the current code base. I see io_remap_pfn_range() is also used in
the new series - maybe that'll need to be moved to where PCI_COMMAND_MEMORY got
turned on/off in the new series (I just noticed remap_pfn_range modifies vma
flags..), as you suggested in the other email.
Thanks,
--
Peter Xu
On Tue, Mar 09, 2021 at 12:26:07PM -0700, Alex Williamson wrote:
> On Tue, 9 Mar 2021 13:47:39 -0500
> Peter Xu wrote:
>
> > On Tue, Mar 09, 2021 at 12:40:04PM -0400, Jason Gunthorpe wrote:
> > > On Tue, Mar 09, 2021 at 08:29:51AM -0700, Alex Williamson wrote:
> >
an userspace to quickly
populate a huge chunk of mmap()ed region for either MMIO or RAM. Indeed from
that pov vmf_insert_pfn() seems to be even more efficient on prefaulting since
it can be threaded.
Thanks,
--
Peter Xu
ng, to use an err() macro instead of either fprintf() or perror()
then another exit() call.
The huge cleanup is done in the last patch. The first 4 patches are some other
standalone cleanups for the same file, so I put them together.
Please review, thanks.
Peter Xu (5):
userfaultfd/selftests
conditionally check the fault flag - just do it
unconditionally.
Signed-off-by: Peter Xu
---
tools/testing/selftests/vm/userfaultfd.c | 55 +---
1 file changed, 1 insertion(+), 54 deletions(-)
diff --git a/tools/testing/selftests/vm/userfaultfd.c
b/tools/testing/selftests/vm
Userfaultfd selftest does not need to handle kernel initiated fault. Set user
mode so it can be run even if unprivileged_userfaultfd=0 (which is the default).
Signed-off-by: Peter Xu
---
tools/testing/selftests/vm/userfaultfd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git
WP and MINOR modes are conditionally enabled on specific memory types. This
patch avoids dumping tons of zeros for those cases when the modes are not
supported at all.
Signed-off-by: Peter Xu
---
tools/testing/selftests/vm/userfaultfd.c | 30
1 file changed, 20
edule latency of
resolving thread. It may not mean an issue with uffd.
Neither do I saw this error triggered either in the past runs. Even if it
triggers, it'll be drown in all the rest of test logs. Remove it.
Signed-off-by: Peter Xu
---
tools/testing/selftests/vm/userfaultfd.c | 8 --
Introduce err()/_err() and replace all the different ways to fail the program,
mostly "fprintf" and "perror" with tons of exit() calls. Always stop the test
program at any failure.
Signed-off-by: Peter Xu
---
tools/testing/selftests/vm/userfaultfd.c | 649 ---
> I do not have the full history, but it 'looks' like
> lockdep might have been confused and this was added to keep it quiet.
>
> BTW - Copy page range for 'normal' pages has the same spin_lock_nested().
Yes. I'll need to take the same lock in v3, so I think I'll just follow.
Thanks,
--
Peter Xu
On Fri, Feb 05, 2021 at 01:53:34PM -0800, Mike Kravetz wrote:
> On 1/29/21 2:49 PM, Peter Xu wrote:
> > On Fri, Jan 15, 2021 at 12:08:37PM -0500, Peter Xu wrote:
> >> This is a RFC series to support userfaultfd upon shmem and hugetlbfs.
> ...
> > Huge & Mike,
> &g
On Fri, Feb 05, 2021 at 02:21:47PM -0800, Hugh Dickins wrote:
> On Fri, 29 Jan 2021, Peter Xu wrote:
> >
> > Huge & Mike,
> >
> > Would any of you have comment/concerns on the high-level design of this
> > series?
> >
> > It would be great to kn
On Sun, Feb 07, 2021 at 11:09:29AM +0200, Gal Pressman wrote:
> On 05/02/2021 17:51, Peter Xu wrote:
> > On Fri, Feb 05, 2021 at 02:58:33PM +, Zhang, Wei wrote:
> >> Hi Peter,
> >
> > Hi, Wei,
> >
> >>
> >> Gal and I worked together. We t
/lkml/20201225092529.3228466-1-na...@vmware.com/
[1] https://github.com/xzpeter/linux/tree/uffd-wp-shmem-hugetlbfs
[2] https://github.com/LLNL/umap-apps
[3] https://github.com/xzpeter/umap/tree/peter-shmem-hugetlbfs
Peter Xu (30):
mm/thp: Simplify copying of huge zero page pmd when fork
zap_details and let them
simply be parameters of unmap_mapping_range_tree(), which is inlined.
Signed-off-by: Peter Xu
---
include/linux/mm.h | 2 --
mm/memory.c| 20 ++--
2 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index
ifference.
Link: https://lore.kernel.org/lkml/20201126222359.8120-1-pet...@redhat.com/
Link: https://lore.kernel.org/lkml/20201130230603.46187-1-pet...@redhat.com/
Suggested-by: Andrea Arcangeli
Suggested-by: Hugh Dickins
Signed-off-by: Peter Xu
---
arch/x86/include
. For uffd-wp, that could lead to data loss if without the
dirty bit set.
Note that shmem_mfill_zeropage_pte() will always call shmem_mfill_atomic_pte()
with wp_copy==false because UFFDIO_ZEROCOPY does not support
UFFDIO_COPY_MODE_WP.
Signed-off-by: Peter Xu
---
include/linux/shmem_fs.h |
check_swap_entries"),
but introduce ZAP_FLAG_SKIP_SWAP flag, which means the opposite of previous
"details" parameter: the caller should explicitly set this to skip swap
entries, otherwise swap entries will always be considered (which is still the
major case here).
Cc: Kir
exist.
Note that this patch only covers the small pages (pte level) but not covering
any of the transparent huge pages yet. But this will be a base for thps too.
Signed-off-by: Peter Xu
---
mm/mprotect.c | 48
1 file changed, 48 insertions(+)
dif
x27;s separately done with
a global counter.
This prepares for a future patch to modify the huge pmd to be installed, so
that we don't need to duplicate it explicitly into huge zero page case too.
Cc: Kirill A. Shutemov
Signed-off-by: Peter Xu
---
mm/huge_memory.c | 9 +++--
1 file changed, 3
d to also
teach userfaultfd itself on either UFFDIO_COPY or handling page faults, so that
everything will still work as expected.
Signed-off-by: Peter Xu
---
fs/userfaultfd.c | 15 +++
mm/shmem.c | 13 -
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/fs/
ze fetcher.
Signed-off-by: Peter Xu
---
mm/hugetlb.c | 29 +
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 9b9f71ec30e1..7959fb4b1633 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4978,7 +4978,7 @@ uns
_MAPPING, while even_cow==true means a none
zap flag to pass in (though in most cases we have had even_cow==false).
No functional change intended.
Signed-off-by: Peter Xu
---
fs/dax.c | 10 ++
include/linux/mm.h | 4 ++--
mm/khugepaged.c| 3 ++-
mm/memory.c| 15
ptes, because it
has taken hugetlb fault mutex so that no concurrent page fault would trigger.
While the call to hugetlb_vmdelete_list() in hugetlbfs_punch_hole() is not
safe. That's why the previous call will be with ZAP_FLAG_DROP_FILE_UFFD_WP,
while the latter one won't be able to.
Si
rotection of pgtable lock.
Signed-off-by: Peter Xu
---
mm/mprotect.c | 10 +-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/mm/mprotect.c b/mm/mprotect.c
index c9390fd673fe..055871322007 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -296,8 +296,16 @@ static inline unsigned lon
with
_UFFDIO_WRITEPROTECT too because all existing types now support write
protection mode.
Since vma_can_userfault() will be used elsewhere, move into userfaultfd_k.h.
Signed-off-by: Peter Xu
---
fs/userfaultfd.c | 17 -
include/linux/userfaultfd_k.h| 7 +++
include
This is to let hugetlbfs be prepared to also recognize swap special ptes just
like uffd-wp special swap ptes.
Signed-off-by: Peter Xu
---
mm/hugetlb.c | 23 +--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index dd2acb8b3f0f
Prepare for it to be called outside of mm/hugetlb.c.
Signed-off-by: Peter Xu
---
include/linux/hugetlb.h | 8
mm/hugetlb.c| 8
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 27ada597a8e6
he special swap
pte too just like a none pte.
Note that we also need to teach UFFDIO_COPY about this special pte across the
code path so that we can safely install a new page at this special pte as long
as we know it's a stall entry.
Signed-off-by: Peter Xu
---
fs/userfaultfd.c | 5
It is a preparation work to be able to behave differently in the per
architecture huge_pte_alloc() according to different VMA attributes.
Signed-off-by: Peter Xu
---
arch/arm64/mm/hugetlbpage.c | 2 +-
arch/ia64/mm/hugetlbpage.c| 3 ++-
arch/mips/mm/hugetlbpage.c| 4 ++--
arch/parisc
arch code would like to use too
- ARM64 currently directly check against CONFIG_ARCH_WANT_HUGE_PMD_SHARE when
trying to share huge pmd. Switch to the want_pmd_share() helper.
Signed-off-by: Peter Xu
---
arch/arm64/mm/hugetlbpage.c | 3 +--
include/linux/hugetlb.h
This starts from passing cp_flags into hugetlb_change_protection() so hugetlb
will be able to handle MM_CP_UFFD_WP[_RESOLVE] requests.
huge_pte_clear_uffd_wp() is introduced to handle the case where the
UFFDIO_WRITEPROTECT is requested upon migrating huge page entries.
Signed-off-by: Peter Xu
Hook up hugetlbfs_fault() with the capability to handle userfaultfd-wp faults.
We do this slightly earlier than hugetlb_cow() so that we can avoid taking some
extra locks that we definitely don't need.
Signed-off-by: Peter Xu
---
mm/hugetlb.c | 19 +++
1 file change
und it. Doing fault-around with the new flag could confuse all the rest of
pages when installing ptes from page cache when there's a cache hit.
Signed-off-by: Peter Xu
---
include/linux/mm.h | 2 +
mm/memory.c| 107 +++--
2 files chan
want_pmd_share() in hugetlb code so that huge pmd sharing
is completely disabled for userfaultfd-wp registered range.
Signed-off-by: Peter Xu
---
fs/userfaultfd.c | 43
include/linux/mmu_notifier.h | 1 +
2 files changed, 44 insertions(+)
diff
It should be handled similarly like other uffd-wp wr-protected ptes: we should
pass it over when the dst_vma has VM_UFFD_WP armed, otherwise drop it.
Signed-off-by: Peter Xu
---
mm/memory.c | 15 ++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/mm/memory.c b/mm
f->pte first. Or, alloc_set_pte() will make sure to allocate a new
pte even after calling pte_unmap_same().
Since we'll need to modify vmf->pte, directly pass in vmf into pte_unmap_same()
and then we can also avoid the long parameter list.
Signed-off-by: Peter Xu
---
mm/memory.
th ZAP_FLAG_CHECK_MAPPING flag, it'll be very
easy to grep this information by simply grepping the flag.
It'll also make life easier when we want to e.g. pass in zap_flags into the
callers like unmap_mapping_pages() (instead of adding new booleans besides the
even_cows parame
it even if UFFDIO_COPY_MODE_WP is provided, so that the core mm will
know this page contains valid data and never drop it.
Signed-off-by: Peter Xu
---
include/asm-generic/hugetlb.h | 5 +
include/linux/hugetlb.h | 6 --
mm/hugetlb.c | 9 +++--
mm/use
lt "else" paths.
Warn properly (e.g., in do_swap_page()) when we see a special swap pte - we
should never call do_swap_page() upon those ptes, but just to bail out early if
it happens.
Signed-off-by: Peter Xu
---
fs/proc/task_mmu.c | 14 --
include/linux/swapops.h
-wp bit.
3. When convert pmd to swap entry, should drop the uffd-wp bit always.
Signed-off-by: Peter Xu
---
include/linux/swapops.h | 2 ++
mm/huge_memory.c| 4
2 files changed, 6 insertions(+)
diff --git a/include/linux/swapops.h b/include/linux/swapops.h
index d9b7c9132
opied has uffd-wp bit set.
Remove the comment in copy_present_pte() about this. It won't help a huge lot
to only comment there, but comment everywhere would be an overkill. Let's
assume the commit messages would help.
Cc: Jerome Glisse
Cc: Mike Rapoport
Fixes: b569a1760782f3da03ff718d61
g the whole vma, or
punching a hole in a shmem file. For the latter, we can only drop the uffd-wp
bit when holding the page lock. It means the unmap_mapping_range() in
shmem_fallocate() still reuqires to zap without ZAP_FLAG_DROP_FILE_UFFD_WP
because that's still racy with the page faults.
After we added support for shmem and hugetlbfs, we can turn uffd-wp test on
always now.
Signed-off-by: Peter Xu
---
tools/testing/selftests/vm/userfaultfd.c | 14 ++
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/tools/testing/selftests/vm/userfaultfd.c
b/tools
t;preserve_write" for that pte looks
odd already.
Meanwhile, if that really happens (when pte write bit set, but during a
uffd_wp_resolve request) imho there is really nothing we can do, so we should
simply avoid touching that at all, and also avoid ptep_modify_prot_start,
pte_modify, ptep_modify_prot_commit, calls etc., which takes extra cost.
Thanks,
--
Peter Xu
On Tue, Jan 05, 2021 at 01:08:48PM -0500, Andrea Arcangeli wrote:
> On Tue, Jan 05, 2021 at 10:08:13AM -0500, Peter Xu wrote:
> > On Fri, Dec 25, 2020 at 01:25:28AM -0800, Nadav Amit wrote:
> > > diff --git a/mm/mprotect.c b/mm/mprotect.c
> > > index ab709023e9aa..c08c
On Tue, Jan 05, 2021 at 07:07:51PM +, Nadav Amit wrote:
> > On Jan 5, 2021, at 7:08 AM, Peter Xu wrote:
> >
> > On Fri, Dec 25, 2020 at 01:25:28AM -0800, Nadav Amit wrote:
> >> diff --git a/mm/mprotect.c b/mm/mprotect.c
> >> index ab709023e9aa..c08c4055
COW is the only
one affected (or, is it?) while umap may not use cow that lot by accident. But
I could be completely wrong on that.
[1] https://github.com/LLNL/umap
[2] https://llnl-umap.readthedocs.io/en/develop/environment_variables.html
--
Peter Xu
t me know if you prefer me to do it, or I'll wait for your new version.
Thanks,
--
Peter Xu
On Mon, Dec 07, 2020 at 09:50:19PM -0500, Peter Xu wrote:
> Posted this small series out to rework zap_details a bit, before adding
> something new in. Hopefully it makes things slighly clearer.
>
> Smoke test only. Please have a look, thanks.
>
> Peter Xu (3):
>
userspace full control of the uffd-registered ranges, rather
than trying to do the tricks.
Cc: Hugh Dickins
Cc: Andrea Arcangeli
Cc: Andrew Morton
Cc: Mike Rapoport
Signed-off-by: Peter Xu
---
Note that since no file-backed uffd-wp support is there yet upstream, so the
uffd-wp check is actual
On Fri, Nov 27, 2020 at 10:16:05AM +0200, Mike Rapoport wrote:
> On Thu, Nov 26, 2020 at 05:23:59PM -0500, Peter Xu wrote:
> > Faulting around for reads are in most cases helpful for the performance so
> > that
> > continuous memory accesses may avoid another trip of pa
Matthew,
Thanks for the review comments.
On Fri, Nov 27, 2020 at 12:22:24PM +, Matthew Wilcox wrote:
> On Thu, Nov 26, 2020 at 05:23:59PM -0500, Peter Xu wrote:
> > For missing mode uffds, fault around does not help because if the page cache
> > existed, then the page should b
On Fri, Nov 27, 2020 at 06:00:44PM +0100, David Hildenbrand wrote:
> On 26.11.20 23:23, Peter Xu wrote:
> > Faulting around for reads are in most cases helpful for the performance so
> > that
> > continuous memory accesses may avoid another trip of page fault. However it
&g
On Fri, Nov 27, 2020 at 07:33:39PM -0500, Andrea Arcangeli wrote:
> Hello,
Hi, Andrea!
>
> On Fri, Nov 27, 2020 at 12:22:24PM +, Matthew Wilcox wrote:
> > On Thu, Nov 26, 2020 at 05:23:59PM -0500, Peter Xu wrote:
> > > For wr-protected mode uffds, errornously fau
rfaultfd: wp: userfaultfd_pte/huge_pmd_wp() helpers
userfaultfd: wp: add UFFDIO_COPY_MODE_WP
userfaultfd: wp: add the writeprotect API to userfaultfd ioctl
Martin Cracauer (1):
userfaultfd: wp: UFFDIO_REGISTER_MODE_WP documentation update
Peter Xu (17):
mm: gup: rename "nonblocking" to "lo
ter suite the
functionality of the variable. While at it, fixing up some of the
comments accordingly.
Reviewed-by: Mike Rapoport
Signed-off-by: Peter Xu
---
mm/gup.c | 44 +---
mm/hugetlb.c | 8
2 files changed, 25 insertions(+), 27
-by: Linus Torvalds
Signed-off-by: Peter Xu
---
fs/userfaultfd.c | 24
1 file changed, 24 deletions(-)
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 89800fc7dc9d..b397bc3b954d 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -514,30 +514,6 @@
t certainly worth to achieve it
but in a later incremental patch.
v3: Add hooking point for THP wrprotect faults.
CC: Shaohua Li
Signed-off-by: Andrea Arcangeli
Signed-off-by: Peter Xu
---
mm/memory.c | 12 +++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/mm/memory.c
ult write-protection.
Please read the thread below for more information.
[1] https://lkml.org/lkml/2017/11/2/833
[2] https://lkml.org/lkml/2018/12/30/64
Suggested-by: Linus Torvalds
Suggested-by: Andrea Arcangeli
Signed-off-by: Peter Xu
---
arch/alpha/mm/fault.c | 2 +-
arch/arc/m
This is the gup counterpart of the change that allows the VM_FAULT_RETRY
to happen for more than once.
Signed-off-by: Peter Xu
---
mm/gup.c | 17 +
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/mm/gup.c b/mm/gup.c
index fa75a03204c1..ba387aec0d80 100644
--- a/mm
to handle nonfatal
signals faster than before.
This patch is a preparation work for the next patch to finally remove
the special code path mentioned above in handle_userfault().
Suggested-by: Linus Torvalds
Suggested-by: Andrea Arcangeli
Signed-off-by: Peter Xu
---
arch/alpha/mm/fault.c
ay on that, we'd
need to stay on the safe side and generate false positive wp faults
for every swapped out page.
Signed-off-by: Andrea Arcangeli
Signed-off-by: Peter Xu
---
arch/x86/Kconfig | 1 +
arch/x86/include/asm/pgtable.h | 52
From: Shaohua Li
add helper for writeprotect check. Will use it later.
Cc: Andrea Arcangeli
Cc: Pavel Emelyanov
Cc: Rik van Riel
Cc: Kirill A. Shutemov
Cc: Mel Gorman
Cc: Hugh Dickins
Cc: Johannes Weiner
Signed-off-by: Shaohua Li
Signed-off-by: Andrea Arcangeli
Signed-off-by: Peter Xu
From: Andrea Arcangeli
This allows UFFDIO_COPY to map pages wrprotected.
Signed-off-by: Andrea Arcangeli
Signed-off-by: Peter Xu
---
fs/userfaultfd.c | 5 +++--
include/linux/userfaultfd_k.h| 2 +-
include/uapi/linux/userfaultfd.h | 11 +-
mm/userfaultfd.c
From: Andrea Arcangeli
Implement helpers methods to invoke userfaultfd wp faults more
selectively: not only when a wp fault triggers on a vma with
vma->vm_flags VM_UFFD_WP set, but only if the _PAGE_UFFD_WP bit is set
in the pagetable too.
Signed-off-by: Andrea Arcangeli
Signed-off-by: Pe
ameters to change_protection(). In the follow up
patches, a new parameter for userfaultfd write protection will be
introduced.
No functional change at all.
Signed-off-by: Peter Xu
---
include/linux/huge_mm.h | 2 +-
include/linux/mm.h | 14 +-
mm/huge_memory.c| 3 ++-
mm/m
Export this function for usages outside page fault handlers.
Signed-off-by: Peter Xu
---
include/linux/mm.h | 2 ++
mm/memory.c| 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index f38fbe9c8bc9..2fd14a62324b 100644
--- a
page faults in either
do_wp_page() or wp_huge_pmd().
Signed-off-by: Peter Xu
---
arch/x86/include/asm/pgtable_types.h | 2 +-
include/linux/mm.h | 5 +
mm/huge_memory.c | 14 +-
mm/memory.c | 4 ++--
mm/mprotect.c
t to
resolve an uffd-wp page fault always. That matches what we do with
general huge PMD write protections. In that way, we resolved the huge
PMD copy-on-write issue into PTE copy-on-write.
Signed-off-by: Peter Xu
---
mm/memory.c | 2 ++
mm/
: Peter Xu
---
mm/huge_memory.c | 8
mm/memory.c | 8
2 files changed, 16 insertions(+)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 817335b443c2..fb2234cb595a 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -938,6 +938,14 @@ int copy_huge_pmd(struct
Adding these missing helpers for uffd-wp operations with pmd
swap/migration entries.
Signed-off-by: Peter Xu
---
arch/x86/include/asm/pgtable.h | 15 +++
include/asm-generic/pgtable_uffd.h | 15 +++
2 files changed, 30 insertions(+)
diff --git a/arch/x86/include/asm
serfaultfd: wp: hook
userfault handler to write protection fault" where we try to remove the
VM_FAULT_WRITE from vmf->flags when uffd-wp is set for the VMA. This
patch will still keep the write flag there.
Signed-off-by: Peter Xu
---
include/linux/swapops.h | 2 ++
mm/huge_memory.c
ngeli
[peterx:
- use the helper to find VMA;
- return -ENOENT if not found to match mcopy case;
- use the new MM_CP_UFFD_WP* flags for change_protection
- check against mmap_changing for failures]
Signed-off-by: Peter Xu
---
include/linux/userfaultfd_k.h | 3 ++
mm/userfaultfd.c
same thing needs to be considered for swap entries and migration
entries. So do the check as well disregarding khugepaged_max_ptes_swap.
Signed-off-by: Peter Xu
---
include/trace/events/huge_memory.h | 1 +
mm/khugepaged.c| 23 +++
2 files changed, 24
ff-by: Peter Xu
---
fs/userfaultfd.c | 82 +---
include/uapi/linux/userfaultfd.h | 11 +
2 files changed, 77 insertions(+), 16 deletions(-)
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 3092885c9d2c..81962d62520c 100644
--- a/fs/userfaultfd.c
+++
We've have multiple (and more coming) places that would like to find a
userfault enabled VMA from a mm struct that covers a specific memory
range. This patch introduce the helper for it, meanwhile apply it to
the code.
Suggested-by: Mike Rapoport
Signed-off-by: Peter Xu
---
mm/userfaul
ff-by: Peter Xu
---
include/uapi/linux/userfaultfd.h | 6 --
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/userfaultfd.h b/include/uapi/linux/userfaultfd.h
index 1b977a7a4435..a50f1ed24d23 100644
--- a/include/uapi/linux/userfaultfd.h
+++ b/include/uapi/
It does not make sense to try to wake up any waiting thread when we're
write-protecting a memory region. Only wake up when resolving a write
protected page fault.
Signed-off-by: Peter Xu
---
fs/userfaultfd.c | 13 -
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git
structure, it's very easy to introduce new statistics.
Signed-off-by: Peter Xu
---
tools/testing/selftests/vm/userfaultfd.c | 76 +++-
1 file changed, 49 insertions(+), 27 deletions(-)
diff --git a/tools/testing/selftests/vm/userfaultfd.c
b/tools/testing/selftes
ious tests but will do MISSING+WP for each page. For
sigbus-mode test we'll need to provide standalone path to handle the
write protection faults.
For all tests, do statistics as well for uffd-wp pages.
Signed-off-by: Peter Xu
---
tools/testing/selftests/vm/user
From: Martin Cracauer
Adds documentation about the write protection support.
Signed-off-by: Andrea Arcangeli
[peterx: rewrite in rst format; fixups here and there]
Signed-off-by: Peter Xu
---
Documentation/admin-guide/mm/userfaultfd.rst | 51
1 file changed, 51
the big picture?
I believe I must have missed some contexts here and there... but I'd
like to raise the question up. Say, if the new way is preferred and
attempted, maybe it would worth it to spread the idea to the rest of
the virtio drivers who support multi-queues as well.
Thanks,
--
Peter Xu
CC: Marc Zyngier
CC: Thomas Gleixner
CC: Dou Liyang
CC: Julien Thierry
CC: Peter Xu
CC: linux-kernel@vger.kernel.org
Signed-off-by: Peter Xu
---
include/linux/irq.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/irq.h b/include/linux/irq.h
index
age sysctl.conf with that and also since no one yet
explicitly asked for sysfs for a better reason yet (And I just noticed
BPF just added another bpf_stats_enabled into sysctl a few weeks ago).
Please have a look, thanks.
Peter Xu (1):
userfaultfd/sysctl: add vm.unprivileged_userfaultfd
Documen
by: Andrea Arcangeli
Suggested-by: Mike Rapoport
Signed-off-by: Peter Xu
---
Documentation/sysctl/vm.txt | 12
fs/userfaultfd.c | 5 +
include/linux/userfaultfd_k.h | 2 ++
kernel/sysctl.c | 12
4 files changed, 31 insertions(+)
di
On Tue, Mar 19, 2019 at 06:28:23PM +, Dr. David Alan Gilbert wrote:
> * Andrew Morton (a...@linux-foundation.org) wrote:
> > On Tue, 19 Mar 2019 11:07:22 +0800 Peter Xu wrote:
> >
> > > Add a global sysctl knob "vm.unprivileged_userfaultfd" to control
>
-by: Linus Torvalds
Reviewed-by: Jerome Glisse
Signed-off-by: Peter Xu
---
fs/userfaultfd.c | 24
1 file changed, 24 deletions(-)
diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
index 89800fc7dc9d..b397bc3b954d 100644
--- a/fs/userfaultfd.c
+++ b/fs/userfaultfd.c
@@ -514
_WP
userfaultfd: wp: add the writeprotect API to userfaultfd ioctl
Martin Cracauer (1):
userfaultfd: wp: UFFDIO_REGISTER_MODE_WP documentation update
Peter Xu (19):
mm: gup: rename "nonblocking" to "locked" where proper
mm: userfault: return VM_FAULT_RETRY on signals
userfau
Linus Torvalds
Suggested-by: Andrea Arcangeli
Signed-off-by: Peter Xu
---
arch/alpha/mm/fault.c | 2 +-
arch/arc/mm/fault.c | 1 -
arch/arm/mm/fault.c | 3 ---
arch/arm64/mm/fault.c | 5 -
arch/hexagon/mm/vm_fault.c | 1 -
arch/ia64/mm/fault.c
to handle nonfatal
signals faster than before.
This patch is a preparation work for the next patch to finally remove
the special code path mentioned above in handle_userfault().
Suggested-by: Linus Torvalds
Suggested-by: Andrea Arcangeli
Reviewed-by: Jerome Glisse
Signed-off-by: Peter Xu
---
ter suite the
functionality of the variable. While at it, fixing up some of the
comments accordingly.
Reviewed-by: Mike Rapoport
Reviewed-by: Jerome Glisse
Signed-off-by: Peter Xu
---
mm/gup.c | 44 +---
mm/hugetlb.c | 8
2 files changed, 25
ome Glisse
Reviewed-by: Mike Rapoport
Signed-off-by: Peter Xu
---
include/linux/userfaultfd_k.h | 27 +++
1 file changed, 27 insertions(+)
diff --git a/include/linux/userfaultfd_k.h b/include/linux/userfaultfd_k.h
index 38f748e7186e..c6590c58ce28 100644
--- a/include/li
ameters to change_protection(). In the follow up
patches, a new parameter for userfaultfd write protection will be
introduced.
No functional change at all.
Reviewed-by: Jerome Glisse
Signed-off-by: Peter Xu
---
include/linux/huge_mm.h | 2 +-
include/linux/mm.h | 14 +-
mm/huge_memory.c
ay on that, we'd
need to stay on the safe side and generate false positive wp faults
for every swapped out page.
Signed-off-by: Andrea Arcangeli
[peterx: append _PAGE_UFD_WP to _PAGE_CHG_MASK]
Reviewed-by: Jerome Glisse
Reviewed-by: Mike Rapoport
Signed-off-by: Peter Xu
---
arch/x
This is the gup counterpart of the change that allows the VM_FAULT_RETRY
to happen for more than once.
Reviewed-by: Jerome Glisse
Signed-off-by: Peter Xu
---
mm/gup.c | 17 +
mm/hugetlb.c | 6 --
2 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/mm/gup.c
by: Jerome Glisse
Reviewed-by: Mike Rapoport
Signed-off-by: Peter Xu
---
fs/userfaultfd.c | 5 +++--
include/linux/userfaultfd_k.h| 2 +-
include/uapi/linux/userfaultfd.h | 11 +-
mm/userfaultfd.c | 36 ++--
4 files chang
t certainly worth to achieve it
but in a later incremental patch.
v3: Add hooking point for THP wrprotect faults.
CC: Shaohua Li
Signed-off-by: Andrea Arcangeli
[peterx: don't conditionally drop FAULT_FLAG_WRITE in do_swap_page]
Reviewed-by: Mike Rapoport
Signed-off-by: Peter Xu
---
mm/me
401 - 500 of 1285 matches
Mail list logo