linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Davidlohr Bueso <dave@stgolabs.net>
To: akpm@linux-foundation.org
Cc: manfred@colorfullife.com, dave@stgolabs.net,
	linux-kernel@vger.kernel.org, Davidlohr Bueso <dbueso@suse.de>
Subject: [PATCH 3/4] sysv,ipc: cacheline align kern_ipc_perm
Date: Thu,  9 Feb 2017 12:53:01 -0800	[thread overview]
Message-ID: <1486673582-6979-4-git-send-email-dave@stgolabs.net> (raw)
In-Reply-To: <1486673582-6979-1-git-send-email-dave@stgolabs.net>

Assign 'struct kern_ipc_perm' its own cacheline to avoid false
sharing with sysv ipc calls. While the structure itself is rather
read-mostly throughout the lifespan of ipc, the spinlock causes
most of the invalidations. One example is 31a7c4746e9 (ipc/sem.c:
cacheline align the ipc spinlock for semaphores). Therefore,
extend this to all ipc.

The effect of cacheline alignment on sems can be seen in sembench,
which deals mostly with semtimedop wait/wakes is seen to improve raw
throughput (worker loops) between 8 to 12% on a 24-core x86 with
over 4 threads.

Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
 include/linux/ipc.h | 7 +++----
 include/linux/sem.h | 3 +--
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/include/linux/ipc.h b/include/linux/ipc.h
index 9d84942ae2e5..71fd92d81b26 100644
--- a/include/linux/ipc.h
+++ b/include/linux/ipc.h
@@ -8,8 +8,7 @@
 #define IPCMNI 32768  /* <= MAX_INT limit for ipc arrays (including sysctl changes) */
 
 /* used by in-kernel data structures */
-struct kern_ipc_perm
-{
+struct kern_ipc_perm {
 	spinlock_t	lock;
 	bool		deleted;
 	int		id;
@@ -18,9 +17,9 @@ struct kern_ipc_perm
 	kgid_t		gid;
 	kuid_t		cuid;
 	kgid_t		cgid;
-	umode_t		mode; 
+	umode_t		mode;
 	unsigned long	seq;
 	void		*security;
-};
+} ____cacheline_aligned_in_smp;
 
 #endif /* _LINUX_IPC_H */
diff --git a/include/linux/sem.h b/include/linux/sem.h
index 4fc222f8755d..9edec926e9d9 100644
--- a/include/linux/sem.h
+++ b/include/linux/sem.h
@@ -10,8 +10,7 @@ struct task_struct;
 
 /* One sem_array data structure for each set of semaphores in the system. */
 struct sem_array {
-	struct kern_ipc_perm	____cacheline_aligned_in_smp
-				sem_perm;	/* permissions .. see ipc.h */
+	struct kern_ipc_perm	sem_perm;	/* permissions .. see ipc.h */
 	time_t			sem_ctime;	/* last change time */
 	struct sem		*sem_base;	/* ptr to first semaphore in array */
 	struct list_head	pending_alter;	/* pending operations */
-- 
2.6.6

  parent reply	other threads:[~2017-02-09 20:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-09 20:52 [PATCH -tip 0/4] ipc/shm: moar updates for v4.11 Davidlohr Bueso
2017-02-09 20:52 ` [PATCH 1/4] ipc/shm: do not check for MAP_POPULATE Davidlohr Bueso
2017-02-10  2:15   ` Hugh Dickins
2017-02-13 18:14     ` Davidlohr Bueso
2017-02-09 20:53 ` [PATCH 2/4] ipc/shm: some shmat cleanups Davidlohr Bueso
2017-02-09 20:53 ` Davidlohr Bueso [this message]
2017-02-09 20:53 ` [PATCH 4/4] mm,hugetlb: compute page_size_log properly Davidlohr Bueso
2017-02-10 10:20   ` Michal Hocko
2017-02-10 16:51     ` Davidlohr Bueso
2017-02-20 16:11       ` Michal Hocko
2017-02-22 16:03         ` Davidlohr Bueso
2017-02-22 16:11           ` Michal Hocko

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=1486673582-6979-4-git-send-email-dave@stgolabs.net \
    --to=dave@stgolabs.net \
    --cc=akpm@linux-foundation.org \
    --cc=dbueso@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=manfred@colorfullife.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;
as well as URLs for NNTP newsgroup(s).