From: Peter Zijlstra <peterz@infradead.org>
To: Jonathan Davies <jonathan.davies@citrix.com>
Cc: Ingo Molnar <mingo@redhat.com>,
linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH RFC] sched/core: Make idle_cpu return 0 if doing softirq work
Date: Fri, 18 Jul 2014 16:08:21 +0200 [thread overview]
Message-ID: <20140718140821.GD20603@laptop.programming.kicks-ass.net> (raw)
In-Reply-To: <1405688346-7349-1-git-send-email-jonathan.davies@citrix.com>
On Fri, Jul 18, 2014 at 01:59:06PM +0100, Jonathan Davies wrote:
> The current implementation of idle_cpu only considers tasks that might be in the
> CPU's runqueue. If there's nothing in the specified CPU's runqueue, it will
> return 1. But if the CPU is doing work in the softirq context, it is wrong for
> idle_cpu to return 1. This patch makes it return 0.
>
> I observed this to be a problem with a device driver kicking a kthread by
> executing wake_up from softirq context. The Completely Fair Scheduler's
> select_task_rq_fair was looking for an "idle sibling" of the CPU executing it by
> calling select_idle_sibling, passing the executing CPU as the 'target'
> parameter. The first thing that select_idle_sibling does is to check whether the
> 'target' CPU is idle, using idle_cpu, and to return that CPU if so. Despite the
> executing CPU being busy in softirq context, idle_cpu was returning 1, meaning
> that the scheduler would consistently try to run the kthread on the same CPU as
> the kick came from. Given that the softirq work was on-going, this led to a
> multi-millisecond delay before the scheduler eventually realised it should
> migrate the kthread to a different CPU.
If your softirq takes _that_ long its broken anyhow.
> A solution to this problem would be to make idle_cpu return 0 when the CPU is
> running in softirq context. I haven't got a patch for that because I couldn't
> find an easy way of querying whether an arbitrary CPU is doing this. (Perhaps I
> should look at the per-CPU softirq_work_list[]...?)
in_serving_softirq()?
> Instead, the following patch is a partial solution, only handling the case when
> the currently-executing CPU is in softirq context. This was sufficient to solve
> the problem I observed.
NAK, IRQ and SoftIRQ are outside of what the scheduler can control, so
for its purpose the CPU is indeed idle.
next prev parent reply other threads:[~2014-07-18 14:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-18 12:59 [PATCH RFC] sched/core: Make idle_cpu return 0 if doing softirq work Jonathan Davies
2014-07-18 14:08 ` Peter Zijlstra [this message]
2014-07-21 16:56 ` Jonathan Davies
2014-07-21 17:09 ` Peter Zijlstra
2014-07-22 9:35 ` Hillf Danton
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=20140718140821.GD20603@laptop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=jonathan.davies@citrix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--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