[PATCH] sched/psi: fix unnecessary KERN_ERR and memory barrier comment

Pintu Kumar posted 1 patch 1 month, 4 weeks ago
kernel/sched/psi.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH] sched/psi: fix unnecessary KERN_ERR and memory barrier comment
Posted by Pintu Kumar 1 month, 4 weeks ago
These warnings were reported by checkpatch.
Fix them with minor changes.

WARNING: Possible unnecessary KERN_ERR
+                       printk_deferred(KERN_ERR "psi: task underflow! cpu=%d t=%d tasks=[%u %u %u %u] clear=%x set=%x\n",

WARNING: Possible unnecessary KERN_ERR
+               printk_deferred(KERN_ERR "psi: inconsistent task state! task=%d:%s cpu=%d psi_flags=%x clear=%x set=%x\n",

WARNING: memory barrier without comment
+       t = smp_load_acquire(trigger_ptr);

WARNING: memory barrier without comment
+       smp_store_release(&seq->private, new);

Signed-off-by: Pintu Kumar <quic_pintu@quicinc.com>
---
 kernel/sched/psi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
index 020d58967d4e..ca4c5c2c7478 100644
--- a/kernel/sched/psi.c
+++ b/kernel/sched/psi.c
@@ -816,7 +816,7 @@ static void psi_group_change(struct psi_group *group, int cpu,
 		if (groupc->tasks[t]) {
 			groupc->tasks[t]--;
 		} else if (!psi_bug) {
-			printk_deferred(KERN_ERR "psi: task underflow! cpu=%d t=%d tasks=[%u %u %u %u] clear=%x set=%x\n",
+			printk_deferred("psi: task underflow! cpu=%d t=%d tasks=[%u %u %u %u] clear=%x set=%x\n",
 					cpu, t, groupc->tasks[0],
 					groupc->tasks[1], groupc->tasks[2],
 					groupc->tasks[3], clear, set);
@@ -885,7 +885,7 @@ static void psi_flags_change(struct task_struct *task, int clear, int set)
 	if (((task->psi_flags & set) ||
 	     (task->psi_flags & clear) != clear) &&
 	    !psi_bug) {
-		printk_deferred(KERN_ERR "psi: inconsistent task state! task=%d:%s cpu=%d psi_flags=%x clear=%x set=%x\n",
+		printk_deferred("psi: inconsistent task state! task=%d:%s cpu=%d psi_flags=%x clear=%x set=%x\n",
 				task->pid, task->comm, task_cpu(task),
 				task->psi_flags, clear, set);
 		psi_bug = 1;
@@ -1474,6 +1474,7 @@ __poll_t psi_trigger_poll(void **trigger_ptr,
 	if (static_branch_likely(&psi_disabled))
 		return DEFAULT_POLLMASK | EPOLLERR | EPOLLPRI;
 
+	/* Pairs with the smp_store_release in psi_write */
 	t = smp_load_acquire(trigger_ptr);
 	if (!t)
 		return DEFAULT_POLLMASK | EPOLLERR | EPOLLPRI;
@@ -1557,6 +1558,7 @@ static ssize_t psi_write(struct file *file, const char __user *user_buf,
 		return PTR_ERR(new);
 	}
 
+	/* Pairs with the smp_store_acquire in psi_trigger_poll */
 	smp_store_release(&seq->private, new);
 	mutex_unlock(&seq->lock);
 
-- 
2.17.1
Re: [PATCH] sched/psi: fix unnecessary KERN_ERR and memory barrier comment
Posted by Joe Perches 1 month, 3 weeks ago
On Mon, 2024-09-30 at 19:21 +0530, Pintu Kumar wrote:
> These warnings were reported by checkpatch.
> Fix them with minor changes.
> 
> WARNING: Possible unnecessary KERN_ERR
> +                       printk_deferred(KERN_ERR "psi: task underflow! cpu=%d t=%d tasks=[%u %u %u %u] clear=%x set=%x\n",

printk_deferred does not have pr_<level>_deferred variants
so a KERN_<LEVEL> use here is appropriate.
Re: [PATCH] sched/psi: fix unnecessary KERN_ERR and memory barrier comment
Posted by Pintu Agarwal 1 month, 3 weeks ago
Hi Joe,

On Wed, 2 Oct 2024 at 05:57, Joe Perches <joe@perches.com> wrote:
>
> On Mon, 2024-09-30 at 19:21 +0530, Pintu Kumar wrote:
> > These warnings were reported by checkpatch.
> > Fix them with minor changes.
> >
> > WARNING: Possible unnecessary KERN_ERR
> > +                       printk_deferred(KERN_ERR "psi: task underflow! cpu=%d t=%d tasks=[%u %u %u %u] clear=%x set=%x\n",
>
> printk_deferred does not have pr_<level>_deferred variants
> so a KERN_<LEVEL> use here is appropriate.
>
Thank you so much for your review.
Okay I will drop this one and only include the other one related to
"memory barrier missing comments".
Will send a v2 patch if you are okay with it.

Thanks,