lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Wed, 10 Sep 2014 09:53:47 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Kirill Tkhai <tkhai@...dex.ru>
Cc:	"mingo@...nel.org" <mingo@...nel.org>,
	"hpa@...or.com" <hpa@...or.com>,
	"sasha.levin@...cle.com" <sasha.levin@...cle.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"torvalds@...ux-foundation.org" <torvalds@...ux-foundation.org>,
	"tglx@...utronix.de" <tglx@...utronix.de>,
	"jjherne@...ux.vnet.ibm.com" <jjherne@...ux.vnet.ibm.com>,
	"laijs@...fujitsu.com" <laijs@...fujitsu.com>,
	"linux-tip-commits@...r.kernel.org" 
	<linux-tip-commits@...r.kernel.org>
Subject: Re: [tip:sched/core] sched: Migrate waking tasks

On Wed, Sep 10, 2014 at 11:38:05AM +0400, Kirill Tkhai wrote:
> 09.09.2014, 18:54, "tip-bot for Lai Jiangshan" <tipbot@...or.com>:
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index a814b3c..78e5c83 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -4666,7 +4666,7 @@ int set_cpus_allowed_ptr(struct task_struct *p, const struct cpumask *new_mask)
> >  		goto out;
> >
> >	dest_cpu = cpumask_any_and(cpu_active_mask, new_mask);
> > -	if (task_on_rq_queued(p)) {
> > +	if (task_on_rq_queued(p) || p->state == TASK_WAKING) {
> >  		struct migration_arg arg = { p, dest_cpu };
> >  		/* Need help from migration thread: drop lock and wait. */
> >  		task_rq_unlock(rq, p, &flags);
> 
> 
> About migration_cpu_stop():
> 
> > @@ -4799,6 +4799,12 @@ static int migration_cpu_stop(void *data)
> >  	* be on another cpu but it doesn't matter.
> >  	*/
> >  	local_irq_disable();
> > +	/*
> > +	* We need to explicitly wake pending tasks before running
> > +	* __migrate_task() such that we will not miss enforcing cpus_allowed
> > +	* during wakeups, see set_cpus_allowed_ptr()'s TASK_WAKING test.
> > +	*/
> > +	sched_ttwu_pending();
> >	__migrate_task(arg->task, raw_smp_processor_id(), arg->dest_cpu);
> >	local_irq_enable();
> >	return 0;
> 
> It looks like we do not need this hunk, because IPI happens earlier then
> stop class begins migration_cpu_stop() execution.
> 
> In the first hunk the check "p->state == TASK_WAKING" is under pi_lock,
> so if the task is really waking then the IPI is already set.
> 
> So, the first hunk is enough here, the second is not need.

If the cpu is idle and has TIF_POLLING_NRFLAG we'll never send the IPI,
then again, the wake from idle required to start running the stop task
will also flush that pending queue. So you're probably right.

I'll leave it in though, better safe than sorry and its not a critical
fast path. Good thinking though.

Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ