From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752804AbcIIIT1 (ORCPT ); Fri, 9 Sep 2016 04:19:27 -0400 Received: from email.kedacom.com ([221.224.36.251]:11158 "EHLO test1.kedacom.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751944AbcIIITX (ORCPT ); Fri, 9 Sep 2016 04:19:23 -0400 Subject: Re: [PATCH v2] stop_machine: Make migration_cpu_stop() does useful works for CONFIG_PREEMPT_NONE To: mingo@kernel.org, oleg@redhat.com, peterz@infradead.org, tj@kernel.org, akpm@linux-foundation.org, chris@chris-wilson.co.uk References: <1473408834-6122-1-git-send-email-chengchao@kedacom.com> Cc: linux-kernel@vger.kernel.org From: chengchao Message-ID: <146661ce-936d-a3e0-5b3c-bd0c742ccc46@kedacom.com> Date: Fri, 9 Sep 2016 16:19:01 +0800 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.0 MIME-Version: 1.0 In-Reply-To: <1473408834-6122-1-git-send-email-chengchao@kedacom.com> X-MIMETrack: Itemize by SMTP Server on kedacomsmtp/kedacom(Release 8.5.3|September 15, 2011) at 2016-09-09 16:19:05, Serialize by Router on kedacomsmtp/kedacom(Release 8.5.3|September 15, 2011) at 2016-09-09 16:19:05, Serialize complete at 2016-09-09 16:19:05, Itemize by SMTP Server on kedacomtest1/kedacom(Release 8.5.3|September 15, 2011) at 2016/09/09 16:18:56, Serialize by Router on kedacomtest1/kedacom(Release 8.5.3|September 15, 2011) at 2016/09/09 16:19:13, Serialize complete at 2016/09/09 16:19:13 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=gbk Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --in-reply-to doesn't work? v1 is : https://lkml.org/lkml/2016/9/7/819 on 09/09/2016 04:13 PM, Cheng Chao wrote: > For CONFIG_PREEMPT_NONE=y, when sched_exec() needs migration, sched_exec() > calls stop_one_cpu(task_cpu(p), migration_cpu_stop, &arg). > > 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. > > But in fact, all above works are almost useless(wasteful),the reason is > migration_cpu_stop() can not migrate. why? migration_cpu_stop() needs the > task is TASK_ON_RQ_QUEUED before it calls __migrate_task(). > > This patch keeps the task TASK_RUNNING instead of TASK_UNINTERRUPTIBLE, > so the migration_cpu_stop() can do useful works. > > Signed-off-by: Cheng Chao > --- > 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(); > +#endif > wait_for_completion(&done.completion); > return done.ret; > } >