From: Yicong Yang <yangyicong@huawei.com>
To: Chen Yu <yu.c.chen@intel.com>,
"Gautham R. Shenoy" <gautham.shenoy@amd.com>
Cc: <yangyicong@hisilicon.com>, <peterz@infradead.org>,
<mingo@redhat.com>, <juri.lelli@redhat.com>,
<vincent.guittot@linaro.org>, <dietmar.eggemann@arm.com>,
<tim.c.chen@linux.intel.com>, <mgorman@suse.de>,
<vschneid@redhat.com>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>, <rostedt@goodmis.org>,
<bsegall@google.com>, <bristot@redhat.com>,
<prime.zeng@huawei.com>, <jonathan.cameron@huawei.com>,
<ego@linux.vnet.ibm.com>, <srikar@linux.vnet.ibm.com>,
<linuxarm@huawei.com>, <21cnbao@gmail.com>,
<kprateek.nayak@amd.com>, <wuyun.abel@bytedance.com>,
Barry Song <song.bao.hua@hisilicon.com>
Subject: Re: [PATCH v8 2/2] sched/fair: Scan cluster before scanning LLC in wake-up path
Date: Tue, 13 Jun 2023 15:44:50 +0800 [thread overview]
Message-ID: <c98baaab-aee6-6983-bc29-836488f73d8d@huawei.com> (raw)
In-Reply-To: <ZIariDV8sztoPbv0@chenyu5-mobl2.ccr.corp.intel.com>
On 2023/6/12 13:22, Chen Yu wrote:
> On 2023-06-12 at 10:31:39 +0530, Gautham R. Shenoy wrote:
>> Hello Yicong,
>>
>>
>> On Tue, May 30, 2023 at 03:02:53PM +0800, Yicong Yang wrote:
>>> From: Barry Song <song.bao.hua@hisilicon.com>
>> [..snip..]
>>
>>> @@ -7103,7 +7127,7 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
>>> bool has_idle_core = false;
>>> struct sched_domain *sd;
>>> unsigned long task_util, util_min, util_max;
>>> - int i, recent_used_cpu;
>>> + int i, recent_used_cpu, prev_aff = -1;
>>>
>>> /*
>>> * On asymmetric system, update task utilization because we will check
>>> @@ -7130,8 +7154,11 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
>>> */
>>> if (prev != target && cpus_share_cache(prev, target) &&
>>> (available_idle_cpu(prev) || sched_idle_cpu(prev)) &&
>>> - asym_fits_cpu(task_util, util_min, util_max, prev))
>>> - return prev;
>>> + asym_fits_cpu(task_util, util_min, util_max, prev)) {
>>> + if (cpus_share_lowest_cache(prev, target))
>>
>> For platforms without the cluster domain, the cpus_share_lowest_cache
>> check is a repetition of the cpus_share_cache(prev, target) check. Can
>> we avoid this using a static branch check for cluster ?
>>
>>
> Sounds good.
>>> + return prev;
>>> + prev_aff = prev;
>>> + }
>>>
>>> /*
>>> * Allow a per-cpu kthread to stack with the wakee if the
>>> @@ -7158,7 +7185,10 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
>>> (available_idle_cpu(recent_used_cpu) || sched_idle_cpu(recent_used_cpu)) &&
>>> cpumask_test_cpu(p->recent_used_cpu, p->cpus_ptr) &&
>>> asym_fits_cpu(task_util, util_min, util_max, recent_used_cpu)) {
>>> - return recent_used_cpu;
>>> + if (cpus_share_lowest_cache(recent_used_cpu, target))
>>
>> Same here.
>>
>>> + return recent_used_cpu;
>>> + } else {
>>> + recent_used_cpu = -1;
>>> }
>>>
>>> /*
>>> @@ -7199,6 +7229,17 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)
>>> if ((unsigned)i < nr_cpumask_bits)
>>> return i;
>>>
>>> + /*
>>> + * For cluster machines which have lower sharing cache like L2 or
>>> + * LLC Tag, we tend to find an idle CPU in the target's cluster
>>> + * first. But prev_cpu or recent_used_cpu may also be a good candidate,
>>> + * use them if possible when no idle CPU found in select_idle_cpu().
>>> + */
>>> + if ((unsigned int)prev_aff < nr_cpumask_bits)
>>> + return prev_aff;
>>
>> Shouldn't we check if prev_aff (and the recent_used_cpu below) is
>> still idle ?
>>
>>
> When we reach here, the target is non-idle, and the prev_aff is idle.
> Although there is a race condition that prev_aff becomes non-idle
> and target becomes idle after select_idle_cpu(), this window might be
> small IMO.
>
Yes. Races here but adding a check won't cost much, so it's ok for me
to check it or not.
Thanks.
prev parent reply other threads:[~2023-06-13 7:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-30 7:02 [PATCH v8 0/2] sched/fair: Scan cluster before scanning LLC in wake-up path Yicong Yang
2023-05-30 7:02 ` [PATCH v8 1/2] sched: Add per_cpu cluster domain info and cpus_share_lowest_cache API Yicong Yang
2023-05-30 11:38 ` Peter Zijlstra
2023-05-30 13:24 ` Yicong Yang
2023-05-30 7:02 ` [PATCH v8 2/2] sched/fair: Scan cluster before scanning LLC in wake-up path Yicong Yang
2023-05-30 11:55 ` Peter Zijlstra
2023-05-30 14:39 ` Yicong Yang
2023-05-31 8:21 ` Yicong Yang
2023-06-08 3:26 ` Chen Yu
2023-06-08 6:45 ` Yicong Yang
2023-06-09 10:50 ` Chen Yu
2023-06-13 7:36 ` Yicong Yang
2023-06-13 8:09 ` Yicong Yang
2023-06-13 12:44 ` Chen Yu
2023-06-15 7:59 ` Yicong Yang
2023-06-16 6:00 ` Chen Yu
2023-06-12 5:01 ` Gautham R. Shenoy
2023-06-12 5:22 ` Chen Yu
2023-06-13 7:44 ` Yicong Yang [this message]
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=c98baaab-aee6-6983-bc29-836488f73d8d@huawei.com \
--to=yangyicong@huawei.com \
--cc=21cnbao@gmail.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=ego@linux.vnet.ibm.com \
--cc=gautham.shenoy@amd.com \
--cc=jonathan.cameron@huawei.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=prime.zeng@huawei.com \
--cc=rostedt@goodmis.org \
--cc=song.bao.hua@hisilicon.com \
--cc=srikar@linux.vnet.ibm.com \
--cc=tim.c.chen@linux.intel.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=wuyun.abel@bytedance.com \
--cc=yangyicong@hisilicon.com \
--cc=yu.c.chen@intel.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).