The multi-line utrace_attach_task(a lot of args) looks really annoing, add the trivial helper, ptrace_lookup_engine(tracee).
--- kernel/ptrace.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) --- PU/kernel/ptrace.c~48_PTRACE_LOOKUP_ENGINE 2009-09-17 20:13:24.000000000 +0200 +++ PU/kernel/ptrace.c 2009-09-17 20:35:09.000000000 +0200 @@ -98,13 +98,17 @@ static const struct utrace_engine_ops pt static int ptrace_attach_task(struct task_struct *tracee, int options); static void ptrace_abort_attach(struct task_struct *tracee); +static struct utrace_engine *ptrace_lookup_engine(struct task_struct *tracee) +{ + return utrace_attach_task(tracee, UTRACE_ATTACH_MATCH_OPS, + &ptrace_utrace_ops, NULL); +} + static void ptrace_detach_task(struct task_struct *child, int sig) { - struct utrace_engine *engine; + struct utrace_engine *engine = ptrace_lookup_engine(child); int ret; - engine = utrace_attach_task(child, UTRACE_ATTACH_MATCH_OPS, - &ptrace_utrace_ops, NULL); if (unlikely(IS_ERR(engine))) return; @@ -493,8 +497,7 @@ int ptrace_check_attach(struct task_stru if (child->parent != current) return -ESRCH; - engine = utrace_attach_task(child, UTRACE_ATTACH_MATCH_OPS, - &ptrace_utrace_ops, NULL); + engine = ptrace_lookup_engine(child); if (IS_ERR(engine)) return -ESRCH; @@ -805,10 +808,8 @@ int ptrace_writedata(struct task_struct static int ptrace_set_options(struct task_struct *child, long data) { - struct utrace_engine *engine; + struct utrace_engine *engine = ptrace_lookup_engine(child); - engine = utrace_attach_task(child, UTRACE_ATTACH_MATCH_OPS, - &ptrace_utrace_ops, NULL); if (likely(!IS_ERR(engine))) { __ptrace_set_options(child, engine, data & PTRACE_O_MASK); utrace_engine_put(engine); @@ -819,8 +820,7 @@ static int ptrace_set_options(struct tas static int ptrace_getsiginfo(struct task_struct *child, siginfo_t *info) { - struct utrace_engine *engine = utrace_attach_task(child, UTRACE_ATTACH_MATCH_OPS, - &ptrace_utrace_ops, NULL); + struct utrace_engine *engine = ptrace_lookup_engine(child); unsigned long flags; int error = -ESRCH; @@ -842,8 +842,7 @@ static int ptrace_getsiginfo(struct task static int ptrace_setsiginfo(struct task_struct *child, const siginfo_t *info) { - struct utrace_engine *engine = utrace_attach_task(child, UTRACE_ATTACH_MATCH_OPS, - &ptrace_utrace_ops, NULL); + struct utrace_engine *engine = ptrace_lookup_engine(child); unsigned long flags; int error = -ESRCH; @@ -902,11 +901,9 @@ static void do_ptrace_notify_stop(struct void ptrace_notify_stop(struct task_struct *tracee) { - struct utrace_engine *engine; + struct utrace_engine *engine = ptrace_lookup_engine(tracee); struct ptrace_context *context; - engine = utrace_attach_task(tracee, UTRACE_ATTACH_MATCH_OPS, - &ptrace_utrace_ops, NULL); if (IS_ERR(engine)) { // XXX: temporary check, wrong with mutlitracing WARN_ON(tracee->state != TASK_RUNNING); @@ -914,10 +911,8 @@ void ptrace_notify_stop(struct task_stru } context = ptrace_context(engine); - if (WARN_ON(ev_empty(context))) return; - do_ptrace_notify_stop(context, tracee); } @@ -981,8 +976,7 @@ static int ptrace_resume(struct task_str if (!valid_signal(data)) return -EIO; - engine = utrace_attach_task(child, UTRACE_ATTACH_MATCH_OPS, - &ptrace_utrace_ops, NULL); + engine = ptrace_lookup_engine(child); if (IS_ERR(engine)) return -ESRCH;