Skip to content

Commit b76f72b

Browse files
oleg-nesterovPeter Zijlstra
authored andcommitted
seqlock: Change do_task_stat() to use scoped_seqlock_read()
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>
1 parent 488f48b commit b76f72b

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

fs/proc/array.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,6 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
481481
unsigned long flags;
482482
int exit_code = task->exit_code;
483483
struct signal_struct *sig = task->signal;
484-
unsigned int seq = 1;
485484

486485
state = *get_task_state(task);
487486
vsize = eip = esp = 0;
@@ -538,10 +537,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
538537
if (permitted && (!whole || num_threads < 2))
539538
wchan = !task_is_running(task);
540539

541-
do {
542-
seq++; /* 2 on the 1st/lockless path, otherwise odd */
543-
flags = read_seqbegin_or_lock_irqsave(&sig->stats_lock, &seq);
544-
540+
scoped_seqlock_read (&sig->stats_lock, ss_lock_irqsave) {
545541
cmin_flt = sig->cmin_flt;
546542
cmaj_flt = sig->cmaj_flt;
547543
cutime = sig->cutime;
@@ -563,8 +559,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
563559
}
564560
rcu_read_unlock();
565561
}
566-
} while (need_seqretry(&sig->stats_lock, seq));
567-
done_seqretry_irqrestore(&sig->stats_lock, seq, flags);
562+
}
568563

569564
if (whole) {
570565
thread_group_cputime_adjusted(task, &utime, &stime);

0 commit comments

Comments
 (0)