Re: [PATCH 2/2] io_uring: defer alloc_hint update to io_file_bitmap_set()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/27/22 10:53 AM, Xiaoguang Wang wrote:
> @@ -9650,12 +9646,15 @@ static void io_free_file_tables(struct io_file_table *table)
>  	table->bitmap = NULL;
>  }
>  
> -static inline void io_file_bitmap_set(struct io_file_table *table, int bit)
> +static inline void io_file_bitmap_set(struct io_ring_ctx *ctx, int bit)
>  {
> +	struct io_file_table *table = &ctx->file_table;
> +
>  	WARN_ON_ONCE(test_bit(bit, table->bitmap));
>  	__set_bit(bit, table->bitmap);
> -	if (bit == table->alloc_hint)
> -		table->alloc_hint++;
> +	table->alloc_hint = bit + 1;
> +	if (table->alloc_hint >= ctx->nr_user_files)
> +		table->alloc_hint = 0;
>  }

This branch isn't needed, we'll reset it when failing to get one anyway.
Much better than adding a branch to the fast path.

-- 
Jens Axboe




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux