Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipc/sem.c: cacheline align the ipc spinlock for semaphores

Cacheline align the spinlock for sysv semaphores. Without the patch, the
spinlock and sem_otime [written by every semop that modified the array]
and sem_base [read in the hot path of try_atomic_semop()] can be in the
same cacheline.

Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: Zach Brown <zach.brown@oracle.com>
Cc: Jens Axboe <jens.axboe@oracle.com>
Cc: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Manfred Spraul and committed by
Linus Torvalds
31a7c474 0a2b9d4c

+3 -1
+3 -1
include/linux/sem.h
··· 79 79 #ifdef __KERNEL__ 80 80 #include <asm/atomic.h> 81 81 #include <linux/rcupdate.h> 82 + #include <linux/cache.h> 82 83 83 84 struct task_struct; 84 85 ··· 92 91 93 92 /* One sem_array data structure for each set of semaphores in the system. */ 94 93 struct sem_array { 95 - struct kern_ipc_perm sem_perm; /* permissions .. see ipc.h */ 94 + struct kern_ipc_perm ____cacheline_aligned_in_smp 95 + sem_perm; /* permissions .. see ipc.h */ 96 96 time_t sem_otime; /* last semop time */ 97 97 time_t sem_ctime; /* last change time */ 98 98 struct sem *sem_base; /* ptr to first semaphore in array */