Re: + taskstats-add-all-thread-stats-for-taskstats_cmd_attr_tgid.patch added to -mm tree

From: Oleg Nesterov
Date: Mon Sep 17 2007 - 12:22:51 EST


On 09/15, Guillaume Chazarain wrote:
>
> Le Thu, 13 Sep 2007 16:41:41 +0400,
> Oleg Nesterov <oleg@xxxxxxxxxx> a ??crit :
>
> > > + do
> > > + if (!tsk->exit_state)
> > > + add_tsk(stats, tsk);
> > > + while_each_thread(first, tsk);
> >
> > This reminds me. The "!tsk->exit_state" is not good and racy, it
> > can't prevent the double accounting (of course, I don't blame this
> > patch).
>
> I documented this in v4, but I was wondering if always setting
> tsk->exit_state under the protection of lock_task_sighand() would fix
> the race.

No, this is not enough. There is a window between do_exit()->taskstats_exit()
and do_exit()->exit_notify() which sets ->exit_state. Probably, we can
shift taskstats_exit() into exit_notify() but this is not good.

Oleg.

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