[RFC PATCH 0/2] ipc: do not hold ipc lock more than necessary

From: Davidlohr Bueso
Date: Fri Mar 01 2013 - 19:16:44 EST


The following set of not-thoroughly-tested patches are based on the
discussion of holding the ipc lock unnecessarily, such as for permissions
and security checks:

https://lkml.org/lkml/2013/2/28/540

Patch 0/1: Introduces new functions, analogous to ipc_lock and ipc_lock_check
in the ipc utility code, allowing to obtain the ipc object without holding the lock.

Patch 0/2: Use the new functions and only acquire the ipc lock when needed.

With Rik's semop-multi.c microbenchmark we can see the following
results:

256 sems without patches:
+ 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
+ 1.75% a.out [kernel.kallsyms] [k] __audit_syscall_entry
+ 1.69% a.out [kernel.kallsyms] [k] ipc_has_perm.isra.21
+ 1.47% a.out [kernel.kallsyms] [k] do_smart_update
+ 1.43% a.out [kernel.kallsyms] [k] pid_vnr
+ 1.39% a.out [kernel.kallsyms] [k] try_atomic_semop.isra.5

total operations: 151452270, ops/sec 5048409

256 sems with patches:
+ 17.47% a.out [kernel.kallsyms] [k] _raw_spin_lock
+ 11.08% a.out [kernel.kallsyms] [k] sys_semtimedop
+ 8.81% a.out [kernel.kallsyms] [k] avc_has_perm_flags
+ 7.96% a.out [kernel.kallsyms] [k] ipc_has_perm.isra.21
+ 6.50% a.out [kernel.kallsyms] [k] __audit_syscall_exit
+ 4.67% a.out [kernel.kallsyms] [k] ipc_obtain_object_check
+ 4.19% a.out [kernel.kallsyms] [k] ipcperms
+ 3.75% a.out [kernel.kallsyms] [k] copy_user_enhanced_fast_string
+ 3.38% a.out [kernel.kallsyms] [k] system_call
+ 3.05% a.out [kernel.kallsyms] [k] try_atomic_semop.isra.5
+ 2.70% a.out [kernel.kallsyms] [k] do_smart_update
+ 2.60% a.out [kernel.kallsyms] [k] __audit_syscall_entry

total operations: 266502912, ops/sec 8883430

While the _raw_spin_lock time is drastically reduced, others do increase.
This results in an overall speedup of ~1.7x regarding ops/sec.


--
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/