From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Levin, Alexander (Sasha Levin)" Subject: Re: [PATCH v2] net/core: Fix BUG to BUG_ON conditionals. Date: Mon, 9 Oct 2017 23:15:40 +0000 Message-ID: <20171009231538.doypjzvxzkoxyoeo@sasha-lappy> References: <20171009153759.km3lqss7hb72wrze@debian> <20171009171540.lgmk2slq3bdrptxk@ast-mbp.dhcp.thefacebook.com> <20171009202633.ep5pbi2tlg7dqidz@sasha-lappy> <20171009230618.e5gla2iuqwmndkig@ast-mbp> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Cc: Tim Hansen , "davem@davemloft.net" , "willemb@google.com" , "edumazet@google.com" , "soheil@google.com" , "pabeni@redhat.com" , "elena.reshetova@intel.com" , "tom@quantonium.net" , "Jason@zx2c4.com" , "fw@strlen.de" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" To: Alexei Starovoitov Return-path: In-Reply-To: <20171009230618.e5gla2iuqwmndkig@ast-mbp> Content-Language: en-US Content-ID: <2A7827635E91A54BBC4CC977AF305344@vzwcorp.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org On Mon, Oct 09, 2017 at 04:06:20PM -0700, Alexei Starovoitov wrote: >On Mon, Oct 09, 2017 at 08:26:34PM +0000, Levin, Alexander (Sasha Levin) w= rote: >> On Mon, Oct 09, 2017 at 10:15:42AM -0700, Alexei Starovoitov wrote: >> >On Mon, Oct 09, 2017 at 11:37:59AM -0400, Tim Hansen wrote: >> >> Fix BUG() calls to use BUG_ON(conditional) macros. >> >> >> >> This was found using make coccicheck M=3Dnet/core on linux next >> >> tag next-2017092 >> >> >> >> Signed-off-by: Tim Hansen >> >> --- >> >> net/core/skbuff.c | 15 ++++++--------- >> >> 1 file changed, 6 insertions(+), 9 deletions(-) >> >> >> >> diff --git a/net/core/skbuff.c b/net/core/skbuff.c >> >> index d98c2e3ce2bf..34ce4c1a0f3c 100644 >> >> --- a/net/core/skbuff.c >> >> +++ b/net/core/skbuff.c >> >> @@ -1350,8 +1350,7 @@ struct sk_buff *skb_copy(const struct sk_buff *= skb, gfp_t gfp_mask) >> >> /* Set the tail pointer and length */ >> >> skb_put(n, skb->len); >> >> >> >> - if (skb_copy_bits(skb, -headerlen, n->head, headerlen + skb->len)) >> >> - BUG(); >> >> + BUG_ON(skb_copy_bits(skb, -headerlen, n->head, headerlen + skb->len= )); >> > >> >I'm concerned with this change. >> >1. Calling non-trivial bit of code inside the macro is a poor coding st= yle (imo) >> >2. BUG_ON !=3D BUG. Some archs like mips and ppc have HAVE_ARCH_BUG_ON = and implementation >> >of BUG and BUG_ON look quite different. >> >> For these archs, wouldn't it then be more efficient to use BUG_ON rather= than BUG()? > >why more efficient? any data to prove that? Just guessing. Either way, is there a particular reason for not using BUG_ON() here besides that it's implementation is "quite different"? >I'm pointing that the change is not equivalent and >this code has been around forever (pre-git days), so I see >no reason to risk changing it. Do you know that BUG_ON() is broken on any archs? If not, "this code has been around forever" is really not an excuse to not touch code. If BUG_ON() behavior is broken somewhere, then it needs to get fixed. --=20 Thanks, Sasha=