mmc: core: use default generic cmd6 timeout for flushing cache
[firefly-linux-kernel-4.4.55.git] / drivers / misc / uid_cputime.c
index 89bfba6c5b6aa91bb4ed63560f65fce3f4134bfc..c1ad5246f564e5c1a0b210820492b785f7b76d4e 100644 (file)
@@ -38,8 +38,6 @@ struct uid_entry {
        cputime_t stime;
        cputime_t active_utime;
        cputime_t active_stime;
-       unsigned long long active_power;
-       unsigned long long power;
        struct hlist_node hash;
 };
 
@@ -75,7 +73,7 @@ static struct uid_entry *find_or_register_uid(uid_t uid)
 static int uid_stat_show(struct seq_file *m, void *v)
 {
        struct uid_entry *uid_entry;
-       struct task_struct *task;
+       struct task_struct *task, *temp;
        cputime_t utime;
        cputime_t stime;
        unsigned long bkt;
@@ -85,11 +83,10 @@ static int uid_stat_show(struct seq_file *m, void *v)
        hash_for_each(hash_table, bkt, uid_entry, hash) {
                uid_entry->active_stime = 0;
                uid_entry->active_utime = 0;
-               uid_entry->active_power = 0;
        }
 
        read_lock(&tasklist_lock);
-       for_each_process(task) {
+       do_each_thread(temp, task) {
                uid_entry = find_or_register_uid(from_kuid_munged(
                        current_user_ns(), task_uid(task)));
                if (!uid_entry) {
@@ -103,8 +100,7 @@ static int uid_stat_show(struct seq_file *m, void *v)
                task_cputime_adjusted(task, &utime, &stime);
                uid_entry->active_utime += utime;
                uid_entry->active_stime += stime;
-               uid_entry->active_power += task->cpu_power;
-       }
+       } while_each_thread(temp, task);
        read_unlock(&tasklist_lock);
 
        hash_for_each(hash_table, bkt, uid_entry, hash) {
@@ -112,12 +108,11 @@ static int uid_stat_show(struct seq_file *m, void *v)
                                                        uid_entry->active_utime;
                cputime_t total_stime = uid_entry->stime +
                                                        uid_entry->active_stime;
-               unsigned long long total_power = uid_entry->power +
-                                                       uid_entry->active_power;
-               seq_printf(m, "%d: %u %u %llu\n", uid_entry->uid,
-                                               cputime_to_usecs(total_utime),
-                                               cputime_to_usecs(total_stime),
-                                               total_power);
+               seq_printf(m, "%d: %llu %llu\n", uid_entry->uid,
+                       (unsigned long long)jiffies_to_msecs(
+                               cputime_to_jiffies(total_utime)) * USEC_PER_MSEC,
+                       (unsigned long long)jiffies_to_msecs(
+                               cputime_to_jiffies(total_stime)) * USEC_PER_MSEC);
        }
 
        mutex_unlock(&uid_lock);
@@ -167,14 +162,15 @@ static ssize_t uid_remove_write(struct file *file,
                kstrtol(end_uid, 10, &uid_end) != 0) {
                return -EINVAL;
        }
-
        mutex_lock(&uid_lock);
 
        for (; uid_start <= uid_end; uid_start++) {
                hash_for_each_possible_safe(hash_table, uid_entry, tmp,
-                                                       hash, uid_start) {
-                       hash_del(&uid_entry->hash);
-                       kfree(uid_entry);
+                                                       hash, (uid_t)uid_start) {
+                       if (uid_start == uid_entry->uid) {
+                               hash_del(&uid_entry->hash);
+                               kfree(uid_entry);
+                       }
                }
        }
 
@@ -210,7 +206,6 @@ static int process_notifier(struct notifier_block *self,
        task_cputime_adjusted(task, &utime, &stime);
        uid_entry->utime += utime;
        uid_entry->stime += stime;
-       uid_entry->power += task->cpu_power;
 
 exit:
        mutex_unlock(&uid_lock);