Re: [PATCH] sched: change printk(KERN_<LEVEL>.. to pr_<level>()

From: Joe Perches
Date: Thu May 26 2022 - 05:42:44 EST


On Thu, 2022-05-26 at 02:10 -0700, Yu Zhe wrote:
> Prefer pr_<level>(... to printk(KERN_<LEVEL> ..., change them.

Do remember that checkpatch is just a guide and isn't always correct.

You are responsible for verifying that anything it suggests is
converted properly.

> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
[]
> @@ -9370,7 +9370,7 @@ static void dump_rq_tasks(struct rq *rq, const char *loglvl)
>
> lockdep_assert_rq_held(rq);
>
> - printk("%sCPU%d enqueued tasks (%u total):\n", loglvl, cpu, rq->nr_running);
> + pr_warn("%sCPU%d enqueued tasks (%u total):\n", loglvl, cpu, rq->nr_running);

This is _not_ a good change.

Do please look to see what loglvl is and if this change is appropriate.

> for_each_process_thread(g, p) {
> if (task_cpu(p) != cpu)
> continue;
> @@ -9378,7 +9378,7 @@ static void dump_rq_tasks(struct rq *rq, const char *loglvl)
> if (!task_on_rq_queued(p))
> continue;
>
> - printk("%s\tpid: %d, name: %s\n", loglvl, p->pid, p->comm);
> + pr_warn("%s\tpid: %d, name: %s\n", loglvl, p->pid, p->comm);

here too.