From d05d9454bf29ee9c6a619e55bb109da57fd0091c Mon Sep 17 00:00:00 2001 From: Peter Mitsis Date: Wed, 30 Apr 2025 11:22:35 -0700 Subject: [PATCH] kernel: Remove superfluous thread_is_sliceable() call Within z_sched_ipi() there is no need for the thread_is_sliceable() test as z_time_slice() performs that check. Since as a result of this thread_is_sliceable() is now only used within timeslicing.c, the 'static' keyword is applied to it. Signed-off-by: Peter Mitsis --- kernel/include/ksched.h | 1 - kernel/ipi.c | 4 +--- kernel/timeslicing.c | 4 ++-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/kernel/include/ksched.h b/kernel/include/ksched.h index 40168b006f0..8f0fa89f9bc 100644 --- a/kernel/include/ksched.h +++ b/kernel/include/ksched.h @@ -73,7 +73,6 @@ void z_ready_thread(struct k_thread *thread); void z_requeue_current(struct k_thread *curr); struct k_thread *z_swap_next_thread(void); void move_current_to_end_of_prio_q(void); -bool thread_is_sliceable(struct k_thread *thread); static inline void z_reschedule_unlocked(void) { diff --git a/kernel/ipi.c b/kernel/ipi.c index abed831f734..13377ee26c5 100644 --- a/kernel/ipi.c +++ b/kernel/ipi.c @@ -191,9 +191,7 @@ void z_sched_ipi(void) #endif /* CONFIG_TRACE_SCHED_IPI */ #ifdef CONFIG_TIMESLICING - if (thread_is_sliceable(_current)) { - z_time_slice(); - } + z_time_slice(); #endif /* CONFIG_TIMESLICING */ #ifdef CONFIG_ARCH_IPI_LAZY_COPROCESSORS_SAVE diff --git a/kernel/timeslicing.c b/kernel/timeslicing.c index c0ba534d59a..c6b7d81019f 100644 --- a/kernel/timeslicing.c +++ b/kernel/timeslicing.c @@ -36,7 +36,7 @@ static inline int slice_time(struct k_thread *thread) return ret; } -bool thread_is_sliceable(struct k_thread *thread) +static bool thread_is_sliceable(struct k_thread *thread) { bool ret = thread_is_preemptible(thread) && slice_time(thread) != 0 @@ -99,7 +99,7 @@ void k_thread_time_slice_set(struct k_thread *thread, int32_t thread_slice_ticks } #endif -/* Called out of each timer interrupt */ +/* Called out of each timer and IPI interrupt */ void z_time_slice(void) { k_spinlock_key_t key = k_spin_lock(&_sched_spinlock);