taskstats: extended taskstats2 with acct fields
Add basic accounting stats in taskstats2 struct Change-Id: Ieb5aa751381f889628eba143db3988a56ef0f096 Signed-off-by: Jasleen Kalsi <jkalsi@codeaurora.org>
This commit is contained in:
parent
ead4c53fbb
commit
ec9b162b67
@ -35,7 +35,7 @@
|
||||
|
||||
|
||||
#define TASKSTATS_VERSION 9
|
||||
#define TASKSTATS2_VERSION 1
|
||||
#define TASKSTATS2_VERSION 2
|
||||
#define TS_COMM_LEN 32 /* should be >= TASK_COMM_LEN
|
||||
* in linux/sched.h */
|
||||
|
||||
@ -181,6 +181,20 @@ struct taskstats2 {
|
||||
__u64 shmem_rss; /* KB */
|
||||
__u64 unreclaimable; /* KB */
|
||||
/* version 1 ends here */
|
||||
|
||||
/* version 2 begins here */
|
||||
__u64 utime; /* User CPU time [usec] */
|
||||
__u64 stime; /* System CPU time [usec] */
|
||||
__u64 cutime; /* Cumulative User CPU time [usec] */
|
||||
__u64 cstime; /* Cumulative System CPU time [usec] */
|
||||
|
||||
__u32 uid __attribute__((aligned(8)));
|
||||
/* User ID */
|
||||
__u32 ppid; /* Parent process ID */
|
||||
char name[TS_COMM_LEN]; /* Command name */
|
||||
char state[TS_COMM_LEN]; /* Process state */
|
||||
/* version 2 ends here*/
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -644,6 +644,13 @@ static int taskstats2_cmd_attr_pid(struct genl_info *info)
|
||||
size_t size;
|
||||
u32 pid;
|
||||
int rc;
|
||||
u64 utime, stime;
|
||||
const struct cred *tcred;
|
||||
#ifdef CONFIG_CPUSETS
|
||||
struct cgroup_subsys_state *css;
|
||||
#endif //CONFIG_CPUSETS
|
||||
unsigned long flags;
|
||||
struct signal_struct *sig;
|
||||
|
||||
size = nla_total_size_64bit(sizeof(struct taskstats2));
|
||||
|
||||
@ -690,6 +697,37 @@ static int taskstats2_cmd_attr_pid(struct genl_info *info)
|
||||
#undef K
|
||||
task_unlock(p);
|
||||
}
|
||||
|
||||
/* version 2 fields begin here */
|
||||
task_cputime(tsk, &utime, &stime);
|
||||
stats->utime = div_u64(utime, NSEC_PER_USEC);
|
||||
stats->stime = div_u64(stime, NSEC_PER_USEC);
|
||||
|
||||
if (lock_task_sighand(tsk, &flags)) {
|
||||
sig = tsk->signal;
|
||||
stats->cutime = sig->cutime;
|
||||
stats->cstime = sig->cstime;
|
||||
unlock_task_sighand(tsk, &flags);
|
||||
}
|
||||
|
||||
rcu_read_lock();
|
||||
tcred = __task_cred(tsk);
|
||||
stats->uid = from_kuid_munged(current_user_ns(), tcred->uid);
|
||||
stats->ppid = pid_alive(tsk) ?
|
||||
task_tgid_nr_ns(rcu_dereference(tsk->real_parent),
|
||||
task_active_pid_ns(current)) : 0;
|
||||
rcu_read_unlock();
|
||||
|
||||
strlcpy(stats->name, tsk->comm, sizeof(stats->name));
|
||||
|
||||
#ifdef CONFIG_CPUSETS
|
||||
css = task_get_css(tsk, cpuset_cgrp_id);
|
||||
cgroup_path_ns(css->cgroup, stats->state, sizeof(stats->state),
|
||||
current->nsproxy->cgroup_ns);
|
||||
css_put(css);
|
||||
#endif //CONFIG_CPUSETS
|
||||
/* version 2 fields end here */
|
||||
|
||||
put_task_struct(tsk);
|
||||
|
||||
return send_reply(rep_skb, info);
|
||||
|
Loading…
Reference in New Issue
Block a user