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>
Subject: Re: [RFC PATCH] sched: Fix performance regression introduced by mm_cid
Date: Tue, 4 Apr 2023 09:59:49 +0800 [thread overview]
Message-ID: <20230404015949.GA14939@ziqianlu-desk2> (raw)
In-Reply-To: <230301bb-58db-650d-8eb3-8915151685d1@efficios.com>
On Mon, Apr 03, 2023 at 08:13:08PM -0400, Mathieu Desnoyers wrote:
> On 2023-04-03 14:13, Mathieu Desnoyers wrote:
> [...]
> > +/*
> > + * Migration to dst cpu. Called with dst_rq lock held.
> > + */
> > +void sched_mm_cid_migrate_to(struct rq *dst_rq, struct task_struct *t, int src_cid)
> > +{
> > + struct mm_struct *mm = t->mm;
> > + int dst_cid, *dst_pcpu_cid;
> > +
> > + lockdep_assert_rq_held(dst_rq);
> > +
> > + if (!mm || src_cid == -1)
> > + return;
> > +
> > + dst_pcpu_cid = per_cpu_ptr(mm->pcpu_cid, cpu_of(dst_rq));
> > +
> > + /*
> > + * If destination cpu cid is greater than the source cpu cid, unset it
> > + * so it can be reallocated.
> > + */
> > + dst_cid = *dst_pcpu_cid;
> > + if (dst_cid == -1 || dst_cid < src_cid)
>
> Small detail: I plan to change this from "dst_cid < src_cid" to
> "dst_cid <= src_cid" in my next version of the patch to handle the
> unlikely case where a task would be migrated back and forth between
> two runqueues without being scheduled. It would be possible that the
> task's last_mm_cid is equal to the dst_cid here, in which case it
> would be better to leave the mm's destination cpu cid set.
>
This patch is still good regarding lock contention.
(I applied the above small change while testing)
> > + return;
> > + *dst_pcpu_cid = -1;
> > + /*
> > + * Put dst_cid if it is not currently in use, else it will be lazy put
> > + * on the next context switch.
> > + */
> > + if (dst_rq->curr->mm != mm)
> > + __mm_cid_put(mm, dst_cid);
> > +}
Thanks,
Aaron
next prev parent reply other threads:[~2023-04-04 2:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-03 18:13 [RFC PATCH] sched: Fix performance regression introduced by mm_cid Mathieu Desnoyers
2023-04-04 0:13 ` Mathieu Desnoyers
2023-04-04 1:59 ` Aaron Lu [this message]
2023-04-04 8:57 ` Peter Zijlstra
2023-04-04 9:10 ` Peter Zijlstra
2023-04-04 13:23 ` Mathieu Desnoyers
2023-04-04 9:05 ` Peter Zijlstra
2023-04-04 13:24 ` Mathieu Desnoyers
2023-04-04 9:21 ` Peter Zijlstra
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=20230404015949.GA14939@ziqianlu-desk2 \
--to=aaron.lu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@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