mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, Aaron Lu <aaron.lu@intel.com>
Subject: Re: [RFC PATCH] sched: Fix performance regression introduced by mm_cid
Date: Mon, 3 Apr 2023 20:13:08 -0400	[thread overview]
Message-ID: <230301bb-58db-650d-8eb3-8915151685d1@efficios.com> (raw)
In-Reply-To: <20230403181342.210896-1-mathieu.desnoyers@efficios.com>

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.

> +		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,

Mathieu


-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com


  reply	other threads:[~2023-04-04  0:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-03 18:13 Mathieu Desnoyers
2023-04-04  0:13 ` Mathieu Desnoyers [this message]
2023-04-04  1:59   ` Aaron Lu
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=230301bb-58db-650d-8eb3-8915151685d1@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=aaron.lu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --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®