From: Gregory Haskins <gregory.haskins@gmail.com>
To: Gregory Haskins <ghaskins@novell.com>
Cc: linux-kernel@vger.kernel.org, peterz@infradead.org,
rostedt@goodmis.org, rusty@rustcorp.com.au, maxk@qualcomm.com,
mingo@elte.hu
Subject: Re: [PATCH 1/2] [RESEND] sched: Fully integrate cpus_active_map and root-domain code
Date: Thu, 30 Jul 2009 11:10:50 -0400 [thread overview]
Message-ID: <4A71B7FA.4030509@gmail.com> (raw)
In-Reply-To: <4A71B5DD.4010503@novell.com>
[-- Attachment #1: Type: text/plain, Size: 3874 bytes --]
Gregory Haskins wrote:
> Gregory Haskins wrote:
>> (Applies to 2.6.31-rc4)
>>
>> [
>> This patch was originaly sent about a year ago, but got dropped
>> presumably by accident. Here is the original thread.
>>
>> http://lkml.org/lkml/2008/7/22/281
>>
>> At that time, Peter and Max acked it. It has now been forward
>> ported to the new cpumask interface. I will be so bold as to
>> carry their acks forward since the basic logic is the same.
>> However, a new acknowledgement, if they have the time to review,
>> would be ideal.
>>
>> I have tested this patch on a 4-way system using Max's recommended
>> "echo 0|1 > cpu1/online" technique and it appears to work properly
>> ]
>>
>> What: Reflect "active" cpus in the rq->rd->online field, instead of the
>> online_map.
>>
>> Motivation: Things that use the root-domain code (such as cpupri) only
>> care about cpus classified as "active" anyway. By synchronizing the
>> root-domain state with the active map, we allow several optimizations.
>>
>> For instance, we can remove an extra cpumask_and from the scheduler
>> hotpath by utilizing rq->rd->online (since it is now a cached version
>> of cpu_active_map & rq->rd->span).
>>
>> Signed-off-by: Gregory Haskins <ghaskins@novell.com>
>> Acked-by: Peter Zijlstra <peterz@infradead.org>
>> Acked-by: Max Krasnyansky <maxk@qualcomm.com>
>> ---
>>
>> kernel/sched.c | 2 +-
>> kernel/sched_fair.c | 10 +++++++---
>> kernel/sched_rt.c | 7 -------
>> 3 files changed, 8 insertions(+), 11 deletions(-)
>>
>> diff --git a/kernel/sched.c b/kernel/sched.c
>> index 1a104e6..38a1526 100644
>> --- a/kernel/sched.c
>> +++ b/kernel/sched.c
>> @@ -7874,7 +7874,7 @@ static void rq_attach_root(struct rq *rq, struct root_domain *rd)
>> rq->rd = rd;
>>
>> cpumask_set_cpu(rq->cpu, rd->span);
>> - if (cpumask_test_cpu(rq->cpu, cpu_online_mask))
>> + if (cpumask_test_cpu(rq->cpu, cpu_active_mask))
>> set_rq_online(rq);
>>
>> spin_unlock_irqrestore(&rq->lock, flags);
>> diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
>> index 9ffb2b2..2b9cae6 100644
>> --- a/kernel/sched_fair.c
>> +++ b/kernel/sched_fair.c
>> @@ -1040,17 +1040,21 @@ static void yield_task_fair(struct rq *rq)
>> * search starts with cpus closest then further out as needed,
>> * so we always favor a closer, idle cpu.
>> * Domains may include CPUs that are not usable for migration,
>> - * hence we need to mask them out (cpu_active_mask)
>> + * hence we need to mask them out (rq->rd->online)
>> *
>> * Returns the CPU we should wake onto.
>> */
>> #if defined(ARCH_HAS_SCHED_WAKE_IDLE)
>> +
>> +#define cpu_rd_active(cpu, rq) cpumask_test_cpu(cpu, rq->rd->online)
>> +
>> static int wake_idle(int cpu, struct task_struct *p)
>> {
>> struct sched_domain *sd;
>> int i;
>> unsigned int chosen_wakeup_cpu;
>> int this_cpu;
>> + struct rq *task_rq = task_rq(p);
>>
>> /*
>> * At POWERSAVINGS_BALANCE_WAKEUP level, if both this_cpu and prev_cpu
>> @@ -1083,10 +1087,10 @@ static int wake_idle(int cpu, struct task_struct *p)
>> for_each_domain(cpu, sd) {
>> if ((sd->flags & SD_WAKE_IDLE)
>> || ((sd->flags & SD_WAKE_IDLE_FAR)
>> - && !task_hot(p, task_rq(p)->clock, sd))) {
>> + && !task_hot(p, task_rq->clock, sd))) {
>> for_each_cpu_and(i, sched_domain_span(sd),
>> &p->cpus_allowed) {
>
> Hmm, something got suboptimal in translation from the original patch.
>
> This would be better expressed as:
>
> for_each_cpu_and(i, rq->rd->online, &p->cpus_allowed) {
> if (idle_cpu(i)...
> }
NM. My first instinct was correct.
We need the result of sd->span, cpus_allowed, and active_map. The
submitted logic (or the original) is correct, and my comment above is wrong.
Sorry for the noise,
-Greg
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 267 bytes --]
next prev parent reply other threads:[~2009-07-30 15:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-30 14:57 [PATCH 0/2] scheduler fixes Gregory Haskins
2009-07-30 14:57 ` [PATCH 1/2] [RESEND] sched: Fully integrate cpus_active_map and root-domain code Gregory Haskins
2009-07-30 15:01 ` Gregory Haskins
2009-07-30 15:10 ` Gregory Haskins [this message]
2009-08-02 13:13 ` [tip:sched/core] " tip-bot for Gregory Haskins
2009-07-30 14:57 ` [PATCH 2/2] sched: fix race in cpupri introduced by cpumask_var changes Gregory Haskins
2009-08-02 13:12 ` [tip:sched/core] sched: Fix " tip-bot for Gregory Haskins
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=4A71B7FA.4030509@gmail.com \
--to=gregory.haskins@gmail.com \
--cc=ghaskins@novell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maxk@qualcomm.com \
--cc=mingo@elte.hu \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=rusty@rustcorp.com.au \
/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