aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuchi Kandoi <kandoiruchi@google.com>2015-06-26 14:19:21 -0700
committerMoyster <oysterized@gmail.com>2016-09-10 16:03:50 +0200
commit988b7d47d882df3f6ddcebb813eb7874e0486dd6 (patch)
tree0a10560ed8bb8d3e1b0642e87ac3948001551472
parente1d0f1a8cb42b982e4bb2824a1c643e1bc02c91e (diff)
uid_cputime: Avoids double accounting of process stime, utime and cpu_power in
task exit. This avoids the race where a particular process is terminating and we read the show_uid_stats. At this time since the task_struct still exists and we will account for the terminating process as one of the active task, where as the stats would have been added in the task exit callback. Bug: 22064385 Change-Id: Id2ae04b33fcd230eda9683a41b6019d4dd8f5d85 Signed-off-by: Jin Qian <jinqian@google.com> Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
-rw-r--r--drivers/misc/uid_cputime.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/misc/uid_cputime.c b/drivers/misc/uid_cputime.c
index 89bfba6c5..012bd3505 100644
--- a/drivers/misc/uid_cputime.c
+++ b/drivers/misc/uid_cputime.c
@@ -100,6 +100,11 @@ static int uid_stat_show(struct seq_file *m, void *v)
task_uid(task)));
return -ENOMEM;
}
+ /* if this task is exiting, we have already accounted for the
+ * time and power.
+ */
+ if (task->cpu_power == ULLONG_MAX)
+ continue;
task_cputime_adjusted(task, &utime, &stime);
uid_entry->active_utime += utime;
uid_entry->active_stime += stime;
@@ -211,6 +216,7 @@ static int process_notifier(struct notifier_block *self,
uid_entry->utime += utime;
uid_entry->stime += stime;
uid_entry->power += task->cpu_power;
+ task->cpu_power = ULLONG_MAX;
exit:
mutex_unlock(&uid_lock);