From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755771AbdJIXRL (ORCPT ); Mon, 9 Oct 2017 19:17:11 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:59026 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754418AbdJIXRJ (ORCPT ); Mon, 9 Oct 2017 19:17:09 -0400 Date: Mon, 09 Oct 2017 16:17:08 -0700 (PDT) Message-Id: <20171009.161708.963726434970115075.davem@davemloft.net> To: alexei.starovoitov@gmail.com Cc: alexander.levin@verizon.com, devtimhansen@gmail.com, 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 Subject: Re: [PATCH v2] net/core: Fix BUG to BUG_ON conditionals. From: David Miller In-Reply-To: <20171009230618.e5gla2iuqwmndkig@ast-mbp> References: <20171009171540.lgmk2slq3bdrptxk@ast-mbp.dhcp.thefacebook.com> <20171009202633.ep5pbi2tlg7dqidz@sasha-lappy> <20171009230618.e5gla2iuqwmndkig@ast-mbp> X-Mailer: Mew version 6.7 on Emacs 25.3 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 09 Oct 2017 16:17:09 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexei Starovoitov Date: Mon, 9 Oct 2017 16:06:20 -0700 >> 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? It can completely eliminate a branch. For example on powerpc if you use BUG() then the code generated is: test condition branch_not_true 1f unconditional_trap 1: Whereas with BUG_ON() it's just: test condition trap_if_true Which is a lot better even when the branches in the first case are well predicted.