[PATCH] timers/tick_sched: combine WARN_ON_ONCE and print_once

Anna-Maria Behnsen posted 1 patch 1 year, 8 months ago
kernel/time/tick-sched.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
[PATCH] timers/tick_sched: combine WARN_ON_ONCE and print_once
Posted by Anna-Maria Behnsen 1 year, 8 months ago
When the WARN_ON_ONCE() triggers, the printk of the additional information
related to the warning will not happen in print level "warn". When reading
the dmesg with a restriction to level "warn", the information published by
the printk_once() will not show up there.

Transform WARN_ON_ONCE() and printk_once() into a WARN_ONCE().

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
---
 kernel/time/tick-sched.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 71a792cd8936..afeae34e2a09 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -1026,10 +1026,10 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu)
 		if (expires == KTIME_MAX || ts->next_tick == hrtimer_get_expires(&ts->sched_timer))
 			return;
 
-		WARN_ON_ONCE(1);
-		printk_once("basemono: %llu ts->next_tick: %llu dev->next_event: %llu timer->active: %d timer->expires: %llu\n",
-			    basemono, ts->next_tick, dev->next_event,
-			    hrtimer_active(&ts->sched_timer), hrtimer_get_expires(&ts->sched_timer));
+		WARN_ONCE(1, "basemono: %llu ts->next_tick: %llu dev->next_event: %llu "
+			  "timer->active: %d timer->expires: %llu\n", basemono, ts->next_tick,
+			  dev->next_event, hrtimer_active(&ts->sched_timer),
+			  hrtimer_get_expires(&ts->sched_timer));
 	}
 
 	/*
-- 
2.39.2
Re: [PATCH] timers/tick_sched: combine WARN_ON_ONCE and print_once
Posted by Frederic Weisbecker 1 year, 7 months ago
Le Mon, Jun 10, 2024 at 12:35:52PM +0200, Anna-Maria Behnsen a écrit :
> When the WARN_ON_ONCE() triggers, the printk of the additional information
> related to the warning will not happen in print level "warn". When reading
> the dmesg with a restriction to level "warn", the information published by
> the printk_once() will not show up there.
> 
> Transform WARN_ON_ONCE() and printk_once() into a WARN_ONCE().
> 
> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>

Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Re: [PATCH] timers/tick_sched: combine WARN_ON_ONCE and print_once
Posted by Anna-Maria Behnsen 1 year, 7 months ago
Gentle ping :)

And please replace print_once by printk_once in subject line when
reading.

Anna-Maria Behnsen <anna-maria@linutronix.de> writes:

> When the WARN_ON_ONCE() triggers, the printk of the additional information
> related to the warning will not happen in print level "warn". When reading
> the dmesg with a restriction to level "warn", the information published by
> the printk_once() will not show up there.
>
> Transform WARN_ON_ONCE() and printk_once() into a WARN_ONCE().
>
> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
> ---
>  kernel/time/tick-sched.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
> index 71a792cd8936..afeae34e2a09 100644
> --- a/kernel/time/tick-sched.c
> +++ b/kernel/time/tick-sched.c
> @@ -1026,10 +1026,10 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu)
>  		if (expires == KTIME_MAX || ts->next_tick == hrtimer_get_expires(&ts->sched_timer))
>  			return;
>  
> -		WARN_ON_ONCE(1);
> -		printk_once("basemono: %llu ts->next_tick: %llu dev->next_event: %llu timer->active: %d timer->expires: %llu\n",
> -			    basemono, ts->next_tick, dev->next_event,
> -			    hrtimer_active(&ts->sched_timer), hrtimer_get_expires(&ts->sched_timer));
> +		WARN_ONCE(1, "basemono: %llu ts->next_tick: %llu dev->next_event: %llu "
> +			  "timer->active: %d timer->expires: %llu\n", basemono, ts->next_tick,
> +			  dev->next_event, hrtimer_active(&ts->sched_timer),
> +			  hrtimer_get_expires(&ts->sched_timer));
>  	}
>  
>  	/*
[tip: timers/core] tick/sched: Combine WARN_ON_ONCE and print_once
Posted by tip-bot2 for Anna-Maria Behnsen 1 year, 7 months ago
The following commit has been merged into the timers/core branch of tip:

Commit-ID:     59dbee7d4d59425658b1d86238732c575216b718
Gitweb:        https://git.kernel.org/tip/59dbee7d4d59425658b1d86238732c575216b718
Author:        Anna-Maria Behnsen <anna-maria@linutronix.de>
AuthorDate:    Mon, 10 Jun 2024 12:35:52 +02:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 03 Jul 2024 21:32:55 +02:00

tick/sched: Combine WARN_ON_ONCE and print_once

When the WARN_ON_ONCE() triggers, the printk() of the additional
information related to the warning will not happen in print level
"warn". When reading dmesg with a restriction to level "warn", the
information published by the printk_once() will not show up there.

Transform WARN_ON_ONCE() and printk_once() into a WARN_ONCE().

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20240610103552.25252-1-anna-maria@linutronix.de

---
 kernel/time/tick-sched.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 43a6370..753a184 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -1026,10 +1026,10 @@ static void tick_nohz_stop_tick(struct tick_sched *ts, int cpu)
 		if (expires == KTIME_MAX || ts->next_tick == hrtimer_get_expires(&ts->sched_timer))
 			return;
 
-		WARN_ON_ONCE(1);
-		printk_once("basemono: %llu ts->next_tick: %llu dev->next_event: %llu timer->active: %d timer->expires: %llu\n",
-			    basemono, ts->next_tick, dev->next_event,
-			    hrtimer_active(&ts->sched_timer), hrtimer_get_expires(&ts->sched_timer));
+		WARN_ONCE(1, "basemono: %llu ts->next_tick: %llu dev->next_event: %llu "
+			  "timer->active: %d timer->expires: %llu\n", basemono, ts->next_tick,
+			  dev->next_event, hrtimer_active(&ts->sched_timer),
+			  hrtimer_get_expires(&ts->sched_timer));
 	}
 
 	/*