Re: [PATCH v3 5/5] lib/cpumask: reorganize cpumask_local_spread() logic

From: Yury Norov
Date: Thu Dec 08 2022 - 15:41:55 EST


On Thu, Dec 08, 2022 at 08:17:22PM +0000, Peter Lafreniere wrote:
> > Now after moving all NUMA logic into sched_numa_find_nth_cpu(),
> > else-branch of cpumask_local_spread() is just a function call, and
> > we can simplify logic by using ternary operator.
> >
> > While here, replace BUG() with WARN().
> Why make this change? It's still as bad to hit the WARN_ON as it was before.

For example, because of this:

> Greg, please don't do this
>
> > ChangeSet@1.614, 2002-09-05 08:33:20-07:00, greg@xxxxxxxxx
> > USB: storage driver: replace show_trace() with BUG()
>
> that BUG() thing is _way_ out of line, and has killed a few of my machines
> several times for no good reason. It actively hurts debuggability, because
> the machine is totally dead after it, and the whole and ONLY point of
> BUG() messages is to help debugging and make it clear that we can't handle
> something.
>
> In this case, we _can_ handle it, and we're much better off with a machine
> that works and that you can look up the messages with than killing it.
>
> Rule of thumb: BUG() is only good for something that never happens and
> that we really have no other option for (ie state is so corrupt that
> continuing is deadly).
>
> Linus