cputime_t stime;
cputime_t active_utime;
cputime_t active_stime;
- unsigned long long active_power;
- unsigned long long power;
struct hlist_node hash;
};
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;
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) {
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_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) {
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);
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);
+ }
}
}
task_cputime_adjusted(task, &utime, &stime);
uid_entry->utime += utime;
uid_entry->stime += stime;
- uid_entry->power += task->cpu_power;
- task->cpu_power = ULLONG_MAX;
exit:
mutex_unlock(&uid_lock);