From: Frank Rowand <frank.rowand@am.sony.com>
To: Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@elte.hu>
Cc: Chris Mason <chris.mason@oracle.com>,
"axboe@kernel.dk" <axboe@kernel.dk>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Mike Galbraith <efault@gmx.de>, Oleg Nesterov <oleg@redhat.com>,
tglx <tglx@linutronix.de>
Subject: Re: [PATCH RFC] reduce runqueue lock contention
Date: Mon, 13 Dec 2010 18:41:44 -0800 [thread overview]
Message-ID: <4D06D968.9070004@am.sony.com> (raw)
In-Reply-To: <1277125479.1875.510.camel@laptop>
On 06/21/10 06:04, Peter Zijlstra wrote:
> On Mon, 2010-06-21 at 12:54 +0200, Peter Zijlstra wrote:
>>> It looses the ttwu task_running() check, as I must admit I'm not quite
>>> sure what it does.. Ingo?
>
> I think I figured out what its for, its for when p is prev in schedule()
> after deactivate_task(), we have to call activate_task() it again, but
> we cannot migrate the task because the CPU its on is still referencing
> it.
I have not been able to make sense of the task_running() check in
try_to_wake_up(), even with that clue. The try_to_wake_up() code in
question is:
rq = task_rq_lock(p, &flags);
if (!(p->state & state))
goto out;
if (p->se.on_rq)
goto out_running;
cpu = task_cpu(p);
orig_cpu = cpu;
#ifdef CONFIG_SMP
if (unlikely(task_running(rq, p)))
goto out_activate;
The relevent code in schedule() executes with the rq lock held (many
lines left out to emphasize the key lines):
raw_spin_lock_irq(&rq->lock);
if (prev->state && !(preempt_count() & PREEMPT_ACTIVE)) {
deactivate_task(rq, prev, DEQUEUE_SLEEP);
if (likely(prev != next)) {
rq->curr = next;
context_switch(rq, prev, next); /* unlocks the rq */
} else
raw_spin_unlock_irq(&rq->lock);
If (p->se.on_rq) can becomes false due to deactivate_task()
then task_running() will also become false while the rq lock is still
held (either via "rq->curr = next" or via context_switch() updating
p->oncpu -- which one matters depends on #ifdef __ARCH_WANT_UNLOCKED_CTXSW).
I haven't been able to find any case where task_running() can be true
when (p->se.on_rq) is false, while the rq lock is not being held. Thus
I don't think the branch to out_activate will ever be taken.
What am I missing, or is the task_running() test not needed?
Thanks!
Frank
next prev parent reply other threads:[~2010-12-14 2:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-20 20:48 Chris Mason
2010-05-20 21:09 ` Peter Zijlstra
2010-05-20 21:23 ` Peter Zijlstra
2010-05-20 22:17 ` Chris Mason
2010-05-20 22:21 ` Chris Mason
2010-06-04 10:56 ` Stijn Devriendt
2010-06-04 12:00 ` Peter Zijlstra
2010-06-05 9:37 ` Stijn Devriendt
2010-06-21 10:02 ` Peter Zijlstra
2010-06-21 10:54 ` Peter Zijlstra
2010-06-21 13:04 ` Peter Zijlstra
2010-06-22 13:33 ` Peter Zijlstra
2010-06-22 21:11 ` Ingo Molnar
2010-06-23 9:10 ` Peter Zijlstra
2010-12-01 23:13 ` Frank Rowand
2010-12-02 1:17 ` Frank Rowand
2010-12-02 7:36 ` Peter Zijlstra
2010-12-14 2:41 ` Frank Rowand [this message]
2010-12-14 3:42 ` Mike Galbraith
2010-12-14 21:42 ` Frank Rowand
2010-12-15 18:59 ` Oleg Nesterov
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=4D06D968.9070004@am.sony.com \
--to=frank.rowand@am.sony.com \
--cc=axboe@kernel.dk \
--cc=chris.mason@oracle.com \
--cc=efault@gmx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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
Powered by JetHome