Skip to content

Commit d96d16a

Browse files
committed
Merge: do_io_accounting: use sig->stats_lock
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7164 JIRA: https://issues.redhat.com/browse/RHEL-105165 MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7164 Patch 1 is just a proactive fix backported for the same fs/proc/base.c file. Patches 2 and 3 are the one requested by the reporter. Signed-off-by: Waiman Long <longman@redhat.com> Approved-by: Brian Foster <bfoster@redhat.com> Approved-by: Rafael Aquini <raquini@redhat.com> Approved-by: Oleg Nesterov <oleg@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Patrick Talbert <ptalbert@redhat.com>
2 parents 6333e8d + 9c1fe3b commit d96d16a

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

fs/proc/base.c

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2948,8 +2948,7 @@ static const struct file_operations proc_coredump_filter_operations = {
29482948
#ifdef CONFIG_TASK_IO_ACCOUNTING
29492949
static int do_io_accounting(struct task_struct *task, struct seq_file *m, int whole)
29502950
{
2951-
struct task_io_accounting acct = task->ioac;
2952-
unsigned long flags;
2951+
struct task_io_accounting acct;
29532952
int result;
29542953

29552954
result = down_read_killable(&task->signal->exec_update_lock);
@@ -2961,15 +2960,28 @@ static int do_io_accounting(struct task_struct *task, struct seq_file *m, int wh
29612960
goto out_unlock;
29622961
}
29632962

2964-
if (whole && lock_task_sighand(task, &flags)) {
2965-
struct task_struct *t = task;
2963+
if (whole) {
2964+
struct signal_struct *sig = task->signal;
2965+
struct task_struct *t;
2966+
unsigned int seq = 1;
2967+
unsigned long flags;
2968+
2969+
rcu_read_lock();
2970+
do {
2971+
seq++; /* 2 on the 1st/lockless path, otherwise odd */
2972+
flags = read_seqbegin_or_lock_irqsave(&sig->stats_lock, &seq);
29662973

2967-
task_io_accounting_add(&acct, &task->signal->ioac);
2968-
while_each_thread(task, t)
2969-
task_io_accounting_add(&acct, &t->ioac);
2974+
acct = sig->ioac;
2975+
__for_each_thread(sig, t)
2976+
task_io_accounting_add(&acct, &t->ioac);
29702977

2971-
unlock_task_sighand(task, &flags);
2978+
} while (need_seqretry(&sig->stats_lock, seq));
2979+
done_seqretry_irqrestore(&sig->stats_lock, seq, flags);
2980+
rcu_read_unlock();
2981+
} else {
2982+
acct = task->ioac;
29722983
}
2984+
29732985
seq_printf(m,
29742986
"rchar: %llu\n"
29752987
"wchar: %llu\n"
@@ -3555,7 +3567,8 @@ static int proc_tid_comm_permission(struct mnt_idmap *idmap,
35553567
}
35563568

35573569
static const struct inode_operations proc_tid_comm_inode_operations = {
3558-
.permission = proc_tid_comm_permission,
3570+
.setattr = proc_setattr,
3571+
.permission = proc_tid_comm_permission,
35593572
};
35603573

35613574
/*

0 commit comments

Comments
 (0)