From: Valentin Schneider <valentin.schneider@arm.com>
To: Peng Liu <iwtbavbm@gmail.com>, linux-kernel@vger.kernel.org
Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
qais.yousef@arm.com, morten.rasmussen@arm.com
Subject: Re: [PATCH] sched/fair: fix sgc->{min,max}_capacity miscalculate
Date: Wed, 1 Jan 2020 18:55:48 +0000 [thread overview]
Message-ID: <e41793bc-daaf-b224-1f3d-a3e468072592@arm.com> (raw)
In-Reply-To: <20200101141329.GA12809@iZj6chx1xj0e0buvshuecpZ>
On 01/01/2020 14:13, Peng Liu wrote:
>> ---
>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
>> index 08a233e97a01..9f6c015639ef 100644
>> --- a/kernel/sched/fair.c
>> +++ b/kernel/sched/fair.c
>> @@ -7773,8 +7773,8 @@ void update_group_capacity(struct sched_domain *sd, int cpu)
>> */
>>
>> for_each_cpu(cpu, sched_group_span(sdg)) {
>> - struct sched_group_capacity *sgc;
>> struct rq *rq = cpu_rq(cpu);
>> + unsigned long cpu_cap;
>>
>> /*
>> * build_sched_domains() -> init_sched_groups_capacity()
>> @@ -7787,15 +7787,15 @@ void update_group_capacity(struct sched_domain *sd, int cpu)
>> * This avoids capacity from being 0 and
>> * causing divide-by-zero issues on boot.
>> */
>> - if (unlikely(!rq->sd)) {
>> - capacity += capacity_of(cpu);
>> - } else {
>> - sgc = rq->sd->groups->sgc;
>> - capacity += sgc->capacity;
>> - }
>> + if (unlikely(!rq->sd))
>> + cpu_cap = capacity_of(cpu);
>
> --------------------------------------------------------------
>> + else
>> + cpu_cap = rq->sd->groups->sgc->capacity;
>
> sgc->capacity is the *sum* of all CPU's capacity in that group, right?
Right
> {min,max}_capacity are per CPU variables(*part* of a group). So we can't
> compare *part* to *sum*. Am I overlooking something? Thanks.
>
AIUI rq->sd->groups->sgc->capacity should be the capacity of the rq's CPU
(IOW the groups here should be made of single CPUs).
This should be true regardless of overlapping domains, since they sit on top
of the regular domains. Let me paint an example with a simple 2-core SMT2
system:
MC [ ]
SMT [ ][ ]
0 1 2 3
cpu_rq(0)->sd will point to the sched_domain of CPU0 at SMT level (it is the
"base domain", IOW the lowest domain in the topology hierarchy). Its groups
will be:
{0} ----> {1}
^ /
`-----'
and sd->groups will point at the group spanning the "local" CPU, in our case
CPU0, and thus here will be a group containing only CPU0.
I do not know why sched_group_capacity is used here however. As I understand
things, we could use cpu_capacity() unconditionally.
>> +
>> + min_capacity = min(cpu_cap, min_capacity);
>> + max_capacity = max(cpu_cap, max_capacity);
>>
>> - min_capacity = min(capacity, min_capacity);
>> - max_capacity = max(capacity, max_capacity);
>> + capacity += cpu_cap;
>> }
>> } else {
>> /*
next prev parent reply other threads:[~2020-01-01 18:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-31 3:51 Peng Liu
2020-01-01 5:56 ` Valentin Schneider
2020-01-01 14:13 ` Peng Liu
2020-01-01 18:55 ` Valentin Schneider [this message]
2020-01-03 14:21 ` Peng Liu
2020-01-03 14:44 ` Valentin Schneider
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=e41793bc-daaf-b224-1f3d-a3e468072592@arm.com \
--to=valentin.schneider@arm.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=iwtbavbm@gmail.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=morten.rasmussen@arm.com \
--cc=peterz@infradead.org \
--cc=qais.yousef@arm.com \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.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
all inboxes | Powered by JetHome®