Re: Add all thread stats for TASKSTATS_CMD_ATTR_TGID (v5)

From: Oleg Nesterov
Date: Tue Sep 18 2007 - 11:26:45 EST


On 09/18, Guillaume Chazarain wrote:
>
> @@ -508,7 +543,7 @@ void taskstats_exit(struct task_struct *
> if (!stats)
> goto err;
>
> - memcpy(stats, tsk->signal->stats, sizeof(*stats));
> + fill_tgid(tsk->pid, tsk, stats);

No, no, this is wrong.

tsk->signal->stats contains the accumulated info about the already exited
threads, we shouldn't throw it out.

Also, fill_tgid() doesn't make sense here, current is the last live sub-thread.


Hmm. We have another race here. There is no guarantee that tsk->signal->stats
covers all sub-threads, as it is supposed to be. It is quite possible that
another sub-thread decremented ->signal->live before us, but didn't complete
taskstats_exit()->fill_tgid_exit() yet.

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/