lkml.org 
[lkml]   [2017]   [Oct]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2] net/core: Fix BUG to BUG_ON conditionals.
From
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
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.

\
 
 \ /
  Last update: 2017-10-10 01:18    [W:0.092 / U:23.960 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site