]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
seqlock: Change do_io_accounting() to use scoped_seqlock_read()
authorOleg Nesterov <oleg@redhat.com>
Wed, 8 Oct 2025 12:31:05 +0000 (14:31 +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/base.c

index 6299878e3d97e6ee07489c5a4dd09ee638c05c82..407b41cb6e7c8dae40a01cdd394ee4c6e159deef 100644 (file)
@@ -3043,21 +3043,14 @@ static int do_io_accounting(struct task_struct *task, struct seq_file *m, int wh
        if (whole) {
                struct signal_struct *sig = task->signal;
                struct task_struct *t;
-               unsigned int seq = 1;
-               unsigned long flags;
-
-               rcu_read_lock();
-               do {
-                       seq++; /* 2 on the 1st/lockless path, otherwise odd */
-                       flags = read_seqbegin_or_lock_irqsave(&sig->stats_lock, &seq);
 
+               guard(rcu)();
+               scoped_seqlock_read (&sig->stats_lock, ss_lock_irqsave) {
                        acct = sig->ioac;
                        __for_each_thread(sig, t)
                                task_io_accounting_add(&acct, &t->ioac);
 
-               } while (need_seqretry(&sig->stats_lock, seq));
-               done_seqretry_irqrestore(&sig->stats_lock, seq, flags);
-               rcu_read_unlock();
+               }
        } else {
                acct = task->ioac;
        }