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: convert params to pointer in ring reisze

The parameters in io_register_resize_rings() will be moved into another
structure in a later patch. In preparation to that, convert the params
variable it to a pointer, but still store the data on stack.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Pavel Begunkov and committed by
Jens Axboe
929dbbb6 94cd8329

+24 -24
+24 -24
io_uring/register.c
··· 402 402 struct io_ring_ctx_rings o = { }, n = { }, *to_free = NULL; 403 403 size_t size, sq_array_offset; 404 404 unsigned i, tail, old_head; 405 - struct io_uring_params p; 405 + struct io_uring_params __p, *p = &__p; 406 406 int ret; 407 407 408 408 /* limited to DEFER_TASKRUN for now */ 409 409 if (!(ctx->flags & IORING_SETUP_DEFER_TASKRUN)) 410 410 return -EINVAL; 411 - if (copy_from_user(&p, arg, sizeof(p))) 411 + if (copy_from_user(p, arg, sizeof(*p))) 412 412 return -EFAULT; 413 - if (p.flags & ~RESIZE_FLAGS) 413 + if (p->flags & ~RESIZE_FLAGS) 414 414 return -EINVAL; 415 415 416 416 /* properties that are always inherited */ 417 - p.flags |= (ctx->flags & COPY_FLAGS); 417 + p->flags |= (ctx->flags & COPY_FLAGS); 418 418 419 - ret = io_uring_fill_params(&p); 419 + ret = io_uring_fill_params(p); 420 420 if (unlikely(ret)) 421 421 return ret; 422 422 423 - size = rings_size(p.flags, p.sq_entries, p.cq_entries, 423 + size = rings_size(p->flags, p->sq_entries, p->cq_entries, 424 424 &sq_array_offset); 425 425 if (size == SIZE_MAX) 426 426 return -EOVERFLOW; 427 427 428 428 memset(&rd, 0, sizeof(rd)); 429 429 rd.size = PAGE_ALIGN(size); 430 - if (p.flags & IORING_SETUP_NO_MMAP) { 431 - rd.user_addr = p.cq_off.user_addr; 430 + if (p->flags & IORING_SETUP_NO_MMAP) { 431 + rd.user_addr = p->cq_off.user_addr; 432 432 rd.flags |= IORING_MEM_REGION_TYPE_USER; 433 433 } 434 434 ret = io_create_region(ctx, &n.ring_region, &rd, IORING_OFF_CQ_RING); ··· 445 445 * intent... Use read/write once helpers from here on to indicate the 446 446 * shared nature of it. 447 447 */ 448 - WRITE_ONCE(n.rings->sq_ring_mask, p.sq_entries - 1); 449 - WRITE_ONCE(n.rings->cq_ring_mask, p.cq_entries - 1); 450 - WRITE_ONCE(n.rings->sq_ring_entries, p.sq_entries); 451 - WRITE_ONCE(n.rings->cq_ring_entries, p.cq_entries); 448 + WRITE_ONCE(n.rings->sq_ring_mask, p->sq_entries - 1); 449 + WRITE_ONCE(n.rings->cq_ring_mask, p->cq_entries - 1); 450 + WRITE_ONCE(n.rings->sq_ring_entries, p->sq_entries); 451 + WRITE_ONCE(n.rings->cq_ring_entries, p->cq_entries); 452 452 453 - if (copy_to_user(arg, &p, sizeof(p))) { 453 + if (copy_to_user(arg, p, sizeof(*p))) { 454 454 io_register_free_rings(ctx, &n); 455 455 return -EFAULT; 456 456 } 457 457 458 - if (p.flags & IORING_SETUP_SQE128) 459 - size = array_size(2 * sizeof(struct io_uring_sqe), p.sq_entries); 458 + if (p->flags & IORING_SETUP_SQE128) 459 + size = array_size(2 * sizeof(struct io_uring_sqe), p->sq_entries); 460 460 else 461 - size = array_size(sizeof(struct io_uring_sqe), p.sq_entries); 461 + size = array_size(sizeof(struct io_uring_sqe), p->sq_entries); 462 462 if (size == SIZE_MAX) { 463 463 io_register_free_rings(ctx, &n); 464 464 return -EOVERFLOW; ··· 466 466 467 467 memset(&rd, 0, sizeof(rd)); 468 468 rd.size = PAGE_ALIGN(size); 469 - if (p.flags & IORING_SETUP_NO_MMAP) { 470 - rd.user_addr = p.sq_off.user_addr; 469 + if (p->flags & IORING_SETUP_NO_MMAP) { 470 + rd.user_addr = p->sq_off.user_addr; 471 471 rd.flags |= IORING_MEM_REGION_TYPE_USER; 472 472 } 473 473 ret = io_create_region(ctx, &n.sq_region, &rd, IORING_OFF_SQES); ··· 508 508 */ 509 509 tail = READ_ONCE(o.rings->sq.tail); 510 510 old_head = READ_ONCE(o.rings->sq.head); 511 - if (tail - old_head > p.sq_entries) 511 + if (tail - old_head > p->sq_entries) 512 512 goto overflow; 513 513 for (i = old_head; i < tail; i++) { 514 514 unsigned src_head = i & (ctx->sq_entries - 1); 515 - unsigned dst_head = i & (p.sq_entries - 1); 515 + unsigned dst_head = i & (p->sq_entries - 1); 516 516 517 517 n.sq_sqes[dst_head] = o.sq_sqes[src_head]; 518 518 } ··· 521 521 522 522 tail = READ_ONCE(o.rings->cq.tail); 523 523 old_head = READ_ONCE(o.rings->cq.head); 524 - if (tail - old_head > p.cq_entries) { 524 + if (tail - old_head > p->cq_entries) { 525 525 overflow: 526 526 /* restore old rings, and return -EOVERFLOW via cleanup path */ 527 527 ctx->rings = o.rings; ··· 532 532 } 533 533 for (i = old_head; i < tail; i++) { 534 534 unsigned src_head = i & (ctx->cq_entries - 1); 535 - unsigned dst_head = i & (p.cq_entries - 1); 535 + unsigned dst_head = i & (p->cq_entries - 1); 536 536 537 537 n.rings->cqes[dst_head] = o.rings->cqes[src_head]; 538 538 } ··· 550 550 if (!(ctx->flags & IORING_SETUP_NO_SQARRAY)) 551 551 ctx->sq_array = (u32 *)((char *)n.rings + sq_array_offset); 552 552 553 - ctx->sq_entries = p.sq_entries; 554 - ctx->cq_entries = p.cq_entries; 553 + ctx->sq_entries = p->sq_entries; 554 + ctx->cq_entries = p->cq_entries; 555 555 556 556 ctx->rings = n.rings; 557 557 ctx->sq_sqes = n.sq_sqes;