Messages in this thread | | | Date | Wed, 26 Nov 2008 17:59:48 +0100 | From | Oleg Nesterov <> | Subject | Re: [patch 20/24] perfmon: system calls interface |
| |
On 11/26, Ingo Molnar wrote: > > * eranian@googlemail.com <eranian@googlemail.com> wrote: > > > +static int pfm_task_incompatible(struct pfm_context *ctx, > > + struct task_struct *task) > > +{ > > + /* > > + * cannot attach to a kernel thread > > + */ > > + if (!task->mm) { > > + PFM_DBG("cannot attach to kernel thread [%d]", task->pid); > > + return -EPERM; > > + } > > + > > + /* > > + * cannot attach to a zombie task > > + */ > > + if (task->exit_state == EXIT_ZOMBIE || task->exit_state == EXIT_DEAD) { > > + PFM_DBG("cannot attach to zombie/dead task [%d]", task->pid); > > + return -EBUSY; > > + } > > + return 0; > > +}
I agree with Ingo these checks are pointless. Without the locks the ->mm or ->exit_state can be changed right after the check.
And, as Ingo pointed out, you don't need this function at all, if ptrace_check_attach() succeeds the task must have ->mm and its ->exit_state == 0.
But, please note that the task can be SIGKILL'ed right after ptrace_check_attach(), it can drop ->mm, it can be released. (i don't understand the patch, perhaps this doesn't matter for you, just in case).
Oleg.
| |