File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -254,12 +254,12 @@ static __cold struct io_ring_ctx *io_ring_ctx_alloc(struct io_uring_params *p)
254254
255255 /*
256256 * Use 5 bits less than the max cq entries, that should give us around
257- * 32 entries per hash list if totally full and uniformly spread.
257+ * 32 entries per hash list if totally full and uniformly spread, but
258+ * don't keep too many buckets to not overconsume memory.
258259 */
259- hash_bits = ilog2 (p -> cq_entries );
260- hash_bits -= 5 ;
261- if (hash_bits <= 0 )
262- hash_bits = 1 ;
260+ hash_bits = ilog2 (p -> cq_entries ) - 5 ;
261+ hash_bits = clamp (hash_bits , 1 , 8 );
262+
263263 ctx -> cancel_hash_bits = hash_bits ;
264264 ctx -> cancel_hash =
265265 kmalloc ((1U << hash_bits ) * sizeof (struct io_hash_bucket ),
You can’t perform that action at this time.
0 commit comments