aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuchi Kandoi <kandoiruchi@google.com>2015-06-26 14:19:21 -0700
committerrogersb11 <brettrogers11@gmail.com>2015-12-02 12:29:52 -0500
commit874bae78eb0b7aa2ac939636ba0031962633f841 (patch)
tree231ef9639f8e2c4f60db059c7a89c46e7cea7778
parent2ec8bf1130245caf4b9edd97759d120b66bc6c74 (diff)
downloadkernel_samsung_smdk4412-874bae78eb0b7aa2ac939636ba0031962633f841.zip
kernel_samsung_smdk4412-874bae78eb0b7aa2ac939636ba0031962633f841.tar.gz
kernel_samsung_smdk4412-874bae78eb0b7aa2ac939636ba0031962633f841.tar.bz2
uid_cputime: Fixes double accounting race condition on 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.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/misc/uid_cputime.c b/drivers/misc/uid_cputime.c
index ad32727..73ed8b2 100644
--- a/drivers/misc/uid_cputime.c
+++ b/drivers/misc/uid_cputime.c
@@ -101,6 +101,10 @@ static int uid_stat_show(struct seq_file *m, void *v)
__func__, 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_times(task, &utime, &stime);
uid_entry->active_utime += utime;
uid_entry->active_stime += stime;
@@ -212,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);