diff mbox

[2/3] irq-poll: micro optimize some branch predictions

Message ID 1478991755-28153-3-git-send-email-sagi@grimberg.me (mailing list archive)
State New, archived
Headers show

Commit Message

Sagi Grimberg Nov. 12, 2016, 11:02 p.m. UTC
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
 lib/irq_poll.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Christoph Hellwig Nov. 13, 2016, 3:13 p.m. UTC | #1
Are they really that unlikely?  I don't like these annotations unless
it's clearly an error path or they have a high, demonstrable benefit.
--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sagi Grimberg Nov. 14, 2016, 12:49 a.m. UTC | #2
> Are they really that unlikely?  I don't like these annotations unless
> it's clearly an error path or they have a high, demonstrable benefit.

IRQ_POLL_F_DISABLE is set when disabling the iop (in the end of the
world). IRQ_POLL_F_SCHED is set on irq_poll_sched() itself so this cond
would match only if the user called irq_poll_sched() twice which it
shouldn't ever do.

So yes, I think these are really unlikely()

But now I noticed that I typo'ed the IRQ_POLL_F_SCHED from
unlikely to likely :(

need to fix that...
--
To unsubscribe from this list: send the line "unsubscribe linux-block" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/irq_poll.c b/lib/irq_poll.c
index 22d033e6ded2..44a5d1da4260 100644
--- a/lib/irq_poll.c
+++ b/lib/irq_poll.c
@@ -26,9 +26,9 @@  void irq_poll_sched(struct irq_poll *iop)
 {
 	unsigned long flags;
 
-	if (test_bit(IRQ_POLL_F_DISABLE, &iop->state))
+	if (unlikely(test_bit(IRQ_POLL_F_DISABLE, &iop->state)))
 		return;
-	if (test_and_set_bit(IRQ_POLL_F_SCHED, &iop->state))
+	if (likely(test_and_set_bit(IRQ_POLL_F_SCHED, &iop->state)))
 		return;
 
 	local_irq_save(flags);
@@ -120,7 +120,7 @@  static void __latent_entropy irq_poll_softirq(struct softirq_action *h)
 		 * move the instance around on the list at-will.
 		 */
 		if (work >= weight) {
-			if (test_bit(IRQ_POLL_F_DISABLE, &iop->state))
+			if (unlikely(test_bit(IRQ_POLL_F_DISABLE, &iop->state)))
 				__irq_poll_complete(iop);
 			else
 				list_move_tail(&iop->list, list);