userfaultfd: reset err to be 0 when move_pages_ptes succeeded
Subsystems (2)
PATCH v3 1/1 userfaultfd: reset err to be 0 when move_pages_ptes succeeded
During move_pages() operation, when move_pages_ptes() returns EAGAIN, the error code is not cleared even after we processed it. This leads to a successful retry but then the same pages are retried again due to the stale error code. This time move fails because pages are already moved, loop is terminated and move_pages() reports a failure. Clear the error code once we processes EAGAIN.
---
Changes in v3:
- Updated to use proper sign off.
Changes in v2:
- Updated on description to be easier to understood
- Reset err before retrying, instead of fixing right at the move_pages_ptes branch.
- Added Assisted-by, received an answer few days ago from linux-newbies IRC that even I just used AI/LLM as "fast path" of git bisect. I still need to add it following
https://docs.kernel.org/process/coding-assistants.html doc.
--- mm/userfaultfd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/userfaultfd.c +3 -1
@@ -2085,8 +2085,10 @@ static ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start, }if (err) { -if (err == -EAGAIN ) +if (err == -EAGAIN ) { + err =0 ;continue ; + }break ; }
Signature · 1 line
2.55.0
Andrew Morton
maintainerQuoted 11 lines · On Wed, 19 Aug 2026 10:08:24 +0700 (WIB) Foxie Flakey <[email protected]>…
During
move_pages()operation, whenmove_pages_ptes()returns EAGAIN, the error code is not cleared even after we processed it. This leads to a successful retry but then the same pages are retried again due to the stale error code. This time move fails because pages are already moved, loop is terminated andmove_pages()reports a failure. Clear the error code once we processes EAGAIN.Fixes 50944692052b ("userfaultfd: opportunistic TLB-flush batching for present pages in MOVE")Assisted-by ChatGPT:GPT-5.6-LunaSigned-off-by Bryan Lim <[email protected]>
Thanks, Bryan.
More paperwork: the signoff is supposed to match the Author:. The way to do this is to add an explicit From: line at start-of-changelog. If this is not present, we fall back to the email envelope's From:.
mm/userfaultfd.c static ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start, · line 2093
Quoted 13 lines
mm/userfaultfd.c +3
-1@@ -2085,8 +2085,10 @@ static ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start, }if (err) { -if (err == -EAGAIN ) +if (err == -EAGAIN ) { + err =0 ;continue ; + }break ; }
I'll queue it, with an adjusted From:, as above.
Could reviewers please advise on whether we should backport this into -stable kernels?
Quoted 10 lines · Andrew Morton
Quoted 8 lines · On Wed, 19 Aug 2026 10:08:24 +0700 (WIB) Foxie Flakey <[email protected]>…
During
move_pages()operation, whenmove_pages_ptes()returns EAGAIN, the error code is not cleared even after we processed it. This leads to a successful retry but then the same pages are retried again due to the stale error code. This time move fails because pages are already moved, loop is terminated andmove_pages()reports a failure. Clear the error code once we processes EAGAIN.
Quoted 5 lines
Quoted 3 lines
Fixes 50944692052b ("userfaultfd: opportunistic TLB-flush batching for present pages in MOVE")Assisted-by ChatGPT:GPT-5.6-LunaSigned-off-by Bryan Lim <[email protected]>Thanks, Bryan.
No, problem. Thank you for your time. If you don't mind this, I would prefer keep to be called as Foxie unless its required to be Bryan Lim like the sign off. Sorry, if it took a while for me to understand.
Quoted 3 lines
More paperwork: the signoff is supposed to match the Author:. The way to do this is to add an explicit From: line at start-of-changelog. If this is not present, we fall back to the email envelope's From:.
Noted. I'll keep that in mind for my future patches.
Quoted 5 lines
Quoted 5 lines
mm/userfaultfd.c +0
-0@@ -2085,8 +2085,10 @@ static ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start, }
Quoted 10 lines
mm/userfaultfd.c static ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start, · line 2093
Quoted 8 lines
mm/userfaultfd.c +3
-1if (err) { -if (err == -EAGAIN ) +if (err == -EAGAIN ) { + err =0 ;continue ; + }break ; }I'll queue it, with an adjusted From:, as above.
Thank you!
Quoted 4 lines
Could reviewers please advise on whether we should backport this into -stable kernels?
Suren Baghdasaryan
Reviewed-byQuoted 11 lines · Andrew Morton
Quoted 8 lines · On Wed, 19 Aug 2026 10:08:24 +0700 (WIB) Foxie Flakey <[email protected]>…
During
move_pages()operation, whenmove_pages_ptes()returns EAGAIN, the error code is not cleared even after we processed it. This leads to a successful retry but then the same pages are retried again due to the stale error code. This time move fails because pages are already moved, loop is terminated andmove_pages()reports a failure. Clear the error code once we processes EAGAIN.
Quoted 3 lines
Quoted 3 lines
Fixes 50944692052b ("userfaultfd: opportunistic TLB-flush batching for present pages in MOVE")Assisted-by ChatGPT:GPT-5.6-LunaSigned-off-by Bryan Lim <[email protected]>
Quoted 23 lines
Thanks, Bryan.
More paperwork: the signoff is supposed to match the Author:. The way to do this is to add an explicit From: line at start-of-changelog. If this is not present, we fall back to the email envelope's From:.
mm/userfaultfd.c static ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start, · line 2093
Quoted 13 lines
mm/userfaultfd.c +3
-1@@ -2085,8 +2085,10 @@ static ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start, }if (err) { -if (err == -EAGAIN ) +if (err == -EAGAIN ) { + err =0 ;continue ; + }break ; }I'll queue it, with an adjusted From:, as above.
Quoted 2 lines
Could reviewers please advise on whether we should backport this into -stable kernels?
Yes please. The first version where the bug appears is 6.18. Thanks!
Quoted 2 lines
Hi Foxie,
Quoted 11 lines · Foxie Flakey
During
move_pages()operation, whenmove_pages_ptes()returns EAGAIN, the error code is not cleared even after we processed it. This leads to a successful retry but then the same pages are retried again due to the stale error code. This time move fails because pages are already moved, loop is terminated andmove_pages()reports a failure. Clear the error code once we processes EAGAIN.Fixes 50944692052b ("userfaultfd: opportunistic TLB-flush batching for present pages in MOVE")Assisted-by ChatGPT:GPT-5.6-LunaSigned-off-by Bryan Lim <[email protected]>
With the authorship changes that Andrew requested
Quoted 36 lines
---
Changes in v3:
- Updated to use proper sign off.Changes in v2:
- Updated on description to be easier to understood
- Reset err before retrying, instead of fixing right at themove_pages_ptesbranch.
- Added Assisted-by, received an answer few days ago from linux-newbies IRC that even I just used AI/LLM as "fast path" of git bisect. I still need to add it following
https://docs.kernel.org/process/coding-assistants.html doc.--- mm/userfaultfd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)mm/userfaultfd.c +3
-1@@ -2085,8 +2085,10 @@ static ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start, }if (err) { -if (err == -EAGAIN ) +if (err == -EAGAIN ) { + err =0 ;continue ; + }break ; }Signature · 1 line
2.55.0
Signature · 2 lines
Sincerely yours, Mike.