Re: [RFCv7 PATCH 03/10] sched: scheduler-driven cpu frequency selection

From: Peter Zijlstra
Date: Tue Mar 01 2016 - 08:17:34 EST


On Thu, Feb 25, 2016 at 04:34:23PM -0800, Steve Muckle wrote:
> >> + /*
> >> + * Ensure that all CPUs currently part of this policy are out
> >> + * of the hot path so that if this policy exits we can free gd.
> >> + */
> >> + preempt_disable();
> >> + smp_call_function_many(policy->cpus, dummy, NULL, true);
> >> + preempt_enable();
> >
> > I'm not sure how this works, can you please tell me?
>
> Peter correctly interpreted my intentions.
>
> The RCU possibility also crossed my mind. They both seemed like a bit of
> a hack to me - this wouldn't really be doing any RCU per se, rather
> relying on its implementation. I'll switch to RCU since that seems to be
> preferred though. It's certainly cleaner to write.

RCU is widely used in this fashion. synchronize_sched() is explicitly
constructed to sync against preempt disable sections. This is not an
implementation detail.