From: "tip-bot2 for Qais Yousef" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>,
Qais Yousef <qais.yousef@arm.com>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>, x86 <x86@kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: [tip: sched/core] sched/rt: Optimize cpupri_find() on non-heterogenous systems
Date: Fri, 06 Mar 2020 14:42:04 -0000 [thread overview]
Message-ID: <158350572453.28353.9922528021955517987.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20200302132721.8353-4-qais.yousef@arm.com>
The following commit has been merged into the sched/core branch of tip:
Commit-ID: a1bd02e1f28b1939cac8c64072a0e578c3cbc345
Gitweb: https://git.kernel.org/tip/a1bd02e1f28b1939cac8c64072a0e578c3cbc345
Author: Qais Yousef <qais.yousef@arm.com>
AuthorDate: Mon, 02 Mar 2020 13:27:18
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Fri, 06 Mar 2020 12:57:27 +01:00
sched/rt: Optimize cpupri_find() on non-heterogenous systems
By introducing a new cpupri_find_fitness() function that takes the
fitness_fn as an argument and only called when asym_system static key is
enabled.
cpupri_find() is now a wrapper function that calls cpupri_find_fitness()
passing NULL as a fitness_fn, hence disabling the logic that handles
fitness by default.
LINK: https://lore.kernel.org/lkml/c0772fca-0a4b-c88d-fdf2-5715fcf8447b@arm.com/
Reported-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Qais Yousef <qais.yousef@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Fixes: 804d402fb6f6 ("sched/rt: Make RT capacity-aware")
Link: https://lkml.kernel.org/r/20200302132721.8353-4-qais.yousef@arm.com
---
kernel/sched/cpupri.c | 10 ++++++++--
kernel/sched/cpupri.h | 6 ++++--
kernel/sched/rt.c | 23 +++++++++++++++++++----
3 files changed, 31 insertions(+), 8 deletions(-)
diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c
index 1bcfa19..dd3f16d 100644
--- a/kernel/sched/cpupri.c
+++ b/kernel/sched/cpupri.c
@@ -94,8 +94,14 @@ static inline int __cpupri_find(struct cpupri *cp, struct task_struct *p,
return 1;
}
+int cpupri_find(struct cpupri *cp, struct task_struct *p,
+ struct cpumask *lowest_mask)
+{
+ return cpupri_find_fitness(cp, p, lowest_mask, NULL);
+}
+
/**
- * cpupri_find - find the best (lowest-pri) CPU in the system
+ * cpupri_find_fitness - find the best (lowest-pri) CPU in the system
* @cp: The cpupri context
* @p: The task
* @lowest_mask: A mask to fill in with selected CPUs (or NULL)
@@ -111,7 +117,7 @@ static inline int __cpupri_find(struct cpupri *cp, struct task_struct *p,
*
* Return: (int)bool - CPUs were found
*/
-int cpupri_find(struct cpupri *cp, struct task_struct *p,
+int cpupri_find_fitness(struct cpupri *cp, struct task_struct *p,
struct cpumask *lowest_mask,
bool (*fitness_fn)(struct task_struct *p, int cpu))
{
diff --git a/kernel/sched/cpupri.h b/kernel/sched/cpupri.h
index 32dd520..efbb492 100644
--- a/kernel/sched/cpupri.h
+++ b/kernel/sched/cpupri.h
@@ -19,8 +19,10 @@ struct cpupri {
#ifdef CONFIG_SMP
int cpupri_find(struct cpupri *cp, struct task_struct *p,
- struct cpumask *lowest_mask,
- bool (*fitness_fn)(struct task_struct *p, int cpu));
+ struct cpumask *lowest_mask);
+int cpupri_find_fitness(struct cpupri *cp, struct task_struct *p,
+ struct cpumask *lowest_mask,
+ bool (*fitness_fn)(struct task_struct *p, int cpu));
void cpupri_set(struct cpupri *cp, int cpu, int pri);
int cpupri_init(struct cpupri *cp);
void cpupri_cleanup(struct cpupri *cp);
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index f0071fa..29a8695 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -1504,7 +1504,7 @@ static void check_preempt_equal_prio(struct rq *rq, struct task_struct *p)
* let's hope p can move out.
*/
if (rq->curr->nr_cpus_allowed == 1 ||
- !cpupri_find(&rq->rd->cpupri, rq->curr, NULL, NULL))
+ !cpupri_find(&rq->rd->cpupri, rq->curr, NULL))
return;
/*
@@ -1512,7 +1512,7 @@ static void check_preempt_equal_prio(struct rq *rq, struct task_struct *p)
* see if it is pushed or pulled somewhere else.
*/
if (p->nr_cpus_allowed != 1 &&
- cpupri_find(&rq->rd->cpupri, p, NULL, NULL))
+ cpupri_find(&rq->rd->cpupri, p, NULL))
return;
/*
@@ -1691,6 +1691,7 @@ static int find_lowest_rq(struct task_struct *task)
struct cpumask *lowest_mask = this_cpu_cpumask_var_ptr(local_cpu_mask);
int this_cpu = smp_processor_id();
int cpu = task_cpu(task);
+ int ret;
/* Make sure the mask is initialized first */
if (unlikely(!lowest_mask))
@@ -1699,8 +1700,22 @@ static int find_lowest_rq(struct task_struct *task)
if (task->nr_cpus_allowed == 1)
return -1; /* No other targets possible */
- if (!cpupri_find(&task_rq(task)->rd->cpupri, task, lowest_mask,
- rt_task_fits_capacity))
+ /*
+ * If we're on asym system ensure we consider the different capacities
+ * of the CPUs when searching for the lowest_mask.
+ */
+ if (static_branch_unlikely(&sched_asym_cpucapacity)) {
+
+ ret = cpupri_find_fitness(&task_rq(task)->rd->cpupri,
+ task, lowest_mask,
+ rt_task_fits_capacity);
+ } else {
+
+ ret = cpupri_find(&task_rq(task)->rd->cpupri,
+ task, lowest_mask);
+ }
+
+ if (!ret)
return -1; /* No targets found */
/*
next prev parent reply other threads:[~2020-03-06 14:43 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-02 13:27 [PATCH v3 0/6] RT Capacity Awareness Fixes & Improvements Qais Yousef
2020-03-02 13:27 ` [PATCH v3 1/6] sched/rt: cpupri_find: Implement fallback mechanism for !fit case Qais Yousef
[not found] ` <20200304143200.GA13200@geo.homenetwork>
2020-03-04 15:18 ` Qais Yousef
2020-03-04 16:27 ` Steven Rostedt
2020-03-04 17:39 ` Qais Yousef
2020-03-04 18:54 ` Steven Rostedt
2020-03-04 20:01 ` Qais Yousef
2020-03-05 12:43 ` Qais Yousef
2020-03-10 14:22 ` Qais Yousef
2020-03-11 13:51 ` Steven Rostedt
2020-03-20 12:58 ` [tip: sched/core] sched/rt: cpupri_find: Trigger a full search as fallback tip-bot2 for Qais Yousef
2020-03-06 14:42 ` [tip: sched/core] sched/rt: cpupri_find: Implement fallback mechanism for !fit case tip-bot2 for Qais Yousef
2020-03-02 13:27 ` [PATCH v3 2/6] sched/rt: Re-instate old behavior in select_task_rq_rt Qais Yousef
2020-03-06 14:42 ` [tip: sched/core] sched/rt: Re-instate old behavior in select_task_rq_rt() tip-bot2 for Qais Yousef
2020-03-02 13:27 ` [PATCH v3 3/6] sched/rt: Optimize cpupri_find on non-heterogenous systems Qais Yousef
2020-03-06 14:42 ` tip-bot2 for Qais Yousef [this message]
2020-03-02 13:27 ` [PATCH v3 4/6] sched/rt: Allow pulling unfitting task Qais Yousef
[not found] ` <20200304145219.GA14173@geo.homenetwork>
2020-03-04 15:28 ` Qais Yousef
2020-03-06 14:42 ` [tip: sched/core] " tip-bot2 for Qais Yousef
2020-03-02 13:27 ` [PATCH v3 5/6] sched/rt: Remove unnecessary push for unfit tasks Qais Yousef
2020-03-06 14:42 ` [tip: sched/core] " tip-bot2 for Qais Yousef
2020-03-02 13:27 ` [PATCH v3 6/6] sched/rt: Fix pushing unfit tasks to a better CPU Qais Yousef
2020-03-06 17:51 ` Qais Yousef
2020-03-11 10:53 ` Pavan Kondeti
2020-03-11 14:11 ` Qais Yousef
2020-03-11 14:00 ` Steven Rostedt
2020-03-11 14:23 ` Qais Yousef
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=158350572453.28353.9922528021955517987.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=dietmar.eggemann@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=qais.yousef@arm.com \
--cc=x86@kernel.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).