Re: [PATCH] io-wq: simplify code in __io_worker_busy

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

 



On 4/2/21 4:38 AM, Pavel Begunkov wrote:
> On 02/04/2021 11:18, Hao Xu wrote:
>> leverage xor to simplify code in __io_worker_busy
> 
> I don't like hard-coded ^1 because if indexes change it may break.
> One option is to leave it to the compiler:
> 
> idx = bound : WQ_BOUND ? WQ_UNBOUND;
> compl_idx = bound : WQ_UNBOUND ? WQ_BOUND;
> 
> Or add a BUILD_BUG_ON() checking that WQ_BOUND and WQ_UNBOUND
> are mod 2 complementary.

Was going to suggest just that, just add a BUILD_BUG_ON() to catch
any changes there. The code is way cleaner with the XOR trick.

Hao, can you resend with that?

-- 
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