UPSTREAM: Documentation/devicetree: Add new property to specify the max link speed
[firefly-linux-kernel-4.4.55.git] / drivers / misc / uid_cputime.c
index acd7046ce497692887d0aa0ea6c336f37fd0a5cc..c1ad5246f564e5c1a0b210820492b785f7b76d4e 100644 (file)
@@ -73,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;
@@ -86,7 +86,7 @@ static int uid_stat_show(struct seq_file *m, void *v)
        }
 
        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) {
@@ -100,7 +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;
-       }
+       } while_each_thread(temp, task);
        read_unlock(&tasklist_lock);
 
        hash_for_each(hash_table, bkt, uid_entry, hash) {
@@ -108,9 +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;
-               seq_printf(m, "%d: %u %u\n", uid_entry->uid,
-                                               cputime_to_usecs(total_utime),
-                                               cputime_to_usecs(total_stime));
+               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);
@@ -160,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);
+                       }
                }
        }
 
@@ -226,7 +229,7 @@ static int __init proc_uid_cputime_init(void)
        proc_create_data("remove_uid_range", S_IWUGO, parent, &uid_remove_fops,
                                        NULL);
 
-       proc_create_data("show_uid_stat", S_IWUGO, parent, &uid_stat_fops,
+       proc_create_data("show_uid_stat", S_IRUGO, parent, &uid_stat_fops,
                                        NULL);
 
        profile_event_register(PROFILE_TASK_EXIT, &process_notifier_block);