Commit 60f3e00d authored by Davidlohr Bueso's avatar Davidlohr Bueso Committed by Linus Torvalds

sysv,ipc: cacheline align kern_ipc_perm

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
commit 31a7c474 ("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.

Link: http://lkml.kernel.org/r/1486673582-6979-4-git-send-email-dave@stgolabs.netSigned-off-by: default avatarDavidlohr Bueso <dbueso@suse.de>
Cc: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f0cb8802
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
#define IPCMNI 32768 /* <= MAX_INT limit for ipc arrays (including sysctl changes) */ #define IPCMNI 32768 /* <= MAX_INT limit for ipc arrays (including sysctl changes) */
/* used by in-kernel data structures */ /* used by in-kernel data structures */
struct kern_ipc_perm struct kern_ipc_perm {
{
spinlock_t lock; spinlock_t lock;
bool deleted; bool deleted;
int id; int id;
...@@ -21,6 +20,6 @@ struct kern_ipc_perm ...@@ -21,6 +20,6 @@ struct kern_ipc_perm
umode_t mode; umode_t mode;
unsigned long seq; unsigned long seq;
void *security; void *security;
}; } ____cacheline_aligned_in_smp;
#endif /* _LINUX_IPC_H */ #endif /* _LINUX_IPC_H */
...@@ -10,8 +10,7 @@ struct task_struct; ...@@ -10,8 +10,7 @@ struct task_struct;
/* One sem_array data structure for each set of semaphores in the system. */ /* One sem_array data structure for each set of semaphores in the system. */
struct sem_array { struct sem_array {
struct kern_ipc_perm ____cacheline_aligned_in_smp struct kern_ipc_perm sem_perm; /* permissions .. see ipc.h */
sem_perm; /* permissions .. see ipc.h */
time_t sem_ctime; /* last change time */ time_t sem_ctime; /* last change time */
struct sem *sem_base; /* ptr to first semaphore in array */ struct sem *sem_base; /* ptr to first semaphore in array */
struct list_head pending_alter; /* pending operations */ struct list_head pending_alter; /* pending operations */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment