Re: [PATCH v2 1/2] sched: force update of blocked load of idle cpus
From: Peter Zijlstra
Date: Wed Dec 20 2017 - 10:05:14 EST
On Wed, Dec 20, 2017 at 04:01:10PM +0100, Peter Zijlstra wrote:
> Well, you shouldn't mix atomic and non-atomic ops to the same word,
> that's asking for trouble.
>
> But why don't you do something like:
>
> nohz_kick()
>
> flags = NOHZ_STAT;
> if (!only_update)
> flags |= NOHZ_BALANCE;
>
> atomic_long_or(flags, &nohz_cpu(cpu));
>
>
> nohz_idle_balance()
>
> unsigned long do_flags = atomic_long_fetch_andnot(NOHZ_BALANCE|NOHZ_STAT, &nohz_flags(cpu));
>
> if (do_flags & NOHZ_STAT)
> update_blocked_stuff();
>
> if (do_flags & NOHZ_BALANCE)
> rebalance_domains();
>
> That way its far more readable.
we could use atomic_t too, there's not that many flags in there, the
only reason its long is because of that bitmap crud.