diff options
author | Vasiliy Kulikov <segoon@openwall.com> | 2011-08-03 14:28:26 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-08-03 20:45:55 -0400 |
commit | 298507d4d2cff2248e84afcf646b697301294442 (patch) | |
tree | 15861e6610403c57cf4eca976dea4d59ac7a8e99 /ipc | |
parent | 33a30ed4bdccd95ed84a1a20c1fef8ac89788ce5 (diff) |
shm: optimize exit_shm()
We may optimistically check .in_use == 0 without holding the rw_mutex:
it's the common case, and if it's zero, there certainly won't be any
segments associated with us.
After taking the lock, the idr_for_each() will do the right thing, so we
could now drop the re-check inside the lock without any real cost. But
it won't hurt.
Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/shm.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -304,6 +304,9 @@ void exit_shm(struct task_struct *task) | |||
304 | { | 304 | { |
305 | struct ipc_namespace *ns = task->nsproxy->ipc_ns; | 305 | struct ipc_namespace *ns = task->nsproxy->ipc_ns; |
306 | 306 | ||
307 | if (shm_ids(ns).in_use == 0) | ||
308 | return; | ||
309 | |||
307 | /* Destroy all already created segments, but not mapped yet */ | 310 | /* Destroy all already created segments, but not mapped yet */ |
308 | down_write(&shm_ids(ns).rw_mutex); | 311 | down_write(&shm_ids(ns).rw_mutex); |
309 | if (shm_ids(ns).in_use) | 312 | if (shm_ids(ns).in_use) |