Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1609565

Re: [PATCH] sched/core: switch to BUG_ON()

From Peter Zijlstra <peterz@infradead.org>
Newsgroups linux.kernel
Subject Re: [PATCH] sched/core: switch to BUG_ON()
Date 2017-03-27 10:30 +0200
Message-ID <tpych-55m-1@gated-at.bofh.it> (permalink)
References <tpxzz-4xd-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Mar 27, 2017 at 09:40:46AM +0200, Nicholas Mc Guire wrote:

> Found by coccinelle: bugon.cocci
> ./kernel/sched/core.c:5913:2-5: WARNING: Use BUG_ON instead of if condition followed by BUG.

Right, so I disagree with that here.

> @@ -5909,8 +5909,8 @@ 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, non_isolated_cpus) < 0)
> -		BUG();
> +	BUG_ON(set_cpus_allowed_ptr(current, non_isolated_cpus) < 0);
> +
>  	sched_init_granularity();
>  	free_cpumask_var(non_isolated_cpus);

If the condition were without side effects, that pattern would hold, but
here the function call set_cpus_allowed_ptr() is very much not a pure
function, so wrapping it in a BUG_ON() just fels wrong.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] sched/core: switch to BUG_ON() Nicholas Mc Guire <der.herr@hofr.at> - 2017-03-27 09:50 +0200
  Re: [PATCH] sched/core: switch to BUG_ON() Peter Zijlstra <peterz@infradead.org> - 2017-03-27 10:30 +0200
    Re: [PATCH] sched/core: switch to BUG_ON() Nicholas Mc Guire <der.herr@hofr.at> - 2017-03-27 11:20 +0200

csiph-web