linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kirill Tkhai <tkhai@yandex.ru>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	Kirill Tkhai <ktkhai@parallels.com>,
	ralf@linux-mips.org
Subject: Re: [PATCH 2/7] sched: Fix picking a task switching on other cpu (__ARCH_WANT_UNLOCKED_CTXSW)
Date: Sun, 21 Sep 2014 00:19:18 +0400	[thread overview]
Message-ID: <1411244358.3396.8.camel@localhost.localdomain> (raw)
In-Reply-To: <1411243745.3396.7.camel@localhost.localdomain>

В Вс, 21/09/2014 в 00:09 +0400, Kirill Tkhai пишет:
> В Сб, 20/09/2014 в 20:54 +0200, Peter Zijlstra пишет:
> > On Sat, Sep 20, 2014 at 08:33:26PM +0200, Peter Zijlstra wrote:
> > > On Sat, Sep 20, 2014 at 08:51:22PM +0400, Kirill Tkhai wrote:
> > > > From: Kirill Tkhai <ktkhai@parallels.com>
> > > > 
> > > > We may pick a task which is in context_switch() on other cpu at the moment.
> > > > Parallel using of a single stack by two processes is not a good idea.
> > > 
> > > Please elaborate on who exactly that might happen. Its best to have
> > > comprehensive changelogs for issues that fix races.
> > 
> > FWIW IIRC we can remove UNLOCKED_CTXSW from IA64 and I forgot if I
> > audited MIPS, but I suspect we can (and should) remove it there too.
> > 
> > That would make this exception go away and clean up some of this ugly.
> 
> Yeah, you've said me about IA64:
> 
> http://www.spinics.net/lists/linux-ia64/msg10229.html
> 
> It's about 10 years since the logic, which was documented in ia64
> header, has been removed. It looks like, ia64 maintainers are not
> interested much...
> 
> ***
> 
> To do not to start a new message. I've found the above when I was
> analysing if the optimisation below is OK (assume, we have accessor
> cpu_relax__while_on_cpu()):
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 7d0d023..8d765ba 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1699,8 +1699,6 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
>  		goto stat;
>  
>  #ifdef CONFIG_SMP
> -	cpu_relax__while_on_cpu(p);
> -
>  	p->sched_contributes_to_load = !!task_contributes_to_load(p);
>  	p->state = TASK_WAKING;
>  
> @@ -1708,6 +1706,9 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
>  		p->sched_class->task_waking(p);
>  
>  	cpu = select_task_rq(p, p->wake_cpu, SD_BALANCE_WAKE, wake_flags);
> +
> +	cpu_relax__while_on_cpu(p);
> +
>  	if (task_cpu(p) != cpu) {
>  		wake_flags |= WF_MIGRATED;
>  		set_task_cpu(p, cpu);
> 
> Looks like, now problem here. Task p is dequeued, we can set sched_contributes_to_load and state

s/now/no/

> here, also task_waking does not produce problems, only arithmetics is there. select_task_rq()
> is R/O function.
> 
> Now I'm testing this.


  reply	other threads:[~2014-09-20 20:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-20 16:51 [PATCH 1/7] sched/fair: Remove duplicate code from can_migrate_task() Kirill Tkhai
2014-09-20 16:51 ` [PATCH 2/7] sched: Fix picking a task switching on other cpu (__ARCH_WANT_UNLOCKED_CTXSW) Kirill Tkhai
2014-09-20 18:33   ` Peter Zijlstra
2014-09-20 18:54     ` Peter Zijlstra
2014-09-20 20:09       ` Kirill Tkhai
2014-09-20 20:19         ` Kirill Tkhai [this message]
2014-09-20 19:03     ` Peter Zijlstra
2014-09-20 16:51 ` [PATCH 3/7] sched: Use dl_bw_of() under RCU read lock Kirill Tkhai
2014-09-20 18:57   ` Peter Zijlstra
2014-09-20 19:25     ` Kirill Tkhai
2014-09-20 19:32       ` Peter Zijlstra
2014-09-20 16:51 ` [PATCH 4/7] sched: cleanup: Rename out_unlock to out_free_new_mask Kirill Tkhai
2014-09-20 16:51 ` [PATCH 5/7] sched: Use rq->rd in sched_setaffinity() under RCU read lock Kirill Tkhai
2014-09-20 18:59   ` Peter Zijlstra
2014-09-20 19:05     ` Kirill Tkhai
2014-09-20 19:18       ` Peter Zijlstra
2014-09-20 19:21         ` Kirill Tkhai
2014-09-20 16:51 ` [PATCH 6/7] sched: Delete rq::skip_clock_update == -1 Kirill Tkhai
2014-09-20 19:01   ` Peter Zijlstra
2014-09-21  4:37     ` Mike Galbraith
2014-09-20 16:51 ` [PATCH 7/7] sched/rt: Use resched_curr() in task_tick_rt() Kirill Tkhai

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=1411244358.3396.8.camel@localhost.localdomain \
    --to=tkhai@yandex.ru \
    --cc=ktkhai@parallels.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=ralf@linux-mips.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).