[PATCH] taskstats: set version field for tgid exit

From: Xidorn Quan
Date: Sat May 16 2020 - 08:16:16 EST


Currently, an aggregated taskstats struct for task group exit does not
have its version field set. This patch fixes it.

Signed-off-by: Xidorn Quan <me@xxxxxxxxxxx>
---
Users of taskstats may expect that version of the struct is always set
up properly, so that they can check whether it's supported.
---
kernel/taskstats.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index e2ac0e37c4ae..c646b27f18ac 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -258,18 +258,21 @@ static int fill_stats_for_tgid(pid_t tgid, struct taskstats *stats)
static void fill_tgid_exit(struct task_struct *tsk)
{
unsigned long flags;
+ struct taskstats *stats;

spin_lock_irqsave(&tsk->sighand->siglock, flags);
- if (!tsk->signal->stats)
+ stats = tsk->signal->stats;
+ if (!stats)
goto ret;

/*
* Each accounting subsystem calls its functions here to
* accumalate its per-task stats for tsk, into the per-tgid structure
*
- * per-task-foo(tsk->signal->stats, tsk);
+ * per-task-foo(stats, tsk);
*/
- delayacct_add_tsk(tsk->signal->stats, tsk);
+ delayacct_add_tsk(stats, tsk);
+ stats->version = TASKSTATS_VERSION;
ret:
spin_unlock_irqrestore(&tsk->sighand->siglock, flags);
return;
--
2.25.1