All of lore.kernel.org
 help / color / mirror / Atom feed
* DAX: bug in COW no page fault?
@ 2016-01-29 21:38 Jared Hulbert
  2016-01-29 21:53 ` Wilcox, Matthew R
  0 siblings, 1 reply; 8+ messages in thread
From: Jared Hulbert @ 2016-01-29 21:38 UTC (permalink / raw)
  To: linux-fsdevel, Wilcox, Matthew R, ross.zwisler

Why isn't this required?

diff --git a/fs/dax.c b/fs/dax.c
index a7f77e1..30f2abe 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -416,6 +416,7 @@ int __dax_fault(struct vm_area_struct *vma, struct vm_fault
                                error = -EIO;
                                goto out;
                        }
+                       i_mmap_unlock_read(mapping);
                }
                return VM_FAULT_LOCKED;
        }

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* RE: bug in COW no page fault?
  2016-01-29 21:38 DAX: bug in COW no page fault? Jared Hulbert
@ 2016-01-29 21:53 ` Wilcox, Matthew R
  2016-01-29 22:12   ` Jared Hulbert
  0 siblings, 1 reply; 8+ messages in thread
From: Wilcox, Matthew R @ 2016-01-29 21:53 UTC (permalink / raw)
  To: Jared Hulbert, linux-fsdevel, ross.zwisler

Because we need to hold the i_mmap_sem until the page is inserted into the page tables to avoid racing with truncate.  Therefore it is unlocked by the MM code.

Did you try this patch?  It should have BUGged immediately that you hit this case.  If not, you have insufficient CONFIG_DEBUG enabled.

________________________________________
From: Jared Hulbert [jaredeh@gmail.com]
Sent: January 29, 2016 1:38 PM
To: linux-fsdevel@vger.kernel.org; Wilcox, Matthew R; ross.zwisler@linux.intel.com
Subject: DAX: bug in COW no page fault?

Why isn't this required?

diff --git a/fs/dax.c b/fs/dax.c
index a7f77e1..30f2abe 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -416,6 +416,7 @@ int __dax_fault(struct vm_area_struct *vma, struct vm_fault
                                error = -EIO;
                                goto out;
                        }
+                       i_mmap_unlock_read(mapping);
                }
                return VM_FAULT_LOCKED;
        }

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: bug in COW no page fault?
  2016-01-29 21:53 ` Wilcox, Matthew R
@ 2016-01-29 22:12   ` Jared Hulbert
  2016-01-29 22:36     ` Wilcox, Matthew R
  0 siblings, 1 reply; 8+ messages in thread
From: Jared Hulbert @ 2016-01-29 22:12 UTC (permalink / raw)
  To: Wilcox, Matthew R; +Cc: linux-fsdevel, ross.zwisler

Which page?  The unmatched call for i_mmap_lock_read() is only called
if(!page).  Ahh, are we locking for the cow_page?  Okay, then why
don't we lock when page != NULL in the COW case?

On Fri, Jan 29, 2016 at 1:53 PM, Wilcox, Matthew R
<matthew.r.wilcox@intel.com> wrote:
> Because we need to hold the i_mmap_sem until the page is inserted into the page tables to avoid racing with truncate.  Therefore it is unlocked by the MM code.
>
> Did you try this patch?  It should have BUGged immediately that you hit this case.  If not, you have insufficient CONFIG_DEBUG enabled.
>
> ________________________________________
> From: Jared Hulbert [jaredeh@gmail.com]
> Sent: January 29, 2016 1:38 PM
> To: linux-fsdevel@vger.kernel.org; Wilcox, Matthew R; ross.zwisler@linux.intel.com
> Subject: DAX: bug in COW no page fault?
>
> Why isn't this required?
>
> diff --git a/fs/dax.c b/fs/dax.c
> index a7f77e1..30f2abe 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
> @@ -416,6 +416,7 @@ int __dax_fault(struct vm_area_struct *vma, struct vm_fault
>                                 error = -EIO;
>                                 goto out;
>                         }
> +                       i_mmap_unlock_read(mapping);
>                 }
>                 return VM_FAULT_LOCKED;
>         }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: bug in COW no page fault?
  2016-01-29 22:12   ` Jared Hulbert
@ 2016-01-29 22:36     ` Wilcox, Matthew R
  2016-01-29 23:16       ` Jared Hulbert
  0 siblings, 1 reply; 8+ messages in thread
From: Wilcox, Matthew R @ 2016-01-29 22:36 UTC (permalink / raw)
  To: Jared Hulbert; +Cc: linux-fsdevel, ross.zwisler

Because then we lock the page instead of the i_mmap_sem.  The code in mm/memory.c isn't /that/ hard to understand, is it?
________________________________________
From: Jared Hulbert [jaredeh@gmail.com]
Sent: January 29, 2016 2:12 PM
To: Wilcox, Matthew R
Cc: linux-fsdevel@vger.kernel.org; ross.zwisler@linux.intel.com
Subject: Re: bug in COW no page fault?

Which page?  The unmatched call for i_mmap_lock_read() is only called
if(!page).  Ahh, are we locking for the cow_page?  Okay, then why
don't we lock when page != NULL in the COW case?

On Fri, Jan 29, 2016 at 1:53 PM, Wilcox, Matthew R
<matthew.r.wilcox@intel.com> wrote:
> Because we need to hold the i_mmap_sem until the page is inserted into the page tables to avoid racing with truncate.  Therefore it is unlocked by the MM code.
>
> Did you try this patch?  It should have BUGged immediately that you hit this case.  If not, you have insufficient CONFIG_DEBUG enabled.
>
> ________________________________________
> From: Jared Hulbert [jaredeh@gmail.com]
> Sent: January 29, 2016 1:38 PM
> To: linux-fsdevel@vger.kernel.org; Wilcox, Matthew R; ross.zwisler@linux.intel.com
> Subject: DAX: bug in COW no page fault?
>
> Why isn't this required?
>
> diff --git a/fs/dax.c b/fs/dax.c
> index a7f77e1..30f2abe 100644
> --- a/fs/dax.c
> +++ b/fs/dax.c
> @@ -416,6 +416,7 @@ int __dax_fault(struct vm_area_struct *vma, struct vm_fault
>                                 error = -EIO;
>                                 goto out;
>                         }
> +                       i_mmap_unlock_read(mapping);
>                 }
>                 return VM_FAULT_LOCKED;
>         }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: bug in COW no page fault?
  2016-01-29 22:36     ` Wilcox, Matthew R
@ 2016-01-29 23:16       ` Jared Hulbert
  2016-01-30  5:47         ` Wilcox, Matthew R
  0 siblings, 1 reply; 8+ messages in thread
From: Jared Hulbert @ 2016-01-29 23:16 UTC (permalink / raw)
  To: Wilcox, Matthew R; +Cc: linux-fsdevel, ross.zwisler

oh...  Look!  There it is, right where it should be.  Sorry.

Recovering from years of Android and VMware, please be patient.

On Fri, Jan 29, 2016 at 2:36 PM, Wilcox, Matthew R
<matthew.r.wilcox@intel.com> wrote:
> Because then we lock the page instead of the i_mmap_sem.  The code in mm/memory.c isn't /that/ hard to understand, is it?
> ________________________________________
> From: Jared Hulbert [jaredeh@gmail.com]
> Sent: January 29, 2016 2:12 PM
> To: Wilcox, Matthew R
> Cc: linux-fsdevel@vger.kernel.org; ross.zwisler@linux.intel.com
> Subject: Re: bug in COW no page fault?
>
> Which page?  The unmatched call for i_mmap_lock_read() is only called
> if(!page).  Ahh, are we locking for the cow_page?  Okay, then why
> don't we lock when page != NULL in the COW case?
>
> On Fri, Jan 29, 2016 at 1:53 PM, Wilcox, Matthew R
> <matthew.r.wilcox@intel.com> wrote:
>> Because we need to hold the i_mmap_sem until the page is inserted into the page tables to avoid racing with truncate.  Therefore it is unlocked by the MM code.
>>
>> Did you try this patch?  It should have BUGged immediately that you hit this case.  If not, you have insufficient CONFIG_DEBUG enabled.
>>
>> ________________________________________
>> From: Jared Hulbert [jaredeh@gmail.com]
>> Sent: January 29, 2016 1:38 PM
>> To: linux-fsdevel@vger.kernel.org; Wilcox, Matthew R; ross.zwisler@linux.intel.com
>> Subject: DAX: bug in COW no page fault?
>>
>> Why isn't this required?
>>
>> diff --git a/fs/dax.c b/fs/dax.c
>> index a7f77e1..30f2abe 100644
>> --- a/fs/dax.c
>> +++ b/fs/dax.c
>> @@ -416,6 +416,7 @@ int __dax_fault(struct vm_area_struct *vma, struct vm_fault
>>                                 error = -EIO;
>>                                 goto out;
>>                         }
>> +                       i_mmap_unlock_read(mapping);
>>                 }
>>                 return VM_FAULT_LOCKED;
>>         }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: bug in COW no page fault?
  2016-01-29 23:16       ` Jared Hulbert
@ 2016-01-30  5:47         ` Wilcox, Matthew R
  2016-01-30  6:34           ` Jared Hulbert
  2016-02-01 21:12           ` Ross Zwisler
  0 siblings, 2 replies; 8+ messages in thread
From: Wilcox, Matthew R @ 2016-01-30  5:47 UTC (permalink / raw)
  To: Jared Hulbert; +Cc: linux-fsdevel, ross.zwisler

I remembered that Ross had a similar question, so it must be hard to understand.  How does this comment work for both of you?

+               /*
+                * A truncate must remove COWs of pages that are removed
+                * from the file.  If we have a struct page, the normal
+                * page lock mechanism prevents truncate from missing the
+                * COWed page.  If not, the i_mmap_lock can provide the
+                * same guarantee.  It is dropped by the caller after the
+                * page is safely in the page tables.
+                */

________________________________________
From: Jared Hulbert [jaredeh@gmail.com]
Sent: January 29, 2016 3:16 PM
To: Wilcox, Matthew R
Cc: linux-fsdevel@vger.kernel.org; ross.zwisler@linux.intel.com
Subject: Re: bug in COW no page fault?

oh...  Look!  There it is, right where it should be.  Sorry.

Recovering from years of Android and VMware, please be patient.

On Fri, Jan 29, 2016 at 2:36 PM, Wilcox, Matthew R
<matthew.r.wilcox@intel.com> wrote:
> Because then we lock the page instead of the i_mmap_sem.  The code in mm/memory.c isn't /that/ hard to understand, is it?
> ________________________________________
> From: Jared Hulbert [jaredeh@gmail.com]
> Sent: January 29, 2016 2:12 PM
> To: Wilcox, Matthew R
> Cc: linux-fsdevel@vger.kernel.org; ross.zwisler@linux.intel.com
> Subject: Re: bug in COW no page fault?
>
> Which page?  The unmatched call for i_mmap_lock_read() is only called
> if(!page).  Ahh, are we locking for the cow_page?  Okay, then why
> don't we lock when page != NULL in the COW case?
>
> On Fri, Jan 29, 2016 at 1:53 PM, Wilcox, Matthew R
> <matthew.r.wilcox@intel.com> wrote:
>> Because we need to hold the i_mmap_sem until the page is inserted into the page tables to avoid racing with truncate.  Therefore it is unlocked by the MM code.
>>
>> Did you try this patch?  It should have BUGged immediately that you hit this case.  If not, you have insufficient CONFIG_DEBUG enabled.
>>
>> ________________________________________
>> From: Jared Hulbert [jaredeh@gmail.com]
>> Sent: January 29, 2016 1:38 PM
>> To: linux-fsdevel@vger.kernel.org; Wilcox, Matthew R; ross.zwisler@linux.intel.com
>> Subject: DAX: bug in COW no page fault?
>>
>> Why isn't this required?
>>
>> diff --git a/fs/dax.c b/fs/dax.c
>> index a7f77e1..30f2abe 100644
>> --- a/fs/dax.c
>> +++ b/fs/dax.c
>> @@ -416,6 +416,7 @@ int __dax_fault(struct vm_area_struct *vma, struct vm_fault
>>                                 error = -EIO;
>>                                 goto out;
>>                         }
>> +                       i_mmap_unlock_read(mapping);
>>                 }
>>                 return VM_FAULT_LOCKED;
>>         }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: bug in COW no page fault?
  2016-01-30  5:47         ` Wilcox, Matthew R
@ 2016-01-30  6:34           ` Jared Hulbert
  2016-02-01 21:12           ` Ross Zwisler
  1 sibling, 0 replies; 8+ messages in thread
From: Jared Hulbert @ 2016-01-30  6:34 UTC (permalink / raw)
  To: Wilcox, Matthew R; +Cc: linux-fsdevel, ross.zwisler

That's helpful.  Thanks.

On Fri, Jan 29, 2016 at 9:47 PM, Wilcox, Matthew R
<matthew.r.wilcox@intel.com> wrote:
> I remembered that Ross had a similar question, so it must be hard to understand.  How does this comment work for both of you?
>
> +               /*
> +                * A truncate must remove COWs of pages that are removed
> +                * from the file.  If we have a struct page, the normal
> +                * page lock mechanism prevents truncate from missing the
> +                * COWed page.  If not, the i_mmap_lock can provide the
> +                * same guarantee.  It is dropped by the caller after the
> +                * page is safely in the page tables.
> +                */
>
> ________________________________________
> From: Jared Hulbert [jaredeh@gmail.com]
> Sent: January 29, 2016 3:16 PM
> To: Wilcox, Matthew R
> Cc: linux-fsdevel@vger.kernel.org; ross.zwisler@linux.intel.com
> Subject: Re: bug in COW no page fault?
>
> oh...  Look!  There it is, right where it should be.  Sorry.
>
> Recovering from years of Android and VMware, please be patient.
>
> On Fri, Jan 29, 2016 at 2:36 PM, Wilcox, Matthew R
> <matthew.r.wilcox@intel.com> wrote:
>> Because then we lock the page instead of the i_mmap_sem.  The code in mm/memory.c isn't /that/ hard to understand, is it?
>> ________________________________________
>> From: Jared Hulbert [jaredeh@gmail.com]
>> Sent: January 29, 2016 2:12 PM
>> To: Wilcox, Matthew R
>> Cc: linux-fsdevel@vger.kernel.org; ross.zwisler@linux.intel.com
>> Subject: Re: bug in COW no page fault?
>>
>> Which page?  The unmatched call for i_mmap_lock_read() is only called
>> if(!page).  Ahh, are we locking for the cow_page?  Okay, then why
>> don't we lock when page != NULL in the COW case?
>>
>> On Fri, Jan 29, 2016 at 1:53 PM, Wilcox, Matthew R
>> <matthew.r.wilcox@intel.com> wrote:
>>> Because we need to hold the i_mmap_sem until the page is inserted into the page tables to avoid racing with truncate.  Therefore it is unlocked by the MM code.
>>>
>>> Did you try this patch?  It should have BUGged immediately that you hit this case.  If not, you have insufficient CONFIG_DEBUG enabled.
>>>
>>> ________________________________________
>>> From: Jared Hulbert [jaredeh@gmail.com]
>>> Sent: January 29, 2016 1:38 PM
>>> To: linux-fsdevel@vger.kernel.org; Wilcox, Matthew R; ross.zwisler@linux.intel.com
>>> Subject: DAX: bug in COW no page fault?
>>>
>>> Why isn't this required?
>>>
>>> diff --git a/fs/dax.c b/fs/dax.c
>>> index a7f77e1..30f2abe 100644
>>> --- a/fs/dax.c
>>> +++ b/fs/dax.c
>>> @@ -416,6 +416,7 @@ int __dax_fault(struct vm_area_struct *vma, struct vm_fault
>>>                                 error = -EIO;
>>>                                 goto out;
>>>                         }
>>> +                       i_mmap_unlock_read(mapping);
>>>                 }
>>>                 return VM_FAULT_LOCKED;
>>>         }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: bug in COW no page fault?
  2016-01-30  5:47         ` Wilcox, Matthew R
  2016-01-30  6:34           ` Jared Hulbert
@ 2016-02-01 21:12           ` Ross Zwisler
  1 sibling, 0 replies; 8+ messages in thread
From: Ross Zwisler @ 2016-02-01 21:12 UTC (permalink / raw)
  To: Wilcox, Matthew R; +Cc: Jared Hulbert, linux-fsdevel, ross.zwisler

On Sat, Jan 30, 2016 at 05:47:18AM +0000, Wilcox, Matthew R wrote:
> I remembered that Ross had a similar question, so it must be hard to understand.  How does this comment work for both of you?
> 
> +               /*
> +                * A truncate must remove COWs of pages that are removed
> +                * from the file.  If we have a struct page, the normal
> +                * page lock mechanism prevents truncate from missing the
> +                * COWed page.  If not, the i_mmap_lock can provide the
> +                * same guarantee.  It is dropped by the caller after the
> +                * page is safely in the page tables.
> +                */

Yep, this makes sense.  It may be worthwhile to explicitly say "It is dropped
by do_cow_fault() after the page is safely in the page tables." so the less
experienced among us (me) can easily find the match to the i_mmap_lock_read().

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-02-01 21:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-29 21:38 DAX: bug in COW no page fault? Jared Hulbert
2016-01-29 21:53 ` Wilcox, Matthew R
2016-01-29 22:12   ` Jared Hulbert
2016-01-29 22:36     ` Wilcox, Matthew R
2016-01-29 23:16       ` Jared Hulbert
2016-01-30  5:47         ` Wilcox, Matthew R
2016-01-30  6:34           ` Jared Hulbert
2016-02-01 21:12           ` Ross Zwisler

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.