Message ID | 3d6a3659fcb7d777530b5cc67aac3e036a212dda.1655213915.git.asml.silence@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | 5.20 cleanups and poll optimisations | expand |
On 6/14/22 22:37, Pavel Begunkov wrote: > Add a variable for the number of hash buckets in io_ring_ctx_alloc(), > makes it more readable. > > Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> > --- > io_uring/io_uring.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c > index 2a7a5db12a0e..15d209f334eb 100644 > --- a/io_uring/io_uring.c > +++ b/io_uring/io_uring.c > @@ -700,6 +700,8 @@ static __cold void io_fallback_req_func(struct work_struct *work) > static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p) > { > struct io_ring_ctx *ctx; > + unsigned hash_buckets; personally prefer nr_something like nr_buckets or nr_hash_buckets
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 2a7a5db12a0e..15d209f334eb 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -700,6 +700,8 @@ static __cold void io_fallback_req_func(struct work_struct *work) static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p) { struct io_ring_ctx *ctx; + unsigned hash_buckets; + size_t hash_size; int hash_bits; ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); @@ -715,15 +717,15 @@ static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p) */ hash_bits = ilog2(p->cq_entries) - 5; hash_bits = clamp(hash_bits, 1, 8); + hash_buckets = 1U << hash_bits; + hash_size = hash_buckets * sizeof(struct io_hash_bucket); ctx->cancel_hash_bits = hash_bits; - ctx->cancel_hash = - kmalloc((1U << hash_bits) * sizeof(struct io_hash_bucket), - GFP_KERNEL); + ctx->cancel_hash = kmalloc(hash_size, GFP_KERNEL); if (!ctx->cancel_hash) goto err; - init_hash_table(ctx->cancel_hash, 1U << hash_bits); + init_hash_table(ctx->cancel_hash, hash_buckets); ctx->dummy_ubuf = kzalloc(sizeof(*ctx->dummy_ubuf), GFP_KERNEL); if (!ctx->dummy_ubuf)
Add a variable for the number of hash buckets in io_ring_ctx_alloc(), makes it more readable. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> --- io_uring/io_uring.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)