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


Groups > linux.kernel > #1479989

Re: [PATCH v2] stop_machine: Make migration_cpu_stop() does useful works for CONFIG_PREEMPT_NONE

From Oleg Nesterov <oleg@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2] stop_machine: Make migration_cpu_stop() does useful works for CONFIG_PREEMPT_NONE
Date 2016-09-09 15:20 +0200
Message-ID <sftSO-3gY-17@gated-at.bofh.it> (permalink)
References <sfpct-qw-3@gated-at.bofh.it> <sfpct-qw-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 09/09, Cheng Chao wrote:
>
> If the migration_cpu_stop() can not migrate,why do we call stop_one_cpu()?
> It just makes the task TASK_UNINTERRUPTIBLE, wakes up the stopper thread,
> executes migration_cpu_stop(), and the stopper thread wakes up the task.

and this finally migrates the target, ttwu() does another
select_task_rq().

> This patch keeps the task TASK_RUNNING instead of TASK_UNINTERRUPTIBLE,
> so the migration_cpu_stop() can do useful works.

yes, this avoids the extra wakeup/select_task_rq. So this is the minor
optimization.

> Signed-off-by: Cheng Chao <chengchao@kedacom.com>
> ---
>  kernel/stop_machine.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
> index 4a1ca5f..41aea5e 100644
> --- a/kernel/stop_machine.c
> +++ b/kernel/stop_machine.c
> @@ -126,6 +126,17 @@ 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;
> +
> +#if defined(CONFIG_PREEMPT_NONE)
> +	/*
> +	 * Makes the stopper thread run as soon as possible.
> +	 * And if the caller is TASK_RUNNING, keeps the caller TASK_RUNNING.
> +	 * It's special useful for some callers which are expected to be
> +	 * TASK_ON_RQ_QUEUED.
> +	 * sched_exec does benefit from this improvement.
> +	 */
> +	schedule();

Well. This can help in general, wait_for_completion() won't block, but
only if we queue the work on the same CPU. Otherwise this schedule() adds
the unnecessary pessimization.

That is why I suggested to use _cond_resched() instead of schedule().

But let me repeat, I leave this to maintainers.

Oleg.

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


Thread

[PATCH v2] stop_machine: Make migration_cpu_stop() does useful works for CONFIG_PREEMPT_NONE Cheng Chao <chengchao@kedacom.com> - 2016-09-09 10:20 +0200
  Re: [PATCH v2] stop_machine: Make migration_cpu_stop() does useful  works for CONFIG_PREEMPT_NONE chengchao <chengchao@kedacom.com> - 2016-09-09 10:20 +0200
  Re: [PATCH v2] stop_machine: Make migration_cpu_stop() does useful         works for CONFIG_PREEMPT_NONE Oleg Nesterov <oleg@redhat.com> - 2016-09-09 15:20 +0200
    Re: [PATCH v2] stop_machine: Make migration_cpu_stop() does useful  works for CONFIG_PREEMPT_NONE Peter Zijlstra <peterz@infradead.org> - 2016-09-09 18:30 +0200
  [PATCH v3] stop_machine: Make migration_cpu_stop() does useful works for CONFIG_PREEMPT_NONE Cheng Chao <cs.os.kernel@gmail.com> - 2016-09-10 11:00 +0200
    Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful  works for CONFIG_PREEMPT_NONE Cheng Chao <cs.os.kernel@gmail.com> - 2016-09-10 12:00 +0200
      Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful  works for CONFIG_PREEMPT_NONE Peter Zijlstra <peterz@infradead.org> - 2016-09-10 18:40 +0200
    Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful         works for CONFIG_PREEMPT_NONE Oleg Nesterov <oleg@redhat.com> - 2016-09-12 13:10 +0200
      Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful  works for CONFIG_PREEMPT_NONE Cheng Chao <cs.os.kernel@gmail.com> - 2016-09-13 04:50 +0200
    Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful  works for CONFIG_PREEMPT_NONE Peter Zijlstra <peterz@infradead.org> - 2016-09-12 13:40 +0200
      Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful  works for CONFIG_PREEMPT_NONE Peter Zijlstra <peterz@infradead.org> - 2016-09-12 13:50 +0200
        Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful         works for CONFIG_PREEMPT_NONE Oleg Nesterov <oleg@redhat.com> - 2016-09-12 15:10 +0200
          Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful  works for CONFIG_PREEMPT_NONE Peter Zijlstra <peterz@infradead.org> - 2016-09-12 17:10 +0200
            Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful         works for CONFIG_PREEMPT_NONE Oleg Nesterov <oleg@redhat.com> - 2016-09-13 18:20 +0200
              Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful  works for CONFIG_PREEMPT_NONE Peter Zijlstra <peterz@infradead.org> - 2016-09-13 18:40 +0200
                Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful  works for CONFIG_PREEMPT_NONE Cheng Chao <cs.os.kernel@gmail.com> - 2016-09-14 04:10 +0200
                Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful  works for CONFIG_PREEMPT_NONE Peter Zijlstra <peterz@infradead.org> - 2016-09-14 10:00 +0200
                Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful         works for CONFIG_PREEMPT_NONE Oleg Nesterov <oleg@redhat.com> - 2016-09-14 17:50 +0200
                [tip:sched/core] sched/core: Optimize __schedule() tip-bot for Peter Zijlstra <tipbot@zytor.com> - 2016-09-22 16:10 +0200
        Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful  works for CONFIG_PREEMPT_NONE Cheng Chao <cs.os.kernel@gmail.com> - 2016-09-13 06:10 +0200
          Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful  works for CONFIG_PREEMPT_NONE Peter Zijlstra <peterz@infradead.org> - 2016-09-13 10:50 +0200
    [PATCH v4] stop_machine: Avoid a sleep and wakeup in the stop_one_cpu() Cheng Chao <cs.os.kernel@gmail.com> - 2016-09-14 04:10 +0200
      Re: [PATCH v4] stop_machine: Avoid a sleep and wakeup in the         stop_one_cpu() Oleg Nesterov <oleg@redhat.com> - 2016-09-14 18:00 +0200
      Re: [PATCH v4] stop_machine: Avoid a sleep and wakeup in the  stop_one_cpu() Cheng Chao <cs.os.kernel@gmail.com> - 2016-09-18 04:10 +0200
      [tip:sched/core] stop_machine: Avoid a sleep and wakeup in  stop_one_cpu() tip-bot for Cheng Chao <tipbot@zytor.com> - 2016-09-22 16:10 +0200

csiph-web