[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1619683852-2247-1-git-send-email-zhouchuangao@vivo.com>
Date: Thu, 29 Apr 2021 01:10:52 -0700
From: zhouchuangao <zhouchuangao@...o.com>
To: David Howells <dhowells@...hat.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
linux-afs@...ts.infradead.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: zhouchuangao <zhouchuangao@...o.com>
Subject: [PATCH] net/rxrpc: Use BUG_ON instead of if condition followed by BUG.
BUG_ON() uses unlikely in if(), which can be optimized at compile time.
do { if (unlikely(condition)) BUG(); } while (0)
Through disassembly, we can see that brk #0x800 is compiled to the
end of the function.
As you can see below:
......
ffffff8008660bec: d65f03c0 ret
ffffff8008660bf0: d4210000 brk #0x800
Usually, the condition in if () is not satisfied. For the multi-stage
pipeline, we do not need to perform fetch decode and excute operation
on brk instruction.
IMO, this can improve the efficiency of the multi-stage pipeline.
Signed-off-by: zhouchuangao <zhouchuangao@...o.com>
---
net/rxrpc/call_object.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/rxrpc/call_object.c b/net/rxrpc/call_object.c
index 4eb91d95..e5deb6f 100644
--- a/net/rxrpc/call_object.c
+++ b/net/rxrpc/call_object.c
@@ -505,8 +505,7 @@ void rxrpc_release_call(struct rxrpc_sock *rx, struct rxrpc_call *call)
ASSERTCMP(call->state, ==, RXRPC_CALL_COMPLETE);
spin_lock_bh(&call->lock);
- if (test_and_set_bit(RXRPC_CALL_RELEASED, &call->flags))
- BUG();
+ BUG_ON(test_and_set_bit(RXRPC_CALL_RELEASED, &call->flags));
spin_unlock_bh(&call->lock);
rxrpc_put_call_slot(call);
@@ -636,8 +635,7 @@ static void rxrpc_rcu_destroy_call(struct rcu_head *rcu)
if (in_softirq()) {
INIT_WORK(&call->processor, rxrpc_destroy_call);
- if (!rxrpc_queue_work(&call->processor))
- BUG();
+ BUG_ON(!rxrpc_queue_work(&call->processor));
} else {
rxrpc_destroy_call(&call->processor);
}
--
2.7.4
Powered by blists - more mailing lists