alistair23-linux/ipc
Manfred Spraul 2e094abfd1 ipc/sem.c: change memory barrier in sem_lock() to smp_rmb()
When I fixed bugs in the sem_lock() logic, I was more conservative than
necessary.  Therefore it is safe to replace the smp_mb() with smp_rmb().
And: With smp_rmb(), semop() syscalls are up to 10% faster.

The race we must protect against is:

	sem->lock is free
	sma->complex_count = 0
	sma->sem_perm.lock held by thread B

thread A:

A: spin_lock(&sem->lock)

			B: sma->complex_count++; (now 1)
			B: spin_unlock(&sma->sem_perm.lock);

A: spin_is_locked(&sma->sem_perm.lock);
A: XXXXX memory barrier
A: if (sma->complex_count == 0)

Thread A must read the increased complex_count value, i.e. the read must
not be reordered with the read of sem_perm.lock done by spin_is_locked().

Since it's about ordering of reads, smp_rmb() is sufficient.

[akpm@linux-foundation.org: update sem_lock() comment, from Davidlohr]
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
Acked-by: Rafael Aquini <aquini@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-12-13 12:42:52 -08:00
..
compat.c ipc: resolve shadow warnings 2014-10-14 02:18:23 +02:00
compat_mq.c ipc, kernel: use Linux headers 2014-06-06 16:08:14 -07:00
ipc_sysctl.c ipc: always handle a new value of auto_msgmni 2014-10-14 02:18:22 +02:00
ipcns_notifier.c
Makefile
mq_sysctl.c ipc: convert use of typedef ctl_table to struct ctl_table 2014-06-06 16:08:16 -07:00
mqueue.c new helper: audit_file() 2014-11-19 13:01:26 -05:00
msg.c ipc,msg: document volatile r_msg 2014-06-06 16:08:15 -07:00
msgutil.c ipc, msg: fix message length check for negative values 2013-11-13 12:09:36 +09:00
namespace.c namespaces: Use task_lock and not rcu to protect nsproxy 2014-07-29 18:08:50 -07:00
sem.c ipc/sem.c: change memory barrier in sem_lock() to smp_rmb() 2014-12-13 12:42:52 -08:00
shm.c ipc/shm: kill the historical/wrong mm->start_stack check 2014-10-14 02:18:23 +02:00
syscall.c
util.c ipc/util.c: use __seq_open_private() instead of seq_open() 2014-10-14 02:18:23 +02:00
util.h ipc, kernel: clear whitespace 2014-06-06 16:08:14 -07:00