Commit 47872953 authored by Josef Bacik's avatar Josef Bacik Committed by Andrew Morton

mm: cleanup flags usage in faultin_page

Patch series "mm: some small page fault cleanups".

I was recently wreaking havoc in the page fault code and I noticed some
things that could be cleaned up.  We no longer modify the gup flags in
faultin_page, so we can clean up how we pass the flags in and remove the
extra variable in __get_user_pages.


This patch (of 2):

We're passing a pointer to the foll_flags for faultin_page, however we
never modify the flags in this call.  Change this to just take the flags
value instead.

Link: https://lkml.kernel.org/r/2df51a54c06bdf93e1cb09a19a9ef1df6557b59e.1721337845.git.josef@toxicpanda.comSigned-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent c3954273
...@@ -1153,19 +1153,19 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address, ...@@ -1153,19 +1153,19 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address,
* to 0 and -EBUSY returned. * to 0 and -EBUSY returned.
*/ */
static int faultin_page(struct vm_area_struct *vma, static int faultin_page(struct vm_area_struct *vma,
unsigned long address, unsigned int *flags, bool unshare, unsigned long address, unsigned int flags, bool unshare,
int *locked) int *locked)
{ {
unsigned int fault_flags = 0; unsigned int fault_flags = 0;
vm_fault_t ret; vm_fault_t ret;
if (*flags & FOLL_NOFAULT) if (flags & FOLL_NOFAULT)
return -EFAULT; return -EFAULT;
if (*flags & FOLL_WRITE) if (flags & FOLL_WRITE)
fault_flags |= FAULT_FLAG_WRITE; fault_flags |= FAULT_FLAG_WRITE;
if (*flags & FOLL_REMOTE) if (flags & FOLL_REMOTE)
fault_flags |= FAULT_FLAG_REMOTE; fault_flags |= FAULT_FLAG_REMOTE;
if (*flags & FOLL_UNLOCKABLE) { if (flags & FOLL_UNLOCKABLE) {
fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE; fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
/* /*
* FAULT_FLAG_INTERRUPTIBLE is opt-in. GUP callers must set * FAULT_FLAG_INTERRUPTIBLE is opt-in. GUP callers must set
...@@ -1173,12 +1173,12 @@ static int faultin_page(struct vm_area_struct *vma, ...@@ -1173,12 +1173,12 @@ static int faultin_page(struct vm_area_struct *vma,
* That's because some callers may not be prepared to * That's because some callers may not be prepared to
* handle early exits caused by non-fatal signals. * handle early exits caused by non-fatal signals.
*/ */
if (*flags & FOLL_INTERRUPTIBLE) if (flags & FOLL_INTERRUPTIBLE)
fault_flags |= FAULT_FLAG_INTERRUPTIBLE; fault_flags |= FAULT_FLAG_INTERRUPTIBLE;
} }
if (*flags & FOLL_NOWAIT) if (flags & FOLL_NOWAIT)
fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_RETRY_NOWAIT; fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_RETRY_NOWAIT;
if (*flags & FOLL_TRIED) { if (flags & FOLL_TRIED) {
/* /*
* Note: FAULT_FLAG_ALLOW_RETRY and FAULT_FLAG_TRIED * Note: FAULT_FLAG_ALLOW_RETRY and FAULT_FLAG_TRIED
* can co-exist * can co-exist
...@@ -1212,7 +1212,7 @@ static int faultin_page(struct vm_area_struct *vma, ...@@ -1212,7 +1212,7 @@ static int faultin_page(struct vm_area_struct *vma,
} }
if (ret & VM_FAULT_ERROR) { if (ret & VM_FAULT_ERROR) {
int err = vm_fault_to_errno(ret, *flags); int err = vm_fault_to_errno(ret, flags);
if (err) if (err)
return err; return err;
...@@ -1490,7 +1490,7 @@ static long __get_user_pages(struct mm_struct *mm, ...@@ -1490,7 +1490,7 @@ static long __get_user_pages(struct mm_struct *mm,
page = follow_page_mask(vma, start, foll_flags, &ctx); page = follow_page_mask(vma, start, foll_flags, &ctx);
if (!page || PTR_ERR(page) == -EMLINK) { if (!page || PTR_ERR(page) == -EMLINK) {
ret = faultin_page(vma, start, &foll_flags, ret = faultin_page(vma, start, foll_flags,
PTR_ERR(page) == -EMLINK, locked); PTR_ERR(page) == -EMLINK, locked);
switch (ret) { switch (ret) {
case 0: case 0:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment