Message ID | 20231006195318.4087158-2-willy@infradead.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Handle more faults under the VMA lock | expand |
On Fri, Oct 6, 2023 at 12:53 PM Matthew Wilcox (Oracle) <willy@infradead.org> wrote: > > Drop the VMA lock instead of the mmap_lock if that's the one which > is held. > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Reviewed-by: Suren Baghdasaryan <surenb@google.com> > --- > mm/filemap.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/mm/filemap.c b/mm/filemap.c > index 9481ffaf24e6..a598872d62cc 100644 > --- a/mm/filemap.c > +++ b/mm/filemap.c > @@ -3104,7 +3104,7 @@ static int lock_folio_maybe_drop_mmap(struct vm_fault *vmf, struct folio *folio, > > /* > * NOTE! This will make us return with VM_FAULT_RETRY, but with > - * the mmap_lock still held. That's how FAULT_FLAG_RETRY_NOWAIT > + * the fault lock still held. That's how FAULT_FLAG_RETRY_NOWAIT > * is supposed to work. We have way too many special cases.. > */ > if (vmf->flags & FAULT_FLAG_RETRY_NOWAIT) > @@ -3114,13 +3114,14 @@ static int lock_folio_maybe_drop_mmap(struct vm_fault *vmf, struct folio *folio, > if (vmf->flags & FAULT_FLAG_KILLABLE) { > if (__folio_lock_killable(folio)) { > /* > - * We didn't have the right flags to drop the mmap_lock, > - * but all fault_handlers only check for fatal signals > - * if we return VM_FAULT_RETRY, so we need to drop the > - * mmap_lock here and return 0 if we don't have a fpin. > + * We didn't have the right flags to drop the > + * fault lock, but all fault_handlers only check > + * for fatal signals if we return VM_FAULT_RETRY, > + * so we need to drop the fault lock here and > + * return 0 if we don't have a fpin. > */ > if (*fpin == NULL) > - mmap_read_unlock(vmf->vma->vm_mm); > + release_fault_lock(vmf); > return 0; > } > } else > -- > 2.40.1 >
diff --git a/mm/filemap.c b/mm/filemap.c index 9481ffaf24e6..a598872d62cc 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3104,7 +3104,7 @@ static int lock_folio_maybe_drop_mmap(struct vm_fault *vmf, struct folio *folio, /* * NOTE! This will make us return with VM_FAULT_RETRY, but with - * the mmap_lock still held. That's how FAULT_FLAG_RETRY_NOWAIT + * the fault lock still held. That's how FAULT_FLAG_RETRY_NOWAIT * is supposed to work. We have way too many special cases.. */ if (vmf->flags & FAULT_FLAG_RETRY_NOWAIT) @@ -3114,13 +3114,14 @@ static int lock_folio_maybe_drop_mmap(struct vm_fault *vmf, struct folio *folio, if (vmf->flags & FAULT_FLAG_KILLABLE) { if (__folio_lock_killable(folio)) { /* - * We didn't have the right flags to drop the mmap_lock, - * but all fault_handlers only check for fatal signals - * if we return VM_FAULT_RETRY, so we need to drop the - * mmap_lock here and return 0 if we don't have a fpin. + * We didn't have the right flags to drop the + * fault lock, but all fault_handlers only check + * for fatal signals if we return VM_FAULT_RETRY, + * so we need to drop the fault lock here and + * return 0 if we don't have a fpin. */ if (*fpin == NULL) - mmap_read_unlock(vmf->vma->vm_mm); + release_fault_lock(vmf); return 0; } } else
Drop the VMA lock instead of the mmap_lock if that's the one which is held. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> --- mm/filemap.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)