From 2d3f0c9d4108fe34b1dce62839f19dd56050f0c8 Mon Sep 17 00:00:00 2001 From: "Hailong.Liu" Date: Fri, 19 Jan 2024 11:22:09 +0800 Subject: [PATCH] ANDROID: Roll back some code to fix system_server registers psi trigger failed. the commit 2c1e89916b2bbab7e4b9cf2488ef778a949efcb5 revert part of https://android-review.googlesource.com/c/kernel/common/+/2199758 causing system_server registers psi trigger failed due to lack of CAP_SYS_RESOURCE capability. Bug: 243781242 Bug: 244148051 Signed-off-by: Hailong.Liu Change-Id: Ie22ea6f7a7dc848fa8307e6f4e8223779367df31 --- kernel/sched/psi.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c index 0c9c1c545926..55be195660a9 100644 --- a/kernel/sched/psi.c +++ b/kernel/sched/psi.c @@ -1410,27 +1410,19 @@ static int psi_cpu_show(struct seq_file *m, void *v) return psi_show(m, &psi_system, PSI_CPU); } -static int psi_open(struct file *file, int (*psi_show)(struct seq_file *, void *)) -{ - if (file->f_mode & FMODE_WRITE && !capable(CAP_SYS_RESOURCE)) - return -EPERM; - - return single_open(file, psi_show, NULL); -} - static int psi_io_open(struct inode *inode, struct file *file) { - return psi_open(file, psi_io_show); + return single_open(file, psi_io_show, NULL); } static int psi_memory_open(struct inode *inode, struct file *file) { - return psi_open(file, psi_memory_show); + return single_open(file, psi_memory_show, NULL); } static int psi_cpu_open(struct inode *inode, struct file *file) { - return psi_open(file, psi_cpu_show); + return single_open(file, psi_cpu_show, NULL); } static ssize_t psi_write(struct file *file, const char __user *user_buf, @@ -1544,7 +1536,7 @@ static int psi_irq_show(struct seq_file *m, void *v) static int psi_irq_open(struct inode *inode, struct file *file) { - return psi_open(file, psi_irq_show); + return single_open(file, psi_irq_show, NULL); } static ssize_t psi_irq_write(struct file *file, const char __user *user_buf,