Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1477533
| Path | csiph.com!news.mixmin.net!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Oleg Nesterov <oleg@redhat.com> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] sched/core: simpler function for sched_exec migration |
| Date | Tue, 06 Sep 2016 17:30:02 +0200 |
| Message-ID | <seqtY-3JB-67@gated-at.bofh.it> (permalink) |
| References | <sdVzQ-8rK-23@gated-at.bofh.it> <se1YC-4eB-17@gated-at.bofh.it> <see9r-422-5@gated-at.bofh.it> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Disposition | inline |
| User-Agent | Mutt/1.5.18 (2008-05-17) |
| X-Scanned-By | MIMEDefang 2.68 on 10.5.11.24 |
| X-Greylist | Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 06 Sep 2016 15:23:35 +0000 (UTC) |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 52 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | mingo@kernel.org, peterz@infradead.org, tj@kernel.org, akpm@linux-foundation.org, chris@chris-wilson.co.uk, linux-kernel@vger.kernel.org |
| X-Original-Date | Tue, 6 Sep 2016 17:22:54 +0200 |
| X-Original-Message-ID | <20160906152253.GB17586@redhat.com> |
| X-Original-References | <1473056403-7877-1-git-send-email-chengchao@kedacom.com> <20160905131147.GA8552@redhat.com> <db5c6fcd-ae5d-0f41-2d45-d161421cf9c4@kedacom.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1477533 |
Show key headers only | View raw
On 09/06, chengchao wrote:
>
> the key point is for CONFIG_PREEMPT_NONE=y,
> ...
> it is too much overhead for one task(fork()+exec()), isn't it?
Yes, yes, I see, this is suboptimal. Not sure we actually do care,
but yes, perhaps another helper which migrates the current task makes
sense, I dunno.
But,
> > stop_one_cpu_sync() assumes that cpu == smp_processor_id/task_cpu(current),
> > and thus the stopper thread should preempt us at least after schedule()
> > (if CONFIG_PREEMPT_NONE), so we do not need to synchronize.
> >
> yes. the stop_one_cpu_sync is not a good name, stop_one_cpu_schedule is better?
> there is nothing about synchronization.
We need to synchronize with the stopper to ensure it can't touch
cpu_stop_work on stack after stop_one_cpu_sync() returns, and
> > But this is not necessarily true? This task can migrate to another CPU
> > before cpu_stop_queue_work() ?
> >
> before sched_exec() calls stop_one_cpu()/cpu_stop_queue_work(), this
> task(current) cannot migrate to another cpu,because this task is running
> on the cpu.
Why? The running task can migrate to another CPU at any moment. Unless it
runs with preemption disabled or CONFIG_PREEMPT_NONE=y.
And this means that cpu_stop_queue_work() can queue the work on another
CPU != smp_processor_id(), and in this case the kernel can crash because
the pending cpu_stop_work can be overwritten right after return.
So you need something like
void stop_one_cpu_sync(cpu_stop_fn_t fn, void *arg)
{
struct cpu_stop_work work = { .fn = fn, .arg = arg, .done = NULL };
preempt_disable();
cpu_stop_queue_work(raw_smp_processor_id(), &work);
preempt_enable_no_resched();
schedule();
}
or I am totally confused. Note that it doesn't (and shouldn't) have
the "int cpu" argument.
Oleg.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] sched/core: simpler function for sched_exec migration cheng chao <chengchao@kedacom.com> - 2016-09-05 08:30 +0200
Re: [PATCH] sched/core: simpler function for sched_exec migration Oleg Nesterov <oleg@redhat.com> - 2016-09-05 15:20 +0200
Re: [PATCH] sched/core: simpler function for sched_exec migration chengchao <chengchao@kedacom.com> - 2016-09-06 04:20 +0200
Re: [PATCH] sched/core: simpler function for sched_exec migration Oleg Nesterov <oleg@redhat.com> - 2016-09-06 17:30 +0200
Re: [PATCH] sched/core: simpler function for sched_exec migration chengchao <chengchao@kedacom.com> - 2016-09-07 05:30 +0200
Re: [PATCH] sched/core: simpler function for sched_exec migration Oleg Nesterov <oleg@redhat.com> - 2016-09-07 14:40 +0200
Re: [PATCH] sched/core: simpler function for sched_exec migration chengchao <chengchao@kedacom.com> - 2016-09-08 04:20 +0200
Re: [PATCH] sched/core: simpler function for sched_exec migration Peter Zijlstra <peterz@infradead.org> - 2016-09-09 12:10 +0200
csiph-web