* [PATCH 1/2] mm: cleanup flags usage in faultin_page
[not found] <cover.1721337845.git.josef@toxicpanda.com>
@ 2024-07-18 21:26 ` Josef Bacik
2024-07-19 13:19 ` David Hildenbrand
2024-07-18 21:26 ` [PATCH 2/2] mm: remove foll_flags in __get_user_pages Josef Bacik
1 sibling, 1 reply; 4+ messages in thread
From: Josef Bacik @ 2024-07-18 21:26 UTC (permalink / raw)
To: akpm, linux-mm, kernel-team
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.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
mm/gup.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/mm/gup.c b/mm/gup.c
index 54d0dc3831fb..985d5141592f 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1153,19 +1153,19 @@ static int get_gate_page(struct mm_struct *mm, unsigned long address,
* to 0 and -EBUSY returned.
*/
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)
{
unsigned int fault_flags = 0;
vm_fault_t ret;
- if (*flags & FOLL_NOFAULT)
+ if (flags & FOLL_NOFAULT)
return -EFAULT;
- if (*flags & FOLL_WRITE)
+ if (flags & FOLL_WRITE)
fault_flags |= FAULT_FLAG_WRITE;
- if (*flags & FOLL_REMOTE)
+ if (flags & FOLL_REMOTE)
fault_flags |= FAULT_FLAG_REMOTE;
- if (*flags & FOLL_UNLOCKABLE) {
+ if (flags & FOLL_UNLOCKABLE) {
fault_flags |= FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
/*
* FAULT_FLAG_INTERRUPTIBLE is opt-in. GUP callers must set
@@ -1173,12 +1173,12 @@ static int faultin_page(struct vm_area_struct *vma,
* That's because some callers may not be prepared to
* handle early exits caused by non-fatal signals.
*/
- if (*flags & FOLL_INTERRUPTIBLE)
+ if (flags & FOLL_INTERRUPTIBLE)
fault_flags |= FAULT_FLAG_INTERRUPTIBLE;
}
- if (*flags & FOLL_NOWAIT)
+ if (flags & FOLL_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
* can co-exist
@@ -1212,7 +1212,7 @@ static int faultin_page(struct vm_area_struct *vma,
}
if (ret & VM_FAULT_ERROR) {
- int err = vm_fault_to_errno(ret, *flags);
+ int err = vm_fault_to_errno(ret, flags);
if (err)
return err;
@@ -1490,7 +1490,7 @@ static long __get_user_pages(struct mm_struct *mm,
page = follow_page_mask(vma, start, foll_flags, &ctx);
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);
switch (ret) {
case 0:
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] mm: remove foll_flags in __get_user_pages
[not found] <cover.1721337845.git.josef@toxicpanda.com>
2024-07-18 21:26 ` [PATCH 1/2] mm: cleanup flags usage in faultin_page Josef Bacik
@ 2024-07-18 21:26 ` Josef Bacik
2024-07-19 13:24 ` David Hildenbrand
1 sibling, 1 reply; 4+ messages in thread
From: Josef Bacik @ 2024-07-18 21:26 UTC (permalink / raw)
To: akpm, linux-mm, kernel-team
Now that we're not passing around a pointer to the flags, there's no
reason to have an extra variable for the gup_flags, simply pass the
gup_flags directly everywhere.
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
mm/gup.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/mm/gup.c b/mm/gup.c
index 985d5141592f..120740cf5a34 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1437,7 +1437,6 @@ static long __get_user_pages(struct mm_struct *mm,
do {
struct page *page;
- unsigned int foll_flags = gup_flags;
unsigned int page_increm;
/* first iteration or cross vma bound */
@@ -1488,9 +1487,9 @@ static long __get_user_pages(struct mm_struct *mm,
}
cond_resched();
- page = follow_page_mask(vma, start, foll_flags, &ctx);
+ page = follow_page_mask(vma, start, gup_flags, &ctx);
if (!page || PTR_ERR(page) == -EMLINK) {
- ret = faultin_page(vma, start, foll_flags,
+ ret = faultin_page(vma, start, gup_flags,
PTR_ERR(page) == -EMLINK, locked);
switch (ret) {
case 0:
@@ -1547,13 +1546,12 @@ static long __get_user_pages(struct mm_struct *mm,
* large folio, this should never fail.
*/
if (try_grab_folio(folio, page_increm - 1,
- foll_flags)) {
+ gup_flags)) {
/*
* Release the 1st page ref if the
* folio is problematic, fail hard.
*/
- gup_put_folio(folio, 1,
- foll_flags);
+ gup_put_folio(folio, 1, gup_flags);
ret = -EFAULT;
goto out;
}
--
2.43.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] mm: cleanup flags usage in faultin_page
2024-07-18 21:26 ` [PATCH 1/2] mm: cleanup flags usage in faultin_page Josef Bacik
@ 2024-07-19 13:19 ` David Hildenbrand
0 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2024-07-19 13:19 UTC (permalink / raw)
To: Josef Bacik, akpm, linux-mm, kernel-team
On 18.07.24 23:26, Josef Bacik wrote:
> 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.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] mm: remove foll_flags in __get_user_pages
2024-07-18 21:26 ` [PATCH 2/2] mm: remove foll_flags in __get_user_pages Josef Bacik
@ 2024-07-19 13:24 ` David Hildenbrand
0 siblings, 0 replies; 4+ messages in thread
From: David Hildenbrand @ 2024-07-19 13:24 UTC (permalink / raw)
To: Josef Bacik, akpm, linux-mm, kernel-team
On 18.07.24 23:26, Josef Bacik wrote:
> Now that we're not passing around a pointer to the flags, there's no
> reason to have an extra variable for the gup_flags, simply pass the
> gup_flags directly everywhere.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-07-19 13:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <cover.1721337845.git.josef@toxicpanda.com>
2024-07-18 21:26 ` [PATCH 1/2] mm: cleanup flags usage in faultin_page Josef Bacik
2024-07-19 13:19 ` David Hildenbrand
2024-07-18 21:26 ` [PATCH 2/2] mm: remove foll_flags in __get_user_pages Josef Bacik
2024-07-19 13:24 ` David Hildenbrand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox