Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful works for CONFIG_PREEMPT_NONE
From: Peter Zijlstra
Date: Tue Sep 13 2016 - 04:46:05 EST
On Tue, Sep 13, 2016 at 12:03:05PM +0800, Cheng Chao wrote:
>
> Peter, Is it as a new patch?
I wanted both changes in one pathc, but I fudged my git-diff.
> > ---
> > kernel/stop_machine.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
> > index ae6f41fb9cba..637798d6b554 100644
> > --- a/kernel/stop_machine.c
> > +++ b/kernel/stop_machine.c
> > @@ -121,6 +121,11 @@ int stop_one_cpu(unsigned int cpu, cpu_stop_fn_t fn, void *arg)
> > cpu_stop_init_done(&done, 1);
> > if (!cpu_stop_queue_work(cpu, &work))
> > return -ENOENT;
> > + /*
> > + * In case @cpu == smp_proccessor_id() we can avoid a sleep+wakeup
> > + * by doing a preemption.
> > + */
> > + cond_resched();
> > wait_for_completion(&done.completion);
> > return done.ret;
> > }
> >
>
> I agree to use cond_resched(). https://lkml.org/lkml/2016/9/12/1228
>
> so we really don't need "if defined(CONFIG_PREEMPT_NONE)"?
> I also think without the "if defined(CONFIG_PREEMPT_NONE)",
> the code is more clean,and the logic is still ok.
You really don't need the #ifdef, look at the actual code, not the
Kconfig language.