Re: [PATCH] atomic: Fix bugs in 'fetch_or()' and rename it to 'xchg_or()'

From: Peter Zijlstra
Date: Tue Mar 15 2016 - 07:06:48 EST


On Tue, Mar 15, 2016 at 10:32:45AM +0100, Ingo Molnar wrote:
> diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
> index 969e6704c3c9..851631899352 100644
> --- a/kernel/time/tick-sched.c
> +++ b/kernel/time/tick-sched.c
> @@ -264,7 +264,7 @@ static void tick_nohz_dep_set_all(unsigned long *dep,
> {
> unsigned long prev;
>
> - prev = fetch_or(dep, BIT_MASK(bit));
> + prev = xchg_or(dep, BIT_MASK(bit));
> if (!prev)
> tick_nohz_full_kick_all();
> }
> @@ -294,7 +294,7 @@ void tick_nohz_dep_set_cpu(int cpu, enum tick_dep_bits bit)
>
> ts = per_cpu_ptr(&tick_cpu_sched, cpu);
>
> - prev = fetch_or(&ts->tick_dep_mask, BIT_MASK(bit));
> + prev = xchg_or(&ts->tick_dep_mask, BIT_MASK(bit));
> if (!prev) {
> preempt_disable();
> /* Perf needs local kick that is NMI safe */

Those should probably also use BIT(), BIT_MASK() is specifically for
bitmasks, and should be combined with BIT_WORD().