Skip to contentSkip to conversation

ipc/sem: add hysteresis

PATCH New [email protected] 1 participant 1 message Feb 27, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 33/78 ipc/sem: add hysteresis

From: Manfred Spraul <[email protected]>
Subject: ipc/sem: add hysteresis

sysv sem has two lock modes: One with per-semaphore locks, one lock mode with a single global lock for the whole array.
When switching from the per-semaphore locks to the global lock, all per-semaphore locks must be scanned for ongoing operations.

The patch adds a hysteresis for switching from the global lock to the per semaphore locks. This reduces how often the per-semaphore locks must be scanned.

Compared to the initial patch, this is a simplified solution:
Setting USE_GLOBAL_LOCK_HYSTERESIS to 1 restores the current behavior.

In theory, a workload with exactly 10 simple sops and then one complex op now scales a bit worse, but this is pure theory:
If there is concurrency, the it won't be exactly 10:1:10:1:10:1:... If there is no concurrency, then there is no need for scalability.

---

 include/linux/sem.h |    2 
 ipc/sem.c           |   86 +++++++++++++++++++++++++++++-------------
 2 files changed, 62 insertions(+), 26 deletions(-)
include/linux/sem.h renamed from include/linux/sem.h~ipc-sem-add-hysteresis +1 -1
diff -puN include/linux/sem.h~ipc-sem-add-hysteresis include/linux/sem.h
@@ -21,7 +21,7 @@ struct sem_array {
 	struct list_head	list_id;	/* undo requests on this array */
 	int			sem_nsems;	/* no. of semaphores in array */
 	int			complex_count;	/* pending complex operations */
-	bool			complex_mode;	/* no parallel simple ops */
+	unsigned int		use_global_lock;/* >0: global lock required */
 };
 
 #ifdef CONFIG_SYSVIPC
ipc/sem.c renamed from ipc/sem.c~ipc-sem-add-hysteresis +61 -25

156 lines not on this page · raw message

_