From 7737efd9954a5090e5aa3129ae8966066abe39c1 Mon Sep 17 00:00:00 2001 From: zhangyuan21 Date: Thu, 8 Jun 2023 19:14:44 +0800 Subject: [PATCH] SMP: fix repeat entry timer_start If we are running on a single CPU architecture, then we know interrupts are disabled and there is no need to explicitly call enter_critical_section(). However, in the SMP case, enter_critical_section() is required prevent multiple cpu to enter timer_start. Signed-off-by: zhangyuan21 --- sched/sched/sched_timerexpiration.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sched/sched/sched_timerexpiration.c b/sched/sched/sched_timerexpiration.c index 030ce38f00..5fb6d7743c 100644 --- a/sched/sched/sched_timerexpiration.c +++ b/sched/sched/sched_timerexpiration.c @@ -601,6 +601,16 @@ void nxsched_timer_expiration(void) { unsigned int elapsed; unsigned int nexttime; + irqstate_t flags; + + /* If we are running on a single CPU architecture, then we know interrupts + * are disabled and there is no need to explicitly call + * enter_critical_section(). However, in the SMP case, + * enter_critical_section() is required prevent multiple cpu to enter + * oneshot_tick_start. + */ + + flags = enter_critical_section(); /* Get the interval associated with last expiration */ @@ -617,6 +627,7 @@ void nxsched_timer_expiration(void) nexttime = nxsched_timer_process(elapsed, false); nxsched_timer_start(nexttime); + leave_critical_section(flags); } #endif