From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E90BC433ED for ; Thu, 29 Apr 2021 08:16:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0BB996143F for ; Thu, 29 Apr 2021 08:16:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239783AbhD2IRA (ORCPT ); Thu, 29 Apr 2021 04:17:00 -0400 Received: from mail-m17640.qiye.163.com ([59.111.176.40]:34682 "EHLO mail-m17640.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232455AbhD2IQ5 (ORCPT ); Thu, 29 Apr 2021 04:16:57 -0400 X-Greylist: delayed 308 seconds by postgrey-1.27 at vger.kernel.org; Thu, 29 Apr 2021 04:16:56 EDT Received: from ubuntu.localdomain (unknown [36.152.145.182]) by mail-m17640.qiye.163.com (Hmail) with ESMTPA id 5512A5403B8; Thu, 29 Apr 2021 16:10:58 +0800 (CST) From: zhouchuangao To: David Howells , "David S. Miller" , Jakub Kicinski , linux-afs@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: zhouchuangao Subject: [PATCH] net/rxrpc: Use BUG_ON instead of if condition followed by BUG. Date: Thu, 29 Apr 2021 01:10:52 -0700 Message-Id: <1619683852-2247-1-git-send-email-zhouchuangao@vivo.com> X-Mailer: git-send-email 2.7.4 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZGk4fHVYYTBpJGh9IHUxOSBpVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWUFZT0tIVUpKS0 hKTFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NT46Hio*Fz8XDkkjNg0DGC4s OC8KFEhVSlVKTUpCTUNIQ05DTE5DVTMWGhIXVQETFA4YEw4aFRwaFDsNEg0UVRgUFkVZV1kSC1lB WUhNVUpOSVVKT05VSkNJWVdZCAFZQUlOTE43Bg++ X-HM-Tid: 0a791cae5831d995kuws5512a5403b8 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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