From: "Gautham R. Shenoy" <gautham.shenoy@amd.com>
To: Chen Yu <yu.c.chen@intel.com>
Cc: Aaron Lu <aaron.lu@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Ingo Molnar <mingo@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Juri Lelli <juri.lelli@redhat.com>,
Tim Chen <tim.c.chen@intel.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Valentin Schneider <vschneid@redhat.com>,
K Prateek Nayak <kprateek.nayak@amd.com>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 2/2] sched/fair: skip the cache hot CPU in select_idle_cpu()
Date: Wed, 13 Sep 2023 11:52:14 +0530 [thread overview]
Message-ID: <ZQFVFv4GcPOU+X7N@BLR-5CG11610CF.amd.com> (raw)
In-Reply-To: <ZP7SYu+gxlc/YjHu@chenyu5-mobl2>
On Mon, Sep 11, 2023 at 04:40:02PM +0800, Chen Yu wrote:
> Hi Aaron,
>
> thanks for the review,
>
> On 2023-09-11 at 15:26:29 +0800, Aaron Lu wrote:
[..snip..]
> > > @@ -6982,8 +6997,13 @@ static inline int find_idlest_cpu(struct sched_domain *sd, struct task_struct *p
> > > static inline int __select_idle_cpu(int cpu, struct task_struct *p)
> > > {
> > > if ((available_idle_cpu(cpu) || sched_idle_cpu(cpu)) &&
> > > - sched_cpu_cookie_match(cpu_rq(cpu), p))
> > > + sched_cpu_cookie_match(cpu_rq(cpu), p)) {
> > > + if (sched_feat(SIS_CACHE) &&
> > > + sched_clock_cpu(cpu) < cpu_rq(cpu)->cache_hot_timeout)
> > > + return -1;
> > > +
> >
> > Maybe introduce a new function that also considers rq->cache_hot_timeout,
> > like available_idle_cpu_migrate() so that above and below logic can be
> > simplified a bit?
> >
>
> Yes, that would be simpler, I'll do in next version.
>
> > I was thinking to simply add that rq->cache_hot_timeout check to
> > available_idle_cpu() but then a long sleeping task could be forced to
> > migrate if its prev_cpu happens to just deschedule a task that sets rq's
> > cache_hot_timeout. I guess that's why you chose to only change the idle
> > semantic in select_idle_cpu() but not in select_idle_sibling()?
> >
>
> Yes, sort of. And the reason I did not put this cache hot check in available_idle_cpu()
> or idle_cpu() was mainly because these APIs are generic and could be invoked by select_idle_sibling().
> If the task fall asleep and woken up quickly, its previous idle CPU will also be skipped,
> thus no one could use this CPU within the cache hot period, including the cache-hot task
> itself.
This happens even with this patch right? It is possible for a task p1
whose avg sleep time is "t" to go to sleep which causes its CPU to go
idle. When it wakes up after a time t' < t, the logic above skips the
idle CPU because it is still cache-hot, despite the fact that it is
cache hot for p1!
Have you considered recording p1's identity in the
rq->cache_hot_sleeper so that in select_task_rq_fair(), we can simply
return the previous CPU if it is cache hot and the wakee is
rq->cache_hot_sleeper, thus avoiding the whole select_idle_sibling
scan.
>
> thanks,
> Chenyu
--
Thanks and Regards
gautham.
next prev parent reply other threads:[~2023-09-13 6:22 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-11 2:49 [RFC PATCH 0/2] Makes it easier for the wakee to choose previous CPU Chen Yu
2023-09-11 2:49 ` [RFC PATCH 1/2] sched/fair: Record the average sleep time of a task Chen Yu
2023-09-11 2:50 ` [RFC PATCH 2/2] sched/fair: skip the cache hot CPU in select_idle_cpu() Chen Yu
2023-09-11 7:26 ` Aaron Lu
2023-09-11 8:40 ` Chen Yu
2023-09-13 6:22 ` Gautham R. Shenoy [this message]
2023-09-13 7:25 ` Chen Yu
2023-09-14 7:06 ` Gautham R. Shenoy
2023-09-14 12:09 ` Chen Yu
2023-09-15 15:18 ` Gautham R. Shenoy
2023-09-19 9:01 ` Chen Yu
2023-09-11 8:29 ` K Prateek Nayak
2023-09-11 10:19 ` Chen Yu
2023-09-12 3:05 ` K Prateek Nayak
2023-09-12 12:32 ` Chen Yu
2023-09-12 14:26 ` K Prateek Nayak
2023-09-13 2:57 ` Chen Yu
2023-09-14 4:13 ` K Prateek Nayak
2023-09-14 11:01 ` Chen Yu
2023-09-15 3:21 ` K Prateek Nayak
2023-09-12 9:39 ` Mike Galbraith
2023-09-12 14:51 ` Chen Yu
2023-09-12 6:32 ` Mike Galbraith
2023-09-11 15:26 ` Mathieu Desnoyers
2023-09-11 15:43 ` Mathieu Desnoyers
2023-09-12 11:53 ` Chen Yu
2023-09-12 14:06 ` Mathieu Desnoyers
2023-09-12 14:14 ` Chen Yu
2023-09-12 15:18 ` Mathieu Desnoyers
2023-09-13 3:02 ` Chen Yu
2023-09-20 12:34 ` Chen Yu
2023-09-14 5:30 ` K Prateek Nayak
2023-09-14 10:43 ` Chen Yu
2023-09-15 3:37 ` K Prateek Nayak
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=ZQFVFv4GcPOU+X7N@BLR-5CG11610CF.amd.com \
--to=gautham.shenoy@amd.com \
--cc=aaron.lu@intel.com \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tim.c.chen@intel.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.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