linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: cheng chao <chengchao@kedacom.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: Mon, 5 Sep 2016 15:11:48 +0200	[thread overview]
Message-ID: <20160905131147.GA8552@redhat.com> (raw)
In-Reply-To: <1473056403-7877-1-git-send-email-chengchao@kedacom.com>

On 09/05, cheng chao wrote:
>
> @@ -2958,7 +2958,7 @@ void sched_exec(void)
>  		struct migration_arg arg = { p, dest_cpu };
>  
>  		raw_spin_unlock_irqrestore(&p->pi_lock, flags);
> -		stop_one_cpu(task_cpu(p), migration_cpu_stop, &arg);
> +		stop_one_cpu_sync(task_cpu(p), migration_cpu_stop, &arg);
>  		return;
>  	}
>  unlock:
> diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
> index 4a1ca5f..24f8637 100644
> --- a/kernel/stop_machine.c
> +++ b/kernel/stop_machine.c
> @@ -130,6 +130,27 @@ int stop_one_cpu(unsigned int cpu, cpu_stop_fn_t fn, void *arg)
>  	return done.ret;
>  }
>  
> +/**
> + * the caller keeps task_on_rq_queued, so it's more suitable for
> + * sched_exec on the case when needs migration
> + */
> +void stop_one_cpu_sync(unsigned int cpu, cpu_stop_fn_t fn, void *arg)
> +{
> +	struct cpu_stop_work work = { .fn = fn, .arg = arg, .done = NULL };
> +
> +	if (!cpu_stop_queue_work(cpu, &work))
> +		return;
> +
> +#if defined(CONFIG_PREEMPT_NONE) || defined(CONFIG_PREEMPT_VOLUNTARY)
> +	/*
> +	 * CONFIG_PREEMPT doesn't need call schedule here, because
> +	 * preempt_enable already does the similar thing when call
> +	 * cpu_stop_queue_work
> +	 */
> +	schedule();
> +#endif
> +}

Honestly, I don't really understand the changelog, but this looks wrong.

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.

But this is not necessarily true? This task can migrate to another CPU
before cpu_stop_queue_work() ?

Oleg.

  reply	other threads:[~2016-09-05 13:11 UTC|newest]

Thread overview: 12+ 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 [this message]
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
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  2:04   ` chengchao
2016-09-09  2:26     ` Ye Xiaolong
2016-09-09  2:36       ` 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=20160905131147.GA8552@redhat.com \
    --to=oleg@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=chengchao@kedacom.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).