[PATCH RFC 16/27] sched/psi: let procfs own the seq_file of the pressure files

From: Christian Brauner

Date: Mon Nov 02 2026 - 14:07:09 EST


Declare the show functions and let procfs open and free the seq_file of
/proc/pressure/*. That makes the open functions unnecessary and
->proc_release() only destroys the trigger now.

Signed-off-by: Christian Brauner (Amutable) <brauner@xxxxxxxxxx>
---
kernel/sched/psi.c | 38 +++++---------------------------------
1 file changed, 5 insertions(+), 33 deletions(-)

diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 7c5381423334..bcb8bf4e0b69 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -1535,21 +1535,6 @@ static int psi_cpu_show(struct seq_file *m, void *v)
return psi_show(m, &psi_system, PSI_CPU);
}

-static int psi_io_open(struct inode *inode, struct file *file)
-{
- return single_open(file, psi_io_show, NULL);
-}
-
-static int psi_memory_open(struct inode *inode, struct file *file)
-{
- return single_open(file, psi_memory_show, NULL);
-}
-
-static int psi_cpu_open(struct inode *inode, struct file *file)
-{
- return single_open(file, psi_cpu_show, NULL);
-}
-
static ssize_t psi_write(struct file *file, const char __user *user_buf,
size_t nbytes, enum psi_res res)
{
@@ -1635,31 +1620,25 @@ static int psi_fop_release(struct inode *inode, struct file *file)
struct seq_file *seq = file->private_data;

psi_trigger_destroy(seq->private);
- return single_release(inode, file);
+ return 0;
}

static const struct proc_ops psi_io_proc_ops = {
- .proc_open = psi_io_open,
- .proc_read = seq_read,
- .proc_lseek = seq_lseek,
+ .proc_show = psi_io_show,
.proc_write = psi_io_write,
.proc_poll = psi_fop_poll,
.proc_release = psi_fop_release,
};

static const struct proc_ops psi_memory_proc_ops = {
- .proc_open = psi_memory_open,
- .proc_read = seq_read,
- .proc_lseek = seq_lseek,
+ .proc_show = psi_memory_show,
.proc_write = psi_memory_write,
.proc_poll = psi_fop_poll,
.proc_release = psi_fop_release,
};

static const struct proc_ops psi_cpu_proc_ops = {
- .proc_open = psi_cpu_open,
- .proc_read = seq_read,
- .proc_lseek = seq_lseek,
+ .proc_show = psi_cpu_show,
.proc_write = psi_cpu_write,
.proc_poll = psi_fop_poll,
.proc_release = psi_fop_release,
@@ -1671,11 +1650,6 @@ static int psi_irq_show(struct seq_file *m, void *v)
return psi_show(m, &psi_system, PSI_IRQ);
}

-static int psi_irq_open(struct inode *inode, struct file *file)
-{
- return single_open(file, psi_irq_show, NULL);
-}
-
static ssize_t psi_irq_write(struct file *file, const char __user *user_buf,
size_t nbytes, loff_t *ppos)
{
@@ -1683,9 +1657,7 @@ static ssize_t psi_irq_write(struct file *file, const char __user *user_buf,
}

static const struct proc_ops psi_irq_proc_ops = {
- .proc_open = psi_irq_open,
- .proc_read = seq_read,
- .proc_lseek = seq_lseek,
+ .proc_show = psi_irq_show,
.proc_write = psi_irq_write,
.proc_poll = psi_fop_poll,
.proc_release = psi_fop_release,

--
2.53.0