public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] timekeeping: Convert to use jiffies macro
@ 2024-08-26  3:27 Chen Yufan
  2024-08-26 21:46 ` Thomas Gleixner
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Yufan @ 2024-08-26  3:27 UTC (permalink / raw)
  To: John Stultz, Thomas Gleixner, Stephen Boyd, linux-kernel
  Cc: opensource.kernel, Chen Yufan

Use time_after instead of using
jiffies directly to handle wraparound.

Signed-off-by: Chen Yufan <chenyufan@vivo.com>
---
The modifications made compared to the previous version are as follows:
1. change the type of timekeeper::last_warning to
unsigned long.
---
 include/linux/timekeeper_internal.h | 2 +-
 kernel/time/timekeeping.c           | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/linux/timekeeper_internal.h b/include/linux/timekeeper_internal.h
index 84ff2844df2a..928a9258b7dd 100644
--- a/include/linux/timekeeper_internal.h
+++ b/include/linux/timekeeper_internal.h
@@ -125,7 +125,7 @@ struct timekeeper {
 	/* Flag used to avoid updating NTP twice with same second */
 	u32			skip_second_overflow;
 #ifdef CONFIG_DEBUG_TIMEKEEPING
-	long			last_warning;
+	unsigned long			last_warning;
 	/*
 	 * These simple flag variables are managed
 	 * without locks, which is racy, but they are
diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 5391e4167d60..6cda65dbe18f 100644
--- a/kernel/time/timekeeping.c
+++ b/kernel/time/timekeeping.c
@@ -217,7 +217,7 @@ static void timekeeping_check_update(struct timekeeper *tk, u64 offset)
 	}
 
 	if (tk->underflow_seen) {
-		if (jiffies - tk->last_warning > WARNING_FREQ) {
+		if (time_after(jiffies, tk->last_warning + WARNING_FREQ)) {
 			printk_deferred("WARNING: Underflow in clocksource '%s' observed, time update ignored.\n", name);
 			printk_deferred("         Please report this, consider using a different clocksource, if possible.\n");
 			printk_deferred("         Your kernel is probably still fine.\n");
@@ -227,7 +227,7 @@ static void timekeeping_check_update(struct timekeeper *tk, u64 offset)
 	}
 
 	if (tk->overflow_seen) {
-		if (jiffies - tk->last_warning > WARNING_FREQ) {
+		if (time_after(jiffies, tk->last_warning + WARNING_FREQ)) {
 			printk_deferred("WARNING: Overflow in clocksource '%s' observed, time update capped.\n", name);
 			printk_deferred("         Please report this, consider using a different clocksource, if possible.\n");
 			printk_deferred("         Your kernel is probably still fine.\n");
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] timekeeping: Convert to use jiffies macro
  2024-08-26  3:27 [PATCH v2] timekeeping: Convert to use jiffies macro Chen Yufan
@ 2024-08-26 21:46 ` Thomas Gleixner
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2024-08-26 21:46 UTC (permalink / raw)
  To: Chen Yufan, John Stultz, Stephen Boyd, linux-kernel
  Cc: opensource.kernel, Chen Yufan

Chen!

On Mon, Aug 26 2024 at 11:27, Chen Yufan wrote:
> Use time_after instead of using
> jiffies directly to handle wraparound.

This kind of terse changelog is really not cutting it.

There is zero explanation why this requires to change the type of
timekeeper::last_warning.

I also fixed up the subject line for you when I applied the previous
patch and you got an email when I applied it which made you aware of
that change.

Please pay attention to such details and stop copy and pasting a boiler
plate text into the change log. I fixed it up for you only once.

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-26 21:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-26  3:27 [PATCH v2] timekeeping: Convert to use jiffies macro Chen Yufan
2024-08-26 21:46 ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox