[PATCH 2/4] taskstats: take the inode once in exe_add_tsk()
From: Bradley Morgan
Date: Sat Oct 31 2026 - 20:57:54 EST
exe_add_tsk() walks exe_file->f_inode twice, once for the superblock
device and once for the inode number. file_inode() is the accessor for
that field, and hoisting the inode out of the two assignments also gets
stats->ac_exe_dev onto one line instead of a split continuation.
Signed-off-by: Bradley Morgan <brads@xxxxxxxxxxxxxx>
---
kernel/taskstats.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index 37422c43b8caa..35e9fa71526cc 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -159,10 +159,11 @@ static void exe_add_tsk(struct taskstats *stats, struct task_struct *tsk)
struct file *exe_file = get_task_exe_file(tsk);
if (exe_file) {
+ struct inode *inode = file_inode(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;
+ stats->ac_exe_dev = huge_encode_dev(inode->i_sb->s_dev);
+ stats->ac_exe_inode = inode->i_ino;
fput(exe_file);
} else {
stats->ac_exe_dev = 0;
--
2.53.0