Merge tag 'iommu-updates-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / kernel / taskstats.c
index bcac5a9..f7e2463 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/kernel.h>
 #include <linux/taskstats_kern.h>
 #include <linux/tsacct_kern.h>
+#include <linux/acct.h>
 #include <linux/delayacct.h>
 #include <linux/cpumask.h>
 #include <linux/percpu.h>
@@ -153,6 +154,23 @@ static void send_cpu_listeners(struct sk_buff *skb,
        up_write(&listeners->sem);
 }
 
+static void exe_add_tsk(struct taskstats *stats, struct task_struct *tsk)
+{
+       /* No idea if I'm allowed to access that here, now. */
+       struct file *exe_file = get_task_exe_file(tsk);
+
+       if (exe_file) {
+               /* Following cp_new_stat64() in stat.c . */
+               stats->ac_exe_dev =
+                       huge_encode_dev(exe_file->f_inode->i_sb->s_dev);
+               stats->ac_exe_inode = exe_file->f_inode->i_ino;
+               fput(exe_file);
+       } else {
+               stats->ac_exe_dev = 0;
+               stats->ac_exe_inode = 0;
+       }
+}
+
 static void fill_stats(struct user_namespace *user_ns,
                       struct pid_namespace *pid_ns,
                       struct task_struct *tsk, struct taskstats *stats)
@@ -175,6 +193,9 @@ static void fill_stats(struct user_namespace *user_ns,
 
        /* fill in extended acct fields */
        xacct_add_tsk(stats, tsk);
+
+       /* add executable info */
+       exe_add_tsk(stats, tsk);
 }
 
 static int fill_stats_for_pid(pid_t pid, struct taskstats *stats)
@@ -620,6 +641,8 @@ void taskstats_exit(struct task_struct *tsk, int group_dead)
                goto err;
 
        fill_stats(&init_user_ns, &init_pid_ns, tsk, stats);
+       if (group_dead)
+               stats->ac_flag |= AGROUP;
 
        /*
         * Doesn't matter if tsk is the leader or the last group member leaving
@@ -665,6 +688,7 @@ static struct genl_family family __ro_after_init = {
        .module         = THIS_MODULE,
        .ops            = taskstats_ops,
        .n_ops          = ARRAY_SIZE(taskstats_ops),
+       .netnsok        = true,
 };
 
 /* Needed early in initialization */