Commit baf9cb64 authored by Stefan Roesch's avatar Stefan Roesch Committed by Jens Axboe

io_uring: change ring size calculation for CQE32

This changes the function rings_size to take large CQE's into account.
Co-developed-by: default avatarJens Axboe <axboe@kernel.dk>
Signed-off-by: default avatarStefan Roesch <shr@fb.com>
Reviewed-by: default avatarKanchan Joshi <joshi.k@samsung.com>
Link: https://lore.kernel.org/r/20220426182134.136504-4-shr@fb.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 4e5bc0a9
...@@ -9994,8 +9994,8 @@ static void *io_mem_alloc(size_t size) ...@@ -9994,8 +9994,8 @@ static void *io_mem_alloc(size_t size)
return (void *) __get_free_pages(gfp, get_order(size)); return (void *) __get_free_pages(gfp, get_order(size));
} }
static unsigned long rings_size(unsigned sq_entries, unsigned cq_entries, static unsigned long rings_size(struct io_ring_ctx *ctx, unsigned int sq_entries,
size_t *sq_offset) unsigned int cq_entries, size_t *sq_offset)
{ {
struct io_rings *rings; struct io_rings *rings;
size_t off, sq_array_size; size_t off, sq_array_size;
...@@ -10003,6 +10003,10 @@ static unsigned long rings_size(unsigned sq_entries, unsigned cq_entries, ...@@ -10003,6 +10003,10 @@ static unsigned long rings_size(unsigned sq_entries, unsigned cq_entries,
off = struct_size(rings, cqes, cq_entries); off = struct_size(rings, cqes, cq_entries);
if (off == SIZE_MAX) if (off == SIZE_MAX)
return SIZE_MAX; return SIZE_MAX;
if (ctx->flags & IORING_SETUP_CQE32) {
if (check_shl_overflow(off, 1, &off))
return SIZE_MAX;
}
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
off = ALIGN(off, SMP_CACHE_BYTES); off = ALIGN(off, SMP_CACHE_BYTES);
...@@ -11684,7 +11688,7 @@ static __cold int io_allocate_scq_urings(struct io_ring_ctx *ctx, ...@@ -11684,7 +11688,7 @@ static __cold int io_allocate_scq_urings(struct io_ring_ctx *ctx,
ctx->sq_entries = p->sq_entries; ctx->sq_entries = p->sq_entries;
ctx->cq_entries = p->cq_entries; ctx->cq_entries = p->cq_entries;
size = rings_size(p->sq_entries, p->cq_entries, &sq_array_offset); size = rings_size(ctx, p->sq_entries, p->cq_entries, &sq_array_offset);
if (size == SIZE_MAX) if (size == SIZE_MAX)
return -EOVERFLOW; return -EOVERFLOW;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment