public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io-wq: simplify code in __io_worker_busy
@ 2021-04-02 10:18 Hao Xu
  2021-04-02 10:38 ` Pavel Begunkov
  0 siblings, 1 reply; 10+ messages in thread
From: Hao Xu @ 2021-04-02 10:18 UTC (permalink / raw)
  To: Jens Axboe; +Cc: io-uring, Pavel Begunkov, Joseph Qi

leverage xor to simplify code in __io_worker_busy

Signed-off-by: Hao Xu <[email protected]>
---
 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);
 	 }
 }
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-04-07 18:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-02 10:18 [PATCH] io-wq: simplify code in __io_worker_busy Hao Xu
2021-04-02 10:38 ` Pavel Begunkov
2021-04-04 19:17   ` Jens Axboe
2021-04-05  7:53     ` [PATCH v3] " Hao Xu
2021-04-05 21:46       ` Jens Axboe
2021-04-06  2:18         ` Hao Xu
2021-04-06  3:08         ` [PATCH v4] " Hao Xu
2021-04-06 15:36           ` Jens Axboe
2021-04-07 18:28           ` Pavel Begunkov
2021-04-05  7:36   ` [PATCH v2] " Hao Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox