]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
seqlock: Change do_task_stat() to use scoped_seqlock_read()
authorOleg Nesterov <oleg@redhat.com>
Wed, 8 Oct 2025 12:30:59 +0000 (14:30 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 21 Oct 2025 10:31:57 +0000 (12:31 +0200)
To simplify the code and make it more readable.

[peterz: change to new interface]
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
fs/proc/array.c

index 2ae63189091e020cadc8a60504cfa4a994b1b647..cbd4bc4a58e41cddbc0bb9a4760bfd7789f750c2 100644 (file)
@@ -481,7 +481,6 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
        unsigned long flags;
        int exit_code = task->exit_code;
        struct signal_struct *sig = task->signal;
-       unsigned int seq = 1;
 
        state = *get_task_state(task);
        vsize = eip = esp = 0;
@@ -538,10 +537,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
        if (permitted && (!whole || num_threads < 2))
                wchan = !task_is_running(task);
 
-       do {
-               seq++; /* 2 on the 1st/lockless path, otherwise odd */
-               flags = read_seqbegin_or_lock_irqsave(&sig->stats_lock, &seq);
-
+       scoped_seqlock_read (&sig->stats_lock, ss_lock_irqsave) {
                cmin_flt = sig->cmin_flt;
                cmaj_flt = sig->cmaj_flt;
                cutime = sig->cutime;
@@ -563,8 +559,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
                        }
                        rcu_read_unlock();
                }
-       } while (need_seqretry(&sig->stats_lock, seq));
-       done_seqretry_irqrestore(&sig->stats_lock, seq, flags);
+       }
 
        if (whole) {
                thread_group_cputime_adjusted(task, &utime, &stime);