Loading include/uapi/linux/taskstats.h +15 −1 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading @@ -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*/ }; /* Loading kernel/taskstats.c +34 −0 Original line number Diff line number Diff line Loading @@ -650,6 +650,11 @@ static int taskstats2_cmd_attr_pid(struct genl_info *info) size_t size; u32 pid; int rc; u64 utime, stime; const struct cred *tcred; struct cgroup_subsys_state *css; unsigned long flags; struct signal_struct *sig; size = nla_total_size_64bit(sizeof(struct taskstats2)); Loading Loading @@ -691,6 +696,35 @@ 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)); 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); /* version 2 fields end here */ put_task_struct(tsk); return send_reply(rep_skb, info); Loading Loading
include/uapi/linux/taskstats.h +15 −1 Original line number Diff line number Diff line Loading @@ -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 */ Loading Loading @@ -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*/ }; /* Loading
kernel/taskstats.c +34 −0 Original line number Diff line number Diff line Loading @@ -650,6 +650,11 @@ static int taskstats2_cmd_attr_pid(struct genl_info *info) size_t size; u32 pid; int rc; u64 utime, stime; const struct cred *tcred; struct cgroup_subsys_state *css; unsigned long flags; struct signal_struct *sig; size = nla_total_size_64bit(sizeof(struct taskstats2)); Loading Loading @@ -691,6 +696,35 @@ 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)); 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); /* version 2 fields end here */ put_task_struct(tsk); return send_reply(rep_skb, info); Loading