mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Swapnil Sapkal <Swapnil.Sapkal@amd.com>
Cc: linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org,
	Aaron Lu <aaron.lu@intel.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	x86@kernel.org
Subject: Re: [tip: sched/core] sched: Fix performance regression introduced by mm_cid
Date: Tue, 20 Jun 2023 11:11:39 +0200	[thread overview]
Message-ID: <20230620091139.GZ4253@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <09e0f469-a3f7-62ef-75a1-e64cec2dcfc5@amd.com>

On Tue, Jun 20, 2023 at 01:44:32PM +0530, Swapnil Sapkal wrote:
> Hello Mathieu,
> 
> On 4/22/2023 1:13 PM, tip-bot2 for Mathieu Desnoyers wrote:
> > The following commit has been merged into the sched/core branch of tip:
> > 
> > Commit-ID:     223baf9d17f25e2608dbdff7232c095c1e612268
> > Gitweb:        https://git.kernel.org/tip/223baf9d17f25e2608dbdff7232c095c1e612268
> > Author:        Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> > AuthorDate:    Thu, 20 Apr 2023 10:55:48 -04:00
> > Committer:     Peter Zijlstra <peterz@infradead.org>
> > CommitterDate: Fri, 21 Apr 2023 13:24:20 +02:00
> > 
> > sched: Fix performance regression introduced by mm_cid
> > 
> > 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 invocation to
> > sched_mm_cid_migrate_to() (with destination runqueue lock held) in
> > activate_task() for migrating tasks. If the destination cpu's mm_cid is
> > unset, and if the source runqueue is not actively using its mm_cid, then
> > the source cpu's mm_cid is moved to the destination cpu on migration.
> > 
> > Introduce 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 task work also clears all
> > mm_cids which are greater or equal to the Hamming weight of the mm
> > cidmask to keep concurrency ids compact.
> > 
> > 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.
> > 
> > Fixes: af7f588d8f73 ("sched: Introduce per-memory-map concurrency ID")
> > Reported-by: Aaron Lu <aaron.lu@intel.com>
> > Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> > Tested-by: Aaron Lu <aaron.lu@intel.com>
> > Link: https://lore.kernel.org/lkml/20230327080502.GA570847@ziqianlu-desk2/
> 
> I run standard benchmarks as a part of kernel performance regression
> testing. When I run these benchmarks against v6.3.0 to v6.4-rc1,
> I have seen performance regression in hackbench running with threads. When I did
> git bisect it pointed to this commit and reverting this commit helps regains
> the performance. This regression is not seen with hackbench processes.

Well, *this* commit was supposed to help fix the horrible contention on
cid_lock that was introduced with af7f588d8f73.

> Following are the results from 1 Socket 4th generation EPYC
> Processor(1 X 96C/192T) configured in NPS1 mode. This regression
> becomes more severe as the number of core count increases.
> 
> The numbers on a 1 Socket Bergamo (1 X 128 cores/256 threads) is significantly worse.
> 
> Threads:
> 
> Test:             With-mmcid-patch        Without-mmcid-patch
>  1-groups:         5.23 (0.00 pct)         4.61 (+11.85 pct)
>  2-groups:         4.99 (0.00 pct)         4.72 (+5.41 pct)
>  4-groups:         5.96 (0.00 pct)         4.87 (+18.28 pct)
>  8-groups:         6.58 (0.00 pct)         5.44 (+17.32 pct)
> 16-groups:        11.48 (0.00 pct)         8.07 (+29.70 pct)

I'm really confused, so you're saying that having a process wide
spinlock is better than what this patch does? Or are you testing against
something without mm-cid entirely?

  reply	other threads:[~2023-06-20  9:12 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-22  7:43 tip-bot2 for Mathieu Desnoyers
2023-06-20  8:14 ` Swapnil Sapkal
2023-06-20  9:11   ` Peter Zijlstra [this message]
2023-06-20 10:35     ` Swapnil Sapkal
2023-06-20 10:51       ` Mathieu Desnoyers
2023-06-21 16:36         ` Swapnil Sapkal
2023-06-21 18:51           ` Mathieu Desnoyers
2023-06-21 21:41             ` Mathieu Desnoyers
2023-06-21 23:59               ` John Johansen
2023-06-22 14:33                 ` Mathieu Desnoyers
2023-06-22 16:09                   ` John Johansen
2023-06-23  6:52                   ` Sebastian Andrzej Siewior
2023-06-23  6:37                 ` Sebastian Andrzej Siewior
2023-06-23  7:16                   ` John Johansen
2023-06-23  8:15                     ` Sebastian Andrzej Siewior
2023-06-23  7:35                   ` John Johansen
2023-06-23  8:17                     ` Sebastian Andrzej Siewior
2023-07-14  6:02             ` Swapnil Sapkal
2023-07-14 14:55               ` Mathieu Desnoyers
2023-07-18  6:01                 ` Swapnil Sapkal
2023-06-23 13:12   ` Linux regression tracking #adding (Thorsten Leemhuis)

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=20230620091139.GZ4253@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=Swapnil.Sapkal@amd.com \
    --cc=aaron.lu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=x86@kernel.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®