userfaultfd: reset err when move_pages_ptes succeeded
Subsystems (2)
PATCH 1/1 userfaultfd: reset err when move_pages_ptes succeeded
There is an edge case when move_pages_ptes fails with EAGAIN and then outer loop attempt to retry and succeeded but "err" isn't reset. This leads to outer loop retry erroneously on same set of pages that was successfully moved. This is fixed by resetting "err" when move_pages_ptes succeeded.
--- mm/userfaultfd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
mm/userfaultfd.c +4 -2
@@ -2069,10 +2069,12 @@ static ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start, ret =move_pages_ptes (mm, dst_pmd, src_pmd, dst_vma, src_vma, dst_addr, src_addr, src_end - src_addr, mode); -if (ret <0 ) +if (ret <0 ) { err = ret; -else + }else { + err =0 ; step_size = ret; + } }cond_resched ();
base-commit: 62cc90241548d5570ee68e01aaba6506964e9811
Signature · 1 line
2.55.0
Quoted 33 lines · Foxie Flakey
There is an edge case when
move_pages_ptesfails with EAGAIN and then outer loop attempt to retry and succeeded but "err" isn't reset. This leads to outer loop retry erroneously on same set of pages that was successfully moved. This is fixed by resetting "err" whenmove_pages_ptessucceeded.Fixes 50944692052b ("userfaultfd: opportunistic TLB-flush batching for present pages in MOVE")Signed-off-by Foxie Flakey <[email protected]>Assisted-by ChatGPT:GPT-5.6-Luna--- mm/userfaultfd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)mm/userfaultfd.c +4
-2@@ -2069,10 +2069,12 @@ static ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start, ret =move_pages_ptes (mm, dst_pmd, src_pmd, dst_vma, src_vma, dst_addr, src_addr, src_end - src_addr, mode); -if (ret <0 ) +if (ret <0 ) { err = ret; -else + }else { + err =0 ; step_size = ret; + } }cond_resched ();
Quoted 5 lines
base-commit:
62cc90241548d5570ee68e01aaba6506964e9811Signature · 1 line
2.55.0
Hi,
Use ./scripts/get_maintainer.pl <file> to figure out to which mailing list you should send your patches. Also don't forget to CC the subsytem and the file maintainer. I don't think this is the correct mailing list for your patch :)
Cheers,
Ali
Quoted 6 lines · Ali Nasrolahi
Hi,
Use
./scripts/get_maintainer.pl <file>to figure out to which mailing list you should send your patches. Also don't forget to CC the subsytem and the file maintainer. I don't think this is the correct mailing list for your patch :)
Thanks! I already sent it previously but there was few issues pointed by someone on IRC and I was sending here so they can check.
Quoted 3 lines
Cheers,
Ali