Skip to contentSkip to conversation

taskstats: set version field for tgid exit

PATCH New Xidorn Quan 1 participant 1 message May 16, 2020 Taskstats statistics interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 taskstats: set version field for tgid exit

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

---
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(-)
kernel/taskstats.c +6 -3
index e2ac0e37c4ae..c646b27f18ac 100644
@@ -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;
Signature · 1 line
2.25.1