[PATCH 6/6] get_utrace_lock: do not check EXIT_DEAD
Oleg Nesterov
oleg at redhat.com
Fri Jul 31 01:06:59 UTC 2009
get_utrace_lock() checks ->state != EXIT_DEAD to make sure it safe
to use ->utrace. This is unneeded since ->utrace was embedded into
task_struct. If we can read ->state, we can read ->utrace as well.
Signed-off-by: Oleg Nesterov <oleg at redhat.com>
----
kernel/utrace.c | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
--- __UTRACE/kernel/utrace.c~6_GET_UTRACE_LOCK 2009-07-31 02:35:50.000000000 +0200
+++ __UTRACE/kernel/utrace.c 2009-07-31 02:47:42.000000000 +0200
@@ -493,27 +493,17 @@ static struct utrace *get_utrace_lock(st
}
utrace = &target->utrace;
- if (unlikely(target->exit_state == EXIT_DEAD)) {
+ spin_lock(&utrace->lock);
+ if (unlikely(!engine->ops) ||
+ unlikely(engine->ops == &utrace_detached_ops)) {
/*
- * If all engines detached already, utrace is clear.
- * Otherwise, we're called after utrace_release_task might
- * have started. A call to this engine's report_reap
- * callback might already be in progress.
+ * By the time we got the utrace lock,
+ * it had been reaped or detached already.
*/
+ spin_unlock(&utrace->lock);
utrace = ERR_PTR(-ESRCH);
- } else {
- spin_lock(&utrace->lock);
- if (unlikely(!engine->ops) ||
- unlikely(engine->ops == &utrace_detached_ops)) {
- /*
- * By the time we got the utrace lock,
- * it had been reaped or detached already.
- */
- spin_unlock(&utrace->lock);
- utrace = ERR_PTR(-ESRCH);
- if (!attached && engine->ops == &utrace_detached_ops)
- utrace = ERR_PTR(-ERESTARTSYS);
- }
+ if (!attached && engine->ops == &utrace_detached_ops)
+ utrace = ERR_PTR(-ERESTARTSYS);
}
rcu_read_unlock();
More information about the utrace-devel
mailing list