Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1481164
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v3] stop_machine: Make migration_cpu_stop() does useful works for CONFIG_PREEMPT_NONE |
| Date | 2016-09-12 13:50 +0200 |
| Message-ID | <sgxUm-2FS-3@gated-at.bofh.it> (permalink) |
| References | <sfpct-qw-1@gated-at.bofh.it> <sfMiJ-6sU-9@gated-at.bofh.it> <sgxKF-2Ci-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon, Sep 12, 2016 at 01:37:27PM +0200, Peter Zijlstra wrote:
> So what you're saying is that migration_stop_cpu() doesn't work because
> wait_for_completion() dequeues the task.
>
> True I suppose. Not sure I like your solution, nor your implementation
> of the solution much though.
>
> I would much prefer an unconditional cond_resched() there, but also, I
> think we should do what __migrate_swap_task() does, and set wake_cpu.
>
> So something like so..
>
> ---
> kernel/sched/core.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index ddd5f48551f1..ade772aa9610 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1063,8 +1063,12 @@ static int migration_cpu_stop(void *data)
> * holding rq->lock, if p->on_rq == 0 it cannot get enqueued because
> * we're holding p->pi_lock.
> */
> - if (task_rq(p) == rq && task_on_rq_queued(p))
> - rq = __migrate_task(rq, p, arg->dest_cpu);
> + if (task_rq(p) == rq) {
> + if (task_on_rq_queued(p))
> + rq = __migrate_task(rq, p, arg->dest_cpu);
> + else
> + p->wake_cpu = arg->dest_cpu;
> + }
> raw_spin_unlock(&rq->lock);
> raw_spin_unlock(&p->pi_lock);
>
And this, too narrow a constraint do git diff made it go away.
---
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;
}
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[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