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. > > Signed-off-by: Hao Xu <haoxu@xxxxxxxxxxxxxxxxx> > --- > fs/io-wq.c | 13 ++++--------- > 1 file changed, 4 insertions(+), 9 deletions(-) > > diff --git a/fs/io-wq.c b/fs/io-wq.c > index 7434eb40ca8c..f77e4704d7c7 100644 > --- a/fs/io-wq.c > +++ b/fs/io-wq.c > @@ -292,16 +292,11 @@ static void __io_worker_busy(struct io_wqe *wqe, struct io_worker *worker, > worker_bound = (worker->flags & IO_WORKER_F_BOUND) != 0; > work_bound = (work->flags & IO_WQ_WORK_UNBOUND) == 0; > if (worker_bound != work_bound) { > + int index = work_bound ? IO_WQ_ACCT_UNBOUND : IO_WQ_ACCT_BOUND; > io_wqe_dec_running(worker); > - if (work_bound) { > - worker->flags |= IO_WORKER_F_BOUND; > - wqe->acct[IO_WQ_ACCT_UNBOUND].nr_workers--; > - wqe->acct[IO_WQ_ACCT_BOUND].nr_workers++; > - } else { > - worker->flags &= ~IO_WORKER_F_BOUND; > - wqe->acct[IO_WQ_ACCT_UNBOUND].nr_workers++; > - wqe->acct[IO_WQ_ACCT_BOUND].nr_workers--; > - } > + worker->flags ^= IO_WORKER_F_BOUND; > + wqe->acct[index].nr_workers--; > + wqe->acct[index^1].nr_workers++; > io_wqe_inc_running(worker); > } > } > -- Pavel Begunkov