aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnmin Hsu <anmin.hsu@mediatek.com>2015-09-19 09:15:03 +0800
committerMister Oyster <oysterized@gmail.com>2017-04-11 11:00:29 +0200
commitf112aed229cc9f2ecd3cff2590a3ac85541562d8 (patch)
treefd4eaa532c63e863bced16fd14899cf3da081027
parentd19b5e09d4d08b5fede9ecd58dc29e3188529e20 (diff)
UID: fix UID_CPUTIME issue
[Detail] KernelUidCpuTimeReader read uid_cputime_stat to get system time, but uid_cputime have some issue cause system update value error. Use workaround to fix this issue. [Solution] enable UID_CPUTIME and check new system is smaller than old. If true return old system time. [Feature] UID MTK-Commit-Id: db35d391a485746c9a12f4413a17961a94792323 Change-Id: I27bacb410365bd5144ef34177fe54a88535d1c0d Signed-off-by: May Huang <may.huang@mediatek.com> CR-Id: ALPS02294778
-rw-r--r--drivers/misc/uid_cputime.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/misc/uid_cputime.c b/drivers/misc/uid_cputime.c
index c751188ce..a2d4cbb66 100644
--- a/drivers/misc/uid_cputime.c
+++ b/drivers/misc/uid_cputime.c
@@ -38,6 +38,8 @@ struct uid_entry {
cputime_t stime;
cputime_t active_utime;
cputime_t active_stime;
+ cputime_t total_utime;
+ cputime_t total_stime;
unsigned long long active_power;
unsigned long long power;
struct hlist_node hash;
@@ -66,6 +68,8 @@ static struct uid_entry *find_or_register_uid(uid_t uid)
return NULL;
uid_entry->uid = uid;
+ uid_entry->total_utime = 0;
+ uid_entry->total_stime = 0;
hash_add(hash_table, &uid_entry->hash, uid);
@@ -119,6 +123,20 @@ static int uid_stat_show(struct seq_file *m, void *v)
uid_entry->active_stime;
unsigned long long total_power = uid_entry->power +
uid_entry->active_power;
+
+ /***
+ * workaround for KernelUidCpuTimeReader issue
+ ***/
+ if (total_stime < uid_entry->total_stime)
+ total_stime = uid_entry->total_stime;
+ else
+ uid_entry->total_stime = total_stime;
+
+ if (total_utime < uid_entry->total_utime)
+ total_utime = uid_entry->total_utime;
+ else
+ uid_entry->total_utime = total_utime;
+
seq_printf(m, "%d: %llu %llu %llu\n", uid_entry->uid,
(unsigned long long)jiffies_to_msecs(
cputime_to_jiffies(total_utime)) * USEC_PER_MSEC,