• Manfred Spraul's avatar
    ipc/sem: add hysteresis · 9de5ab8a
    Manfred Spraul authored
    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.
    
    Link: http://lkml.kernel.org/r/1476851896-3590-3-git-send-email-manfred@colorfullife.comSigned-off-by: default avatarManfred Spraul <manfred@colorfullife.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Davidlohr Bueso <dave@stgolabs.net>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Ingo Molnar <mingo@elte.hu>
    Cc: H. Peter Anvin <hpa@zytor.com>
    Cc: <1vier1@web.de>
    Cc: kernel test robot <xiaolong.ye@intel.com>
    Cc: <felixh@informatik.uni-bremen.de>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    9de5ab8a
sem.c 55.5 KB