[PATCH] fs/io_uring.c: remove unnecessary boolean instructions that add uops

From: noah
Date: Sat Jan 02 2021 - 16:05:56 EST


This patch drops unnecessary comparisons to turn return values into
booleans. There is no reason to do a != for cancelled and posted as
they can be set to a boolean directly more efficiently.

Signed-off-by: noah <goldstein.w.n@xxxxxxxxx>
---
fs/io_uring.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index ca46f314640b..6a46594e749a 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1607,11 +1607,11 @@ static bool io_kill_timeouts(struct io_ring_ctx *ctx, struct task_struct *tsk,
list_for_each_entry_safe(req, tmp, &ctx->timeout_list, timeout.list) {
if (io_match_task(req, tsk, files)) {
io_kill_timeout(req);
- canceled++;
+ canceled = 1;
}
}
spin_unlock_irq(&ctx->completion_lock);
- return canceled != 0;
+ return canceled;
}

static void __io_queue_deferred(struct io_ring_ctx *ctx)
@@ -5491,7 +5491,7 @@ static bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk,
list = &ctx->cancel_hash[i];
hlist_for_each_entry_safe(req, tmp, list, hash_node) {
if (io_match_task(req, tsk, files))
- posted += io_poll_remove_one(req);
+ posted |= io_poll_remove_one(req);
}
}
spin_unlock_irq(&ctx->completion_lock);
@@ -5499,7 +5499,7 @@ static bool io_poll_remove_all(struct io_ring_ctx *ctx, struct task_struct *tsk,
if (posted)
io_cqring_ev_posted(ctx);

- return posted != 0;
+ return posted;
}

static int io_poll_cancel(struct io_ring_ctx *ctx, __u64 sqe_addr)
--
2.29.2