Skip to content
Snippets Groups Projects
  • Davidlohr Bueso's avatar
    16df3674
    ipc,sem: do not hold ipc lock more than necessary · 16df3674
    Davidlohr Bueso authored
    
    Instead of holding the ipc lock for permissions and security checks, among
    others, only acquire it when necessary.
    
    Some numbers....
    
    1) With Rik's semop-multi.c microbenchmark we can see the following
       results:
    
    Baseline (3.9-rc1):
    cpus 4, threads: 256, semaphores: 128, test duration: 30 secs
    total operations: 151452270, ops/sec 5048409
    
    +  59.40%            a.out  [kernel.kallsyms]  [k] _raw_spin_lock
    +   6.14%            a.out  [kernel.kallsyms]  [k] sys_semtimedop
    +   3.84%            a.out  [kernel.kallsyms]  [k] avc_has_perm_flags
    +   3.64%            a.out  [kernel.kallsyms]  [k] __audit_syscall_exit
    +   2.06%            a.out  [kernel.kallsyms]  [k] copy_user_enhanced_fast_string
    +   1.86%            a.out  [kernel.kallsyms]  [k] ipc_lock
    
    With this patchset:
    cpus 4, threads: 256, semaphores: 128, test duration: 30 secs
    total operations: 273156400, ops/sec 9105213
    
    +  18.54%            a.out  [kernel.kallsyms]  [k] _raw_spin_lock
    +  11.72%            a.out  [kernel.kallsyms]  [k] sys_semtimedop
    +   7.70%            a.out  [kernel.kallsyms]  [k] ipc_has_perm.isra.21
    +   6.58%            a.out  [kernel.kallsyms]  [k] avc_has_perm_flags
    +   6.54%            a.out  [kernel.kallsyms]  [k] __audit_syscall_exit
    +   4.71%            a.out  [kernel.kallsyms]  [k] ipc_obtain_object_check
    
    2) While on an Oracle swingbench DSS (data mining) workload the
       improvements are not as exciting as with Rik's benchmark, we can see
       some positive numbers.  For an 8 socket machine the following are the
       percentages of %sys time incurred in the ipc lock:
    
    Baseline (3.9-rc1):
    100 swingbench users: 8,74%
    400 swingbench users: 21,86%
    800 swingbench users: 84,35%
    
    With this patchset:
    100 swingbench users: 8,11%
    400 swingbench users: 19,93%
    800 swingbench users: 77,69%
    
    [riel@redhat.com: fix two locking bugs]
    [sasha.levin@oracle.com: prevent releasing RCU read lock twice in semctl_main]
    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: default avatarDavidlohr Bueso <davidlohr.bueso@hp.com>
    Signed-off-by: default avatarRik van Riel <riel@redhat.com>
    Reviewed-by: default avatarChegu Vinod <chegu_vinod@hp.com>
    Acked-by: default avatarMichel Lespinasse <walken@google.com>
    Cc: Rik van Riel <riel@redhat.com>
    Cc: Jason Low <jason.low2@hp.com>
    Cc: Emmanuel Benisty <benisty.e@gmail.com>
    Cc: Peter Hurley <peter@hurleysoftware.com>
    Cc: Stanislav Kinsbursky <skinsbursky@parallels.com>
    Tested-by: default avatarSedat Dilek <sedat.dilek@gmail.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    16df3674
    History
    ipc,sem: do not hold ipc lock more than necessary
    Davidlohr Bueso authored
    
    Instead of holding the ipc lock for permissions and security checks, among
    others, only acquire it when necessary.
    
    Some numbers....
    
    1) With Rik's semop-multi.c microbenchmark we can see the following
       results:
    
    Baseline (3.9-rc1):
    cpus 4, threads: 256, semaphores: 128, test duration: 30 secs
    total operations: 151452270, ops/sec 5048409
    
    +  59.40%            a.out  [kernel.kallsyms]  [k] _raw_spin_lock
    +   6.14%            a.out  [kernel.kallsyms]  [k] sys_semtimedop
    +   3.84%            a.out  [kernel.kallsyms]  [k] avc_has_perm_flags
    +   3.64%            a.out  [kernel.kallsyms]  [k] __audit_syscall_exit
    +   2.06%            a.out  [kernel.kallsyms]  [k] copy_user_enhanced_fast_string
    +   1.86%            a.out  [kernel.kallsyms]  [k] ipc_lock
    
    With this patchset:
    cpus 4, threads: 256, semaphores: 128, test duration: 30 secs
    total operations: 273156400, ops/sec 9105213
    
    +  18.54%            a.out  [kernel.kallsyms]  [k] _raw_spin_lock
    +  11.72%            a.out  [kernel.kallsyms]  [k] sys_semtimedop
    +   7.70%            a.out  [kernel.kallsyms]  [k] ipc_has_perm.isra.21
    +   6.58%            a.out  [kernel.kallsyms]  [k] avc_has_perm_flags
    +   6.54%            a.out  [kernel.kallsyms]  [k] __audit_syscall_exit
    +   4.71%            a.out  [kernel.kallsyms]  [k] ipc_obtain_object_check
    
    2) While on an Oracle swingbench DSS (data mining) workload the
       improvements are not as exciting as with Rik's benchmark, we can see
       some positive numbers.  For an 8 socket machine the following are the
       percentages of %sys time incurred in the ipc lock:
    
    Baseline (3.9-rc1):
    100 swingbench users: 8,74%
    400 swingbench users: 21,86%
    800 swingbench users: 84,35%
    
    With this patchset:
    100 swingbench users: 8,11%
    400 swingbench users: 19,93%
    800 swingbench users: 77,69%
    
    [riel@redhat.com: fix two locking bugs]
    [sasha.levin@oracle.com: prevent releasing RCU read lock twice in semctl_main]
    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: default avatarDavidlohr Bueso <davidlohr.bueso@hp.com>
    Signed-off-by: default avatarRik van Riel <riel@redhat.com>
    Reviewed-by: default avatarChegu Vinod <chegu_vinod@hp.com>
    Acked-by: default avatarMichel Lespinasse <walken@google.com>
    Cc: Rik van Riel <riel@redhat.com>
    Cc: Jason Low <jason.low2@hp.com>
    Cc: Emmanuel Benisty <benisty.e@gmail.com>
    Cc: Peter Hurley <peter@hurleysoftware.com>
    Cc: Stanislav Kinsbursky <skinsbursky@parallels.com>
    Tested-by: default avatarSedat Dilek <sedat.dilek@gmail.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>