From 20d072465d452aff52181041344e435c5a042d75 Mon Sep 17 00:00:00 2001 From: Yasushi SHOJI Date: Wed, 31 Jul 2019 11:19:08 +0900 Subject: [PATCH] kernel: sched: Do not force preempt when k_sched_unlock() The scheduler lock is a nestable lock. Unlocking a nested, still-having, lock shouldn't preempt the current thread. k_sched_lock(); k_sched_lock(); k_sched_unlock(); /* <--- this shouldn't be a scheduling point */ k_sched_unlock(); /* <--- this is a scheduling point */ This commit changes the preempt_ok argument from 1 to 0. This let should_preempt() check whether it should preempt at the point or not. This fixes #17869. Signed-off-by: Yasushi SHOJI --- kernel/sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched.c b/kernel/sched.c index 43e36133a3a..026804d0577 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -555,7 +555,7 @@ void k_sched_unlock(void) LOCKED(&sched_spinlock) { ++_current->base.sched_locked; - update_cache(1); + update_cache(0); } K_DEBUG("scheduler unlocked (%p:%d)\n",