Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1618442

[PATCH v2] cgroup: move cgroup_subsys_state parent field for cache locality

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From Todd Poynor <toddpoynor@gmail.com>
Newsgroups linux.kernel
Subject [PATCH v2] cgroup: move cgroup_subsys_state parent field for cache locality
Date Fri, 07 Apr 2017 03:50:01 +0200
Message-ID <ttrcd-se-1@gated-at.bofh.it> (permalink)
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=k5HQeNjxoMeMmxBcTN4U5e+gXiJ2fvn6/Pvjzwo1De4=; b=I8mvhksoz5E23Apbk2R3KPjbav2wwcj9ob1G2LRIHnbCgo7t5PruU58KcU83Wq8bcr DRMAX0NE1Udkg9FQoIH1V4j/JtBAPPqvtwqUIiSt8oisgsMry8Nv0jHq/i3+P+OuF75P QorUT/v+77cd44SRUxJgP8E6N/J9a3CDe7v5EoP+cN6NIzBj7TQK4cVKUKA2OY7gzL7c vHCwdoyQyyG6HzTvVajOqEqcQGhj3ydmGnAeidM6ske4utfdASeqMNyBKJj8XVO0++xe EplxjZkn7crDoK++yREs2mC/oJISEYYt++QThFxi4Aq7OpkqJXiQYBGVimbfIi31B7g/ X/TQ==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=k5HQeNjxoMeMmxBcTN4U5e+gXiJ2fvn6/Pvjzwo1De4=; b=ma2YNhXQEmmq5N1S4GPcreB1fG90j6NT8/Iijz7WzlDodnuZZLEIIx8M5mwjKsxuOH hEJ2/wBh+o3woXS2MM3vyDh4DpmBRHMmrDMuaNQW4Aur+Sk+5nwphVBYv+CudXf6TPoX 4E+WYf4YMNgVLeg5ddYjb8YeMUk/8TxpBRSHE4oP6PIk1lQjMqagagB2hVIvSCADw+xw likejflCj6f7dFZxGTL0zGRHjdWl6ehypq2Msx5X+eqyl36BXMCyb3PFAaHhQYDyBgAS 4LufGAsdgN/w27NilXUA4CmYNPNcezHpz2mGdOyfbZwZtoz1YTI5SYZAtrbGDQ2oDU/h fvGw==
X-Gm-Message-State AFeK/H2sDkfqclkuC8sKQt2c6tQZi1E5wbgxszR/7T9pJlqM66orUElvT7gOU9Oa9foF1g==
X-Received by 10.84.202.12 with SMTP id w12mr46202414pld.55.1491529726580; Thu, 06 Apr 2017 18:48:46 -0700 (PDT)
X-Google-Original-From Todd Poynor <todd@tjlinux.dyndns.org>
X-Mailer git-send-email 2.7.4
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 60
Organization linux.* mail to news gateway
X-Original-Cc cgroups@vger.kernel.org, Ingo Molnar <mingo@redhat.com>, Peter Zijlstra <peterz@infradead.org>, linux-kernel@vger.kernel.org, kernel-team@android.com, Todd Poynor <toddpoynor@google.com>
X-Original-Date Thu, 6 Apr 2017 18:47:57 -0700
X-Original-Message-ID <1491529677-707-1-git-send-email-todd@tjlinux.dyndns.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1618442

Show key headers only | View raw


From: Todd Poynor <toddpoynor@google.com>

Various structures embed a struct cgroup_subsys_state, typically at
the top of the containing structure.  It is common for code that
accesses the structures to perform operations that iterate over the
chain of parent css pointers, also accessing data in each containing
structure.  In particular, struct cpuacct is used by fairly hot code
paths in the scheduler such as cpuacct_charge().

Move the parent css pointer field to the end of the structure to
increase the chances of residing in the same cache line as the data
from the containing structure.

Signed-off-by: Todd Poynor <toddpoynor@google.com>
---
 include/linux/cgroup-defs.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

root_cpuacct fields .cpuusage and. css.parent show up as frequently-
accessed memory in separate cache lines (and usually the only thing
accessed in those cache lines until eviction) in armv8 simulations.
A quick search turned up struct blkcg, struct mem_cgroup, and
struct freezer as other examples using a similar struct layout and
access code.

Instead, could move the parent field to the top of css, and have hot
code paths use __cacheline_aligned with hot data prior to css... or
open to suggestions, thanks.

v2 fixes subject line.

diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h
index 6a3f850cabab..53c698207ad0 100644
--- a/include/linux/cgroup-defs.h
+++ b/include/linux/cgroup-defs.h
@@ -106,9 +106,6 @@ struct cgroup_subsys_state {
 	/* reference count - access via css_[try]get() and css_put() */
 	struct percpu_ref refcnt;
 
-	/* PI: the parent css */
-	struct cgroup_subsys_state *parent;
-
 	/* siblings list anchored at the parent's ->children */
 	struct list_head sibling;
 	struct list_head children;
@@ -138,6 +135,12 @@ struct cgroup_subsys_state {
 	/* percpu_ref killing and RCU release */
 	struct rcu_head rcu_head;
 	struct work_struct destroy_work;
+
+	/*
+	 * PI: the parent css.	Placed here for cache proximity to following
+	 * fields of the containing structure.
+	 */
+	struct cgroup_subsys_state *parent;
 };
 
 /*
-- 
2.12.2.715.g7642488e1d-goog

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH v2] cgroup: move cgroup_subsys_state parent field for cache locality Todd Poynor <toddpoynor@gmail.com> - 2017-04-07 03:50 +0200

csiph-web