linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yuriy Romanenko <yromanenko@carrietech.com>
To: Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 1/1] Fix tasks being forgotten for a long time on SMP
Date: Wed, 21 Sep 2016 07:51:02 -0700	[thread overview]
Message-ID: <CACOPJM5QWsN6tmhUYLrt5ZqbuAOgyQfwoBDZzRt5MHmm1ZVSZA@mail.gmail.com> (raw)

Now without HTML

>From e9a304ae91fa2a4427bde7d3aea18296d0ebb27f Mon Sep 17 00:00:00 2001
From: Yuriy Romanenko <yromanenko@carrietech.com>
Date: Tue, 20 Sep 2016 17:47:28 -0700
Subject: [PATCH] Fix tasks being forgotten for a long time on SMP

Observed occasional very high latency on an embedded SMP system between
a task becoming ready to run and actually running with low system load,
impacting interactive usage.

A sched_wake() from CPUx on CPUy puts the task into the run queue and
marks it runnable, but does not trigger an IPI to have the scheduler
re-run on CPUy and see if the current task needs to get pre-empted and
does not wake up CPUy if it is asleep.

This is especially evident when a CPU is in SWFI and simply does not
wake up even though it now has a runnable task.

This is probably not the most elegant fix and definitely generates some
unnecessary scheduler runs, but it's better for overall latency.

Signed-off-by: Yuriy Romanenko <yromanenko@carrietech.com>
---
 kernel/sched/core.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 860070f..7c334b7 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1686,6 +1686,14 @@ static void ttwu_do_wakeup(struct rq *rq,
struct task_struct *p, int wake_flags,
  trace_sched_wakeup(p);

 #ifdef CONFIG_SMP
+ /*
+ * If the task is not on the current cpu, there is a chance
+ * the other cpu might be asleep and will not get to our task
+ * for a really long time. Send an IPI to avoid that
+ */
+ if (task_cpu(p) != smp_processor_id())
+ smp_send_reschedule(task_cpu(p));
+
  if (p->sched_class->task_woken) {
  /*
  * Our task @p is fully woken up and running; so its safe to
-- 
2.7.4

                 reply	other threads:[~2016-09-21 14:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=CACOPJM5QWsN6tmhUYLrt5ZqbuAOgyQfwoBDZzRt5MHmm1ZVSZA@mail.gmail.com \
    --to=yromanenko@carrietech.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.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).