From d88c2de8fc355159ca6a89efd26cd93550d91aa2 Mon Sep 17 00:00:00 2001 From: hujun5 Date: Wed, 11 Dec 2024 16:40:52 +0800 Subject: [PATCH] clock_adjtime: use small lock to protect g_adjtime_ppb g_adjtime_wdog reason: We would like to replace the critical section with a small lock. Signed-off-by: hujun5 --- sched/clock/clock_adjtime.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sched/clock/clock_adjtime.c b/sched/clock/clock_adjtime.c index 3244ad59d6e88..99c4c01954874 100644 --- a/sched/clock/clock_adjtime.c +++ b/sched/clock/clock_adjtime.c @@ -49,6 +49,7 @@ static struct wdog_s g_adjtime_wdog; static long g_adjtime_ppb; +static spinlock_t g_adjtime_lock = SP_UNLOCKED; /**************************************************************************** * Private Functions @@ -108,7 +109,7 @@ static int adjtime_start(long long adjust_usec) ppb = -ppb_limit; } - flags = enter_critical_section(); + flags = spin_lock_irqsave(&g_adjtime_lock); /* Set new adjustment */ @@ -134,7 +135,7 @@ static int adjtime_start(long long adjust_usec) wd_cancel(&g_adjtime_wdog); } - leave_critical_section(flags); + spin_unlock_irqrestore(&g_adjtime_lock, flags); return ret; }