public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
	vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
	rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
	bristot@redhat.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched: replace if (cond) BUG() with BUG_ON()
Date: Wed, 17 Mar 2021 09:41:32 +0100	[thread overview]
Message-ID: <20210317084132.GA378908@gmail.com> (raw)
In-Reply-To: <20210317083947.GD3881262@gmail.com>


* 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

  reply	other threads:[~2021-03-17  8:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17  2:45 [PATCH] sched: replace if (cond) BUG() with BUG_ON() Jiapeng Chong
2021-03-17  8:39 ` Ingo Molnar
2021-03-17  8:41   ` Ingo Molnar [this message]
2021-03-17 12:55     ` Arnd Bergmann
2021-03-17 20:05       ` Ingo Molnar
2021-03-17 21:38         ` Arnd Bergmann
  -- strict thread matches above, loose matches on Subject: below --
2021-03-17  6:45 Jiapeng Chong
2021-03-17  7:00 ` Christophe Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210317084132.GA378908@gmail.com \
    --to=mingo@kernel.org \
    --cc=bristot@redhat.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=jiapeng.chong@linux.alibaba.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox