mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 v6] sched: Fix performance regression introduced by mm_cid
Date: Fri, 14 Apr 2023 22:07:53 +0800	[thread overview]
Message-ID: <20230414140753.GA279103@ziqianlu-desk2> (raw)
In-Reply-To: <20230413223356.17195-1-mathieu.desnoyers@efficios.com>

On Thu, Apr 13, 2023 at 06:33:56PM -0400, Mathieu Desnoyers wrote:
> Introduce per-mm/cpu current concurrency id (mm_cid) to fix a PostgreSQL
> sysbench regression reported by Aaron Lu.
> 
> Keep track of the currently allocated mm_cid for each mm/cpu rather than
> freeing them immediately on context switch. This eliminates most atomic
> operations when context switching back and forth between threads
> belonging to different memory spaces in multi-threaded scenarios (many
> processes, each with many threads). The per-mm/per-cpu mm_cid values are
> serialized by their respective runqueue locks.
> 
> Thread migration is handled by introducing a task-work executed
> periodically, similarly to NUMA work, which delays reclaim of cid
> values when they are unused for a period of time.
> 
> Keep track of the allocation time for each per-cpu cid, and let the task
> work clear them when they are observed to be older than
> SCHED_MM_CID_PERIOD_NS and unused.
> 
> This fix is going for a task-work and delayed reclaim approach rather
> than adding hooks to migrate-from and migrate-to because migration
> happens to be a hot path for various real-world workloads.
> 
> Because we want to ensure the mm_cid converges towards the smaller
> values as migrations happen, the prior optimization that was done when
> context switching between threads belonging to the same mm is removed,
> because it could delay the lazy release of the destination runqueue
> mm_cid after it has been replaced by a migration. Removing this prior
> optimization is not an issue performance-wise because the introduced
> per-mm/per-cpu mm_cid tracking also covers this more specific case.

I was wondering, if a thread was migrated to all possible cpus in the
SCHED_MM_CID_PERIOD_NS window, its mm_cidmask will be full. For user
space, if cid can be the full set of cpus, then it will have to prepare
storage for the full set. Then what's the point of doing compaction? Or
do I understand it wrong?

  parent reply	other threads:[~2023-04-14 14:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13 22:33 Mathieu Desnoyers
2023-04-14  9:43 ` Aaron Lu
2023-04-14 14:07 ` Aaron Lu [this message]
2023-04-14 14:09   ` Mathieu Desnoyers

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=20230414140753.GA279103@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®