[PATCH] timekeeping: Convert to use time_after macro

Zehao Zhang posted 1 patch 2 years, 7 months ago
kernel/time/timekeeping.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] timekeeping: Convert to use time_after macro
Posted by Zehao Zhang 2 years, 7 months ago
From: Zehao Zhang <zhangzehao@vivo.com>

Use time after macro instead of open it for readability.

Signed-off-by: Zehao Zhang <zhangzehao@vivo.com>
---
 kernel/time/timekeeping.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
index 266d02809dbb..b57bcb9b4ead 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.35.3
Re: [PATCH] timekeeping: Convert to use time_after macro
Posted by John Stultz 2 years, 7 months ago
On Wed, Jul 5, 2023 at 7:16 AM Zehao Zhang <11162513@vivo.com> wrote:
>
> From: Zehao Zhang <zhangzehao@vivo.com>
>
> Use time after macro instead of open it for readability.
>
> Signed-off-by: Zehao Zhang <zhangzehao@vivo.com>

Thanks for sending this along!

Acked-by: John Stultz <jstultz@google.com>