All of lore.kernel.org
 help / color / mirror / Atom feed
From: chengchao <chengchao@kedacom.com>
To: Oleg Nesterov <oleg@redhat.com>
Cc: mingo@kernel.org, peterz@infradead.org, tj@kernel.org,
	akpm@linux-foundation.org, chris@chris-wilson.co.uk,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/core: simpler function for sched_exec migration
Date: Thu, 8 Sep 2016 10:17:48 +0800	[thread overview]
Message-ID: <2543729a-5ec1-dda4-28a6-10522271553e@kedacom.com> (raw)
In-Reply-To: <20160907123511.GA1132@redhat.com>

Oled, thank you for moving this patch on.

on 09/07/2016 08:35 PM, Oleg Nesterov wrote:
> On 09/07, chengchao wrote:
>>
>> Oleg, thank you very much.
>>
>> on 09/06/2016 11:22 PM, Oleg Nesterov wrote:
>>> 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.
>>
>> for CONFIG_PREEMPT_NONE=y, this patch wants the stopper thread can migrate the current
>> successfully instead of doing nothing.
> 
> I understand the intent. But I am not sure this optimization makes
> sense.
> 

For CONFIG_PREEMPT_NONE=y, when sched_exec() needs migration, sched_exec() calls
stop_one_cpu(task_cpu(p), migration_cpu_stop, &arg).

If stopper thread can not migrate for us,why should we call stop_one_cpu() here? 
It just makes the task TASK_UNINTERRUPTIBLE, wakes up the stopper thread, executes the 
migration_cpu_stop, and the stopper thread wakes up the task.

But in fact, all above works are almost unuseful, the reason is that the migration_cpu_stop
doesn't migrate for us. why? the migration_cpu_stop() needs the task is TASK_ON_RQ_QUEUED 
before it calls __migrate_task().

This patch can make the task TASK_RUNNING instead of TASK_UNINTERRUPTIBLE,
so the migration_cpu_stop() can migrate happily.

Does this optimization make sense now?

Any different opinions are always welcome.

>> int stop_one_cpu(unsigned int cpu, cpu_stop_fn_t fn, void *arg)
>> {
>>         struct cpu_stop_done done;
>>         struct cpu_stop_work work = { .fn = fn, .arg = arg, .done = &done };
>>
>>         cpu_stop_init_done(&done, 1);
>>         if (!cpu_stop_queue_work(cpu, &work))
>>                 return -ENOENT;
>>
>> #if defined(CONFIG_PREEMPT_NONE)
>> 	   /*
>>          * let the stopper thread runs as soon as possible,
>>          * and keep current TASK_RUNNING.
>>          */
>> 	scheudle();
>> #endif
>>         wait_for_completion(&done.completion);
>>         return done.ret;
>> }
> 
> Agreed this looks better, although I'd suggest _cond_resche().
> 
> Again, I am not sure this makes sense, I leave this to maintainers.
> 

You have done much works for this patch. Thanks again. 

> Oleg.
> 
> 

  reply	other threads:[~2016-09-08  2:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-05  6:20 [PATCH] sched/core: simpler function for sched_exec migration cheng chao
2016-09-05 13:11 ` Oleg Nesterov
2016-09-06  2:11   ` chengchao
2016-09-06 15:22     ` Oleg Nesterov
2016-09-07  3:22       ` chengchao
2016-09-07 12:35         ` Oleg Nesterov
2016-09-08  2:17           ` chengchao [this message]
2016-09-09 10:05           ` Peter Zijlstra
2016-09-09  1:39 ` [lkp] [sched/core] 3d26b7622f: BUG: unable to handle kernel NULL pointer dereference at 00000001 kernel test robot
2016-09-09  1:39   ` kernel test robot
2016-09-09  2:04   ` [lkp] " chengchao
2016-09-09  2:26     ` Ye Xiaolong
2016-09-09  2:26       ` Ye Xiaolong
2016-09-09  2:36       ` [lkp] " chengchao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2543729a-5ec1-dda4-28a6-10522271553e@kedacom.com \
    --to=chengchao@kedacom.com \
    --cc=akpm@linux-foundation.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.