Re: [PATCH] mm: Don't fault around userfaultfd-registered regions on reads

2020-12-01 Thread Andrea Arcangeli
Hi Hugh, On Tue, Dec 01, 2020 at 01:31:21PM -0800, Hugh Dickins wrote: > Please don't ever rely on that i_private business for correctness: as The out of order and lockless "if (inode->i_private)" branch didn't inspire much confidence in terms of being able to rely on it for locking correctness

Re: [PATCH] mm: Don't fault around userfaultfd-registered regions on reads

2020-12-01 Thread Hugh Dickins
On Sat, 28 Nov 2020, Peter Xu wrote: > On Fri, Nov 27, 2020 at 07:33:39PM -0500, Andrea Arcangeli wrote: > > > Now it would be ok if filemap_map_pages re-filled the ptes, after they > > were zapped the first time by fallocate, and then the fallocate would > > zap them again before truncating the

Re: [PATCH] mm: Don't fault around userfaultfd-registered regions on reads

2020-12-01 Thread Andrea Arcangeli
Hi Peter, On Sat, Nov 28, 2020 at 10:29:03AM -0500, Peter Xu wrote: > Yes. A trivial supplementary detail is that filemap_map_pages() will only set > it read-only since alloc_set_pte() will only set write bit if it's a write. > In > our case it's read fault-around so without it. However it'll

Re: [PATCH] mm: Don't fault around userfaultfd-registered regions on reads

2020-11-28 Thread Peter Xu
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 fault in those pages around >

Re: [PATCH] mm: Don't fault around userfaultfd-registered regions on reads

2020-11-27 Thread Andrea Arcangeli
Hello, 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 fault in those pages around could > > lead > > to threads accessing the pages without uffd server's awareness. For > >

Re: [PATCH] mm: Don't fault around userfaultfd-registered regions on reads

2020-11-27 Thread Peter Xu
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 > > may not always work

Re: [PATCH] mm: Don't fault around userfaultfd-registered regions on reads

2020-11-27 Thread David Hildenbrand
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 > may not always work as expected. > > For example, userfaultfd registered regions may not be the

Re: [PATCH] mm: Don't fault around userfaultfd-registered regions on reads

2020-11-27 Thread Peter Xu
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 be there

Re: [PATCH] mm: Don't fault around userfaultfd-registered regions on reads

2020-11-27 Thread Peter Xu
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 page fault. However it > >

Re: [PATCH] mm: Don't fault around userfaultfd-registered regions on reads

2020-11-27 Thread Matthew Wilcox
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 be there already. If the page cache is not > there, nothing else we can do, either. If the fault-around code is destined > to

Re: [PATCH] mm: Don't fault around userfaultfd-registered regions on reads

2020-11-27 Thread Mike Rapoport
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 page fault. However it > may not always work as expected. > > For example, userfaultfd registered

[PATCH] mm: Don't fault around userfaultfd-registered regions on reads

2020-11-26 Thread Peter Xu
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 may not always work as expected. For example, userfaultfd registered regions may not be the best candidate for pre-faults around the reads.