File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,8 @@ static __cold void io_fallback_req_func(struct work_struct *work)
244
244
static __cold struct io_ring_ctx * io_ring_ctx_alloc (struct io_uring_params * p )
245
245
{
246
246
struct io_ring_ctx * ctx ;
247
+ unsigned hash_buckets ;
248
+ size_t hash_size ;
247
249
int hash_bits ;
248
250
249
251
ctx = kzalloc (sizeof (* ctx ), GFP_KERNEL );
@@ -259,15 +261,15 @@ static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p)
259
261
*/
260
262
hash_bits = ilog2 (p -> cq_entries ) - 5 ;
261
263
hash_bits = clamp (hash_bits , 1 , 8 );
264
+ hash_buckets = 1U << hash_bits ;
265
+ hash_size = hash_buckets * sizeof (struct io_hash_bucket );
262
266
263
267
ctx -> cancel_hash_bits = hash_bits ;
264
- ctx -> cancel_hash =
265
- kmalloc ((1U << hash_bits ) * sizeof (struct io_hash_bucket ),
266
- GFP_KERNEL );
268
+ ctx -> cancel_hash = kmalloc (hash_size , GFP_KERNEL );
267
269
if (!ctx -> cancel_hash )
268
270
goto err ;
269
271
270
- init_hash_table (ctx -> cancel_hash , 1U << hash_bits );
272
+ init_hash_table (ctx -> cancel_hash , hash_buckets );
271
273
272
274
ctx -> dummy_ubuf = kzalloc (sizeof (* ctx -> dummy_ubuf ), GFP_KERNEL );
273
275
if (!ctx -> dummy_ubuf )
You can’t perform that action at this time.
0 commit comments