lkml.org 
[lkml]   [2021]   [Mar]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] sched: replace if (cond) BUG() with BUG_ON()

* Ingo Molnar <mingo@kernel.org> wrote:

>
> * Jiapeng Chong <jiapeng.chong@linux.alibaba.com> wrote:
>
> > Fix the following coccicheck warnings:
> >
> > ./kernel/sched/core.c:8039:2-5: WARNING: Use BUG_ON instead of if
> > condition followed by BUG.
> >
> > Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> > Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> > ---
> > kernel/sched/core.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index 9819121..7392bc0 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -8035,8 +8035,7 @@ void __init sched_init_smp(void)
> > mutex_unlock(&sched_domains_mutex);
> >
> > /* Move init over to a non-isolated CPU */
> > - if (set_cpus_allowed_ptr(current, housekeeping_cpumask(HK_FLAG_DOMAIN)) < 0)
> > - BUG();
> > + BUG(set_cpus_allowed_ptr(current, housekeeping_cpumask(HK_FLAG_DOMAIN)) < 0);
>
> The patch doesn't quite do what the title & changelog claims...

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.

Thanks,

Ingo

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