netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'zhouchuangao' <zhouchuangao@vivo.com>,
	David Howells <dhowells@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"linux-afs@lists.infradead.org" <linux-afs@lists.infradead.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] net/rxrpc: Use BUG_ON instead of if condition followed by BUG.
Date: Thu, 29 Apr 2021 08:48:18 +0000	[thread overview]
Message-ID: <e7c1b060f1594d21bab96e68c4b53bb3@AcuMS.aculab.com> (raw)
In-Reply-To: <1619683852-2247-1-git-send-email-zhouchuangao@vivo.com>

From: zhouchuangao
> Sent: 29 April 2021 09:11
> 
> BUG_ON() uses unlikely in if(), which can be optimized at compile time.
> 
>               do { if (unlikely(condition)) BUG(); } while (0)
...
> 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));

Hiding as assignment inside BUG_ON() isn't nice.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)


      reply	other threads:[~2021-04-29  8:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-29  8:10 [PATCH] net/rxrpc: Use BUG_ON instead of if condition followed by BUG zhouchuangao
2021-04-29  8:48 ` David Laight [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e7c1b060f1594d21bab96e68c4b53bb3@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=kuba@kernel.org \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=zhouchuangao@vivo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).