mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Deng Pan <pan.deng@intel.com>
To: tim.c.chen@intel.com, peterz@infradead.org
Cc: vincent.guittot@linaro.org, linux-kernel@vger.kernel.org,
	tianyou.li@intel.com, yu.ma@intel.com, lipeng.zhu@intel.com,
	Deng Pan <pan.deng@intel.com>,
	Tim Chen <tim.c.chen@linux.intel.com>
Subject: [PATCH] sched/task_group: Re-layout structure to reduce false sharing
Date: Fri, 26 May 2023 10:50:44 +0800	[thread overview]
Message-ID: <20230526025044.1660438-1-pan.deng@intel.com> (raw)

When running UnixBench/Pipe-based Context Switching case, we observed
high false sharing for accessing ‘load_avg’ against rt_se and rt_rq.

Pipe-based Context Switching case is a typical suspend/wakeup scenario,
in which load_avg is frequenly loaded and stored, at the meantime,
rt_se and rt_rq are frequently loaded. Unfortunately, they are in the
same cacheline.

This change re-layouts the structure:
1.  Move rt_se and rt_rq to a 2nd cacheline.
2.  Keep ‘parent’ field in the 2nd cacheline since it is also accessed
very often when cgroups are nested, thanks Tim Chen for providing the
insight.

With this change, on Intel Icelake 2 sockets 80C/160T platform, based
on v6.0-rc6, the 160 parallel score is improved ~5%, perf tool reported
rt_se and rt_rq access cycles are reduced from ~6.0% to ~0.1%.
Reviewed-by: Tim Chen <tim.c.chen@linux.intel.com>
Signed-off-by: Deng Pan <pan.deng@intel.com>
---
 kernel/sched/sched.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
index ec7b3e0a2b20..a1dd289511b2 100644
--- a/kernel/sched/sched.h
+++ b/kernel/sched/sched.h
@@ -389,6 +389,13 @@ struct task_group {
 #endif
 #endif
 
+	struct rcu_head		rcu;
+	struct list_head	list;
+
+	struct list_head	siblings;
+	struct list_head	children;
+	struct task_group	*parent;
+
 #ifdef CONFIG_RT_GROUP_SCHED
 	struct sched_rt_entity	**rt_se;
 	struct rt_rq		**rt_rq;
@@ -396,13 +403,6 @@ struct task_group {
 	struct rt_bandwidth	rt_bandwidth;
 #endif
 
-	struct rcu_head		rcu;
-	struct list_head	list;
-
-	struct task_group	*parent;
-	struct list_head	siblings;
-	struct list_head	children;
-
 #ifdef CONFIG_SCHED_AUTOGROUP
 	struct autogroup	*autogroup;
 #endif
-- 
2.39.1


                 reply	other threads:[~2023-05-26  2:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230526025044.1660438-1-pan.deng@intel.com \
    --to=pan.deng@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lipeng.zhu@intel.com \
    --cc=peterz@infradead.org \
    --cc=tianyou.li@intel.com \
    --cc=tim.c.chen@intel.com \
    --cc=tim.c.chen@linux.intel.com \
    --cc=vincent.guittot@linaro.org \
    --cc=yu.ma@intel.com \
    /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®