From: Aaron Lu <aaron.lu@intel.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
<linux-kernel@vger.kernel.org>, Olivier Dion <odion@efficios.com>,
<michael.christie@oracle.com>
Subject: Re: [RFC PATCH v7] sched: Fix performance regression introduced by mm_cid
Date: Mon, 17 Apr 2023 22:35:32 +0800 [thread overview]
Message-ID: <20230417143532.GA491276@ziqianlu-desk2> (raw)
In-Reply-To: <5abacbf4-8101-7931-6dee-84f4f004240a@efficios.com>
On Mon, Apr 17, 2023 at 09:28:54AM -0400, Mathieu Desnoyers wrote:
> On 2023-04-17 06:18, Aaron Lu wrote:
> > On Sun, Apr 16, 2023 at 06:32:17PM -0400, Mathieu Desnoyers wrote:
> > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > > index 0d18c3969f90..9532cf1a2a44 100644
> > > --- a/kernel/sched/core.c
> > > +++ b/kernel/sched/core.c
> > > @@ -2084,8 +2084,10 @@ static inline void dequeue_task(struct rq *rq, struct task_struct *p, int flags)
> > > void activate_task(struct rq *rq, struct task_struct *p, int flags)
> > > {
> > > - if (task_on_rq_migrating(p))
> > > + if (task_on_rq_migrating(p)) {
> > > flags |= ENQUEUE_MIGRATED;
> > > + sched_mm_cid_migrate_to(rq, p);
> >
> >
> > I noticed you did this in previous version too but forgot to ask:
> > is it your intention to only invoke sched_mm_cid_migrate_to() for queued
> > tasks, i.e. tasks that are being migrated due to load/idle balance etc,
> > but not those tasks that migrated on wakeup?
>
> My intent is to also cover tasks migrated on wakeup.
>
> >
> > I saw you did the corresonding sched_mm_cid_migrate_from() in
> > set_task_cpu(), which on the other hand includes tasks that migrated due
> > to wakeup, so it kind of feel weird.
>
> I'm probably missing something here. AFAIU, when try_to_wake_up() moves the
> target process to a different cpu:
>
> cpu = select_task_rq(p, p->wake_cpu, wake_flags | WF_TTWU);
> if (task_cpu(p) != cpu) {
>
> it ends up calling ttwu_queue() with wake_flags |= WF_MIGRATED bit set.
>
> Then ttwu_queue() ends up calling ttwu_queue_wakelist(), which may initiate
> an IPI to the target cpu which executes sched_ttwu_pending().
> This function will take the target cpu's runqueue lock and call
> ttwu_do_activate() with wake_flags=WF_MIGRATED.
>
> The other path that ttwu_queue() can take is to issue ttwu_do_activate()
> with the target cpu's rq lock held.
>
> ttwu_do_activate() calls activate_task() with flags having ENQUEUE_MIGRATED
> set.
>
> OK I think I see what I missed here, I should change this to:
>
> void activate_task(struct rq *rq, struct task_struct *p, int flags)
> {
> if (task_on_rq_migrating(p))
> flags |= ENQUEUE_MIGRATED;
> if (flags & ENQUEUE_MIGRATED)
> sched_mm_cid_migrate_to(rq, p);
> [...]
>
> Because flags is received as input parameter as well.
>
> Do I get your meaning correctly ?
Yes, that's what I meant.
Tasks that have on_rq equals to TASK_ON_RQ_MIGRATING are only those
migrated by load balance etc., it doesn't apply to tasks that migrated
on wake up.
I think your new change looks correct.
Thanks,
Aaron
prev parent reply other threads:[~2023-04-17 14:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-16 22:32 Mathieu Desnoyers
2023-04-17 10:18 ` Aaron Lu
2023-04-17 13:28 ` Mathieu Desnoyers
2023-04-17 14:35 ` Aaron Lu [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=20230417143532.GA491276@ziqianlu-desk2 \
--to=aaron.lu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=michael.christie@oracle.com \
--cc=odion@efficios.com \
--cc=peterz@infradead.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®