From: tip-bot for Peter Zijlstra <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: dave.hansen@linux.intel.com, dvlasenk@redhat.com, ahh@google.com,
peterz@infradead.org, umgwanakikbuti@gmail.com,
matt@codeblueprint.co.uk, oleg@redhat.com, brgerst@gmail.com,
pjt@google.com, bsegall@google.com, pkondeti@codeaurora.org,
linux-kernel@vger.kernel.org, paulmck@linux.vnet.ibm.com,
mingo@kernel.org, bp@alien8.de, hpa@zytor.com,
morten.rasmussen@arm.com, fenghua.yu@intel.com,
torvalds@linux-foundation.org, tglx@linutronix.de,
quentin.casasnovas@oracle.com, luto@amacapital.net
Subject: [tip:sched/urgent] sched/core: Fix remote wakeups
Date: Wed, 25 May 2016 00:12:59 -0700 [thread overview]
Message-ID: <tip-b7e7ade34e6188bee2e3b0d42b51d25137d9e2a5@git.kernel.org> (raw)
In-Reply-To: <20160523091907.GD15728@worktop.ger.corp.intel.com>
Commit-ID: b7e7ade34e6188bee2e3b0d42b51d25137d9e2a5
Gitweb: http://git.kernel.org/tip/b7e7ade34e6188bee2e3b0d42b51d25137d9e2a5
Author: Peter Zijlstra <peterz@infradead.org>
AuthorDate: Mon, 23 May 2016 11:19:07 +0200
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 25 May 2016 08:35:18 +0200
sched/core: Fix remote wakeups
Commit:
b5179ac70de8 ("sched/fair: Prepare to fix fairness problems on migration")
... introduced a bug: Mike Galbraith found that it introduced a
performance regression, while Paul E. McKenney reported lost
wakeups and bisected it to this commit.
The reason is that I mis-read ttwu_queue() such that I assumed any
wakeup that got a remote queue must have had the task migrated.
Since this is not so; we need to transfer this information between
queueing the wakeup and actually doing the wakeup. Use a new
task_struct::sched_flag for this, we already write to
sched_contributes_to_load in the wakeup path so this is a hot and
modified cacheline.
Reported-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reported-by: Mike Galbraith <umgwanakikbuti@gmail.com>
Tested-by: Mike Galbraith <umgwanakikbuti@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Hunter <ahh@google.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Ben Segall <bsegall@google.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Morten Rasmussen <morten.rasmussen@arm.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Paul Turner <pjt@google.com>
Cc: Pavan Kondeti <pkondeti@codeaurora.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: byungchul.park@lge.com
Fixes: b5179ac70de8 ("sched/fair: Prepare to fix fairness problems on migration")
Link: http://lkml.kernel.org/r/20160523091907.GD15728@worktop.ger.corp.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
include/linux/sched.h | 1 +
kernel/sched/core.c | 18 +++++++++++-------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 6cc0df9..e053517 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1533,6 +1533,7 @@ struct task_struct {
unsigned sched_reset_on_fork:1;
unsigned sched_contributes_to_load:1;
unsigned sched_migrated:1;
+ unsigned sched_remote_wakeup:1;
unsigned :0; /* force alignment to the next boundary */
/* unserialized, strictly 'current' */
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 404c078..7f2cae4 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1768,13 +1768,15 @@ void sched_ttwu_pending(void)
cookie = lockdep_pin_lock(&rq->lock);
while (llist) {
+ int wake_flags = 0;
+
p = llist_entry(llist, struct task_struct, wake_entry);
llist = llist_next(llist);
- /*
- * See ttwu_queue(); we only call ttwu_queue_remote() when
- * its a x-cpu wakeup.
- */
- ttwu_do_activate(rq, p, WF_MIGRATED, cookie);
+
+ if (p->sched_remote_wakeup)
+ wake_flags = WF_MIGRATED;
+
+ ttwu_do_activate(rq, p, wake_flags, cookie);
}
lockdep_unpin_lock(&rq->lock, cookie);
@@ -1819,10 +1821,12 @@ void scheduler_ipi(void)
irq_exit();
}
-static void ttwu_queue_remote(struct task_struct *p, int cpu)
+static void ttwu_queue_remote(struct task_struct *p, int cpu, int wake_flags)
{
struct rq *rq = cpu_rq(cpu);
+ p->sched_remote_wakeup = !!(wake_flags & WF_MIGRATED);
+
if (llist_add(&p->wake_entry, &cpu_rq(cpu)->wake_list)) {
if (!set_nr_if_polling(rq->idle))
smp_send_reschedule(cpu);
@@ -1869,7 +1873,7 @@ static void ttwu_queue(struct task_struct *p, int cpu, int wake_flags)
#if defined(CONFIG_SMP)
if (sched_feat(TTWU_QUEUE) && !cpus_share_cache(smp_processor_id(), cpu)) {
sched_clock_cpu(cpu); /* sync clocks x-cpu */
- ttwu_queue_remote(p, cpu);
+ ttwu_queue_remote(p, cpu, wake_flags);
return;
}
#endif
next prev parent reply other threads:[~2016-05-25 7:14 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-10 17:43 [PATCH 0/3] sched: Fix wakeup preemption regression Peter Zijlstra
2016-05-10 17:43 ` [PATCH 1/3] sched,fair: Move record_wakee() Peter Zijlstra
2016-05-12 10:27 ` Matt Fleming
2016-05-12 10:31 ` Peter Zijlstra
2016-05-10 17:43 ` [PATCH 2/3] sched,fair: Fix local starvation Peter Zijlstra
2016-05-10 20:21 ` Ingo Molnar
2016-05-10 22:23 ` Peter Zijlstra
2016-05-20 21:24 ` Matt Fleming
2016-05-21 14:04 ` Mike Galbraith
2016-05-21 19:00 ` Mike Galbraith
2016-05-22 7:00 ` [patch] sched/fair: Move se->vruntime normalization state into struct sched_entity Mike Galbraith
2016-05-22 9:36 ` Peter Zijlstra
2016-05-22 9:52 ` Mike Galbraith
2016-05-22 10:33 ` Peter Zijlstra
2016-05-23 9:19 ` Peter Zijlstra
2016-05-23 9:40 ` Mike Galbraith
2016-05-23 10:13 ` Wanpeng Li
2016-05-23 10:26 ` Mike Galbraith
2016-05-23 12:28 ` Peter Zijlstra
2016-05-25 7:12 ` tip-bot for Peter Zijlstra [this message]
2016-05-22 6:50 ` [PATCH 2/3] sched,fair: Fix local starvation Wanpeng Li
2016-05-22 7:15 ` Mike Galbraith
2016-05-22 7:27 ` Wanpeng Li
2016-05-22 7:32 ` Mike Galbraith
2016-05-22 7:42 ` Wanpeng Li
2016-05-22 8:04 ` Mike Galbraith
2016-05-22 8:24 ` Wanpeng Li
2016-05-22 8:39 ` Mike Galbraith
2016-05-22 8:50 ` Wanpeng Li
2016-05-10 17:43 ` [PATCH 3/3] sched: Kill sched_class::task_waking Peter Zijlstra
2016-05-11 5:55 ` [PATCH 0/3] sched: Fix wakeup preemption regression Mike Galbraith
2016-05-12 9:56 ` Pavan Kondeti
2016-05-12 10:52 ` Matt Fleming
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=tip-b7e7ade34e6188bee2e3b0d42b51d25137d9e2a5@git.kernel.org \
--to=tipbot@zytor.com \
--cc=ahh@google.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=bsegall@google.com \
--cc=dave.hansen@linux.intel.com \
--cc=dvlasenk@redhat.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=matt@codeblueprint.co.uk \
--cc=mingo@kernel.org \
--cc=morten.rasmussen@arm.com \
--cc=oleg@redhat.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=pkondeti@codeaurora.org \
--cc=quentin.casasnovas@oracle.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=umgwanakikbuti@gmail.com \
/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).