Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/memmap: refactor io_free_region() to take user_struct param

Refactor io_free_region() to take user_struct directly, instead of
accessing it from the ring ctx.

Signed-off-by: David Wei <dw@davidwei.uk>
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

David Wei and committed by
Jens Axboe
1fa7a341 a5af56a9

+14 -14
+3 -3
io_uring/io_uring.c
··· 2751 2751 2752 2752 static void io_rings_free(struct io_ring_ctx *ctx) 2753 2753 { 2754 - io_free_region(ctx, &ctx->sq_region); 2755 - io_free_region(ctx, &ctx->ring_region); 2754 + io_free_region(ctx->user, &ctx->sq_region); 2755 + io_free_region(ctx->user, &ctx->ring_region); 2756 2756 ctx->rings = NULL; 2757 2757 ctx->sq_sqes = NULL; 2758 2758 } ··· 2837 2837 io_eventfd_unregister(ctx); 2838 2838 io_free_alloc_caches(ctx); 2839 2839 io_destroy_buffers(ctx); 2840 - io_free_region(ctx, &ctx->param_region); 2840 + io_free_region(ctx->user, &ctx->param_region); 2841 2841 mutex_unlock(&ctx->uring_lock); 2842 2842 if (ctx->sq_creds) 2843 2843 put_cred(ctx->sq_creds);
+2 -2
io_uring/kbuf.c
··· 417 417 static void io_put_bl(struct io_ring_ctx *ctx, struct io_buffer_list *bl) 418 418 { 419 419 if (bl->flags & IOBL_BUF_RING) 420 - io_free_region(ctx, &bl->region); 420 + io_free_region(ctx->user, &bl->region); 421 421 else 422 422 io_remove_buffers_legacy(ctx, bl, -1U); 423 423 ··· 661 661 io_buffer_add_list(ctx, bl, reg.bgid); 662 662 return 0; 663 663 fail: 664 - io_free_region(ctx, &bl->region); 664 + io_free_region(ctx->user, &bl->region); 665 665 kfree(bl); 666 666 return ret; 667 667 }
+4 -4
io_uring/memmap.c
··· 88 88 IO_REGION_F_SINGLE_REF = 4, 89 89 }; 90 90 91 - void io_free_region(struct io_ring_ctx *ctx, struct io_mapped_region *mr) 91 + void io_free_region(struct user_struct *user, struct io_mapped_region *mr) 92 92 { 93 93 if (mr->pages) { 94 94 long nr_refs = mr->nr_pages; ··· 105 105 } 106 106 if ((mr->flags & IO_REGION_F_VMAP) && mr->ptr) 107 107 vunmap(mr->ptr); 108 - if (mr->nr_pages && ctx->user) 109 - __io_unaccount_mem(ctx->user, mr->nr_pages); 108 + if (mr->nr_pages && user) 109 + __io_unaccount_mem(user, mr->nr_pages); 110 110 111 111 memset(mr, 0, sizeof(*mr)); 112 112 } ··· 226 226 goto out_free; 227 227 return 0; 228 228 out_free: 229 - io_free_region(ctx, mr); 229 + io_free_region(ctx->user, mr); 230 230 return ret; 231 231 } 232 232
+1 -1
io_uring/memmap.h
··· 16 16 unsigned long flags); 17 17 int io_uring_mmap(struct file *file, struct vm_area_struct *vma); 18 18 19 - void io_free_region(struct io_ring_ctx *ctx, struct io_mapped_region *mr); 19 + void io_free_region(struct user_struct *user, struct io_mapped_region *mr); 20 20 int io_create_region(struct io_ring_ctx *ctx, struct io_mapped_region *mr, 21 21 struct io_uring_region_desc *reg, 22 22 unsigned long mmap_offset);
+3 -3
io_uring/register.c
··· 381 381 static void io_register_free_rings(struct io_ring_ctx *ctx, 382 382 struct io_ring_ctx_rings *r) 383 383 { 384 - io_free_region(ctx, &r->sq_region); 385 - io_free_region(ctx, &r->ring_region); 384 + io_free_region(ctx->user, &r->sq_region); 385 + io_free_region(ctx->user, &r->ring_region); 386 386 } 387 387 388 388 #define swap_old(ctx, o, n, field) \ ··· 604 604 if (ret) 605 605 return ret; 606 606 if (copy_to_user(rd_uptr, &rd, sizeof(rd))) { 607 - io_free_region(ctx, &region); 607 + io_free_region(ctx->user, &region); 608 608 return -EFAULT; 609 609 } 610 610
+1 -1
io_uring/zcrx.c
··· 378 378 379 379 static void io_free_rbuf_ring(struct io_zcrx_ifq *ifq) 380 380 { 381 - io_free_region(ifq->ctx, &ifq->region); 381 + io_free_region(ifq->ctx->user, &ifq->region); 382 382 ifq->rq_ring = NULL; 383 383 ifq->rqes = NULL; 384 384 }