lkml.org 
[lkml]   [2021]   [Mar]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] sched: replace if (cond) BUG() with BUG_ON()
On Wed, Mar 17, 2021 at 9:05 PM Ingo Molnar <mingo@kernel.org> wrote:
> * Arnd Bergmann <arnd@kernel.org> wrote:
> > On Wed, Mar 17, 2021 at 9:45 AM Ingo Molnar <mingo@kernel.org> wrote:
> > >
> > > More importantly, we use this pattern when we don't want !CONFIG_BUG
> > > to remove the 'condition'.
> > >
> > > I.e. the "side effect" here is important scheduler logic. It must
> > > never be optimized out.
> >
> > This behavior for !CONFIG_BUG has changed a while ago, it is now safe
> > to rely on the side-effect of the BUG_ON() condition regardless of
> > CONFIG_BUG. When that option is disabled, running into the condition
> > just ends up in a "do {} while (1)" loop.
>
> Dunno, I still think it's not a particularly clean pattern to 'hide'
> significant side effects within a BUG_ON().

Fair enough. Readability really is the key here, and I agree the current
version is easier to understand. The only architectures that even define
an optimized BUG_ON() are mips and powerpc, and saving a few cycles
is barely worth it in a fast path, which this is clearly not.

Arnd

\
 
 \ /
  Last update: 2021-03-17 22:40    [W:0.665 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site