[PATCH] ipc/sem.c: Alternative for fixing Concurrency bug

From: Manfred Spraul
Date: Sat Oct 10 2015 - 02:37:22 EST


Two ideas for fixing the bug found by Felix:
- Revert my initial patch.
Problem: Significant slowdown for application that use large sem
arrays and complex operations: Every semop() does a loop
with spin_lock() on all semaphores.

- Add another sem_wait_array() that catches operations that are in
the middle of sem_lock().

What do you think? Is it worth to optimize for complex ops?

Reported-by: felixh@xxxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: Manfred Spraul <manfred@xxxxxxxxxxxxxxxx>
---
ipc/sem.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/ipc/sem.c b/ipc/sem.c
index b471e5a..9a55cfb 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -1936,9 +1936,16 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops,
list_add_tail(&queue.list, &curr->pending_const);
}
} else {
- if (!sma->complex_count)
+ if (!sma->complex_count) {
merge_queues(sma);

+ /*
+ * squeeze out any simple operations that are in the middle
+ * of sem_lock()
+ */
+ sem_wait_array(sma);
+ }
+
if (alter)
list_add_tail(&queue.list, &sma->pending_alter);
else
--
2.4.3


--------------070208030101040203030001--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/