Skip to content

Commit 776617d

Browse files
TobiasHollaxboe
authored andcommitted
io_uring/rsrc: check for nonconsecutive pages
Pages that are from the same folio do not necessarily need to be consecutive. In that case, we cannot consolidate them into a single bvec entry. Before applying the huge page optimization from commit 57bebf8 ("io_uring/rsrc: optimise registered huge pages"), check that the memory is actually consecutive. Cc: stable@vger.kernel.org Fixes: 57bebf8 ("io_uring/rsrc: optimise registered huge pages") Signed-off-by: Tobias Holl <tobias@tholl.xyz> [axboe: formatting] Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 3c85cc4 commit 776617d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

io_uring/rsrc.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,12 @@ static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov,
11171117
if (nr_pages > 1) {
11181118
folio = page_folio(pages[0]);
11191119
for (i = 1; i < nr_pages; i++) {
1120-
if (page_folio(pages[i]) != folio) {
1120+
/*
1121+
* Pages must be consecutive and on the same folio for
1122+
* this to work
1123+
*/
1124+
if (page_folio(pages[i]) != folio ||
1125+
pages[i] != pages[i - 1] + 1) {
11211126
folio = NULL;
11221127
break;
11231128
}

0 commit comments

Comments
 (0)