From f112aed229cc9f2ecd3cff2590a3ac85541562d8 Mon Sep 17 00:00:00 2001 From: Anmin Hsu Date: Sat, 19 Sep 2015 09:15:03 +0800 Subject: 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 CR-Id: ALPS02294778 --- drivers/misc/uid_cputime.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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, -- cgit v1.2.3