Skip to content

Commit cbcf721

Browse files
isilenceaxboe
authored andcommitted
io_uring: return locked and pinned page accounting
Locked and pinned memory accounting in io_{,un}account_mem() depends on having ->sqo_mm, which is NULL after a recent change for non SQPOLL'ed io_ring. That disables the accounting. Return ->sqo_mm initialisation back, and do __io_sq_thread_acquire_mm() based on IORING_SETUP_SQPOLL flag. Fixes: 8eb06d7 ("io_uring: fix missing ->mm on exit") Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 5dbcad5 commit cbcf721

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

fs/io_uring.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,8 @@ static void io_sq_thread_drop_mm(void)
981981
static int __io_sq_thread_acquire_mm(struct io_ring_ctx *ctx)
982982
{
983983
if (!current->mm) {
984-
if (unlikely(!ctx->sqo_mm || !mmget_not_zero(ctx->sqo_mm)))
984+
if (unlikely(!(ctx->flags & IORING_SETUP_SQPOLL) ||
985+
!mmget_not_zero(ctx->sqo_mm)))
985986
return -EFAULT;
986987
kthread_use_mm(ctx->sqo_mm);
987988
}
@@ -7259,10 +7260,10 @@ static int io_sq_offload_start(struct io_ring_ctx *ctx,
72597260
{
72607261
int ret;
72617262

7262-
if (ctx->flags & IORING_SETUP_SQPOLL) {
7263-
mmgrab(current->mm);
7264-
ctx->sqo_mm = current->mm;
7263+
mmgrab(current->mm);
7264+
ctx->sqo_mm = current->mm;
72657265

7266+
if (ctx->flags & IORING_SETUP_SQPOLL) {
72667267
ret = -EPERM;
72677268
if (!capable(CAP_SYS_ADMIN))
72687269
goto err;

0 commit comments

Comments
 (0)