Commit 0bf44f23 authored by Peter Mitsis's avatar Peter Mitsis Committed by Maureen Helm
Browse files

kernel: Re-order should_preempt() checks



Re-orders the checks in should_preempt() tests so that the
z_is_thread_timeout_active() check is done last.

This change has been observed to give a +7% performance boost on
the thread_metric benchmark's preemptive scheduling test.

Signed-off-by: default avatarPeter Mitsis <peter.mitsis@intel.com>
parent 73d04a49
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -204,6 +204,13 @@ static ALWAYS_INLINE bool should_preempt(struct k_thread *thread,
		return true;
	}

	/* Otherwise we have to be running a preemptible thread or
	 * switching to a metairq
	 */
	if (thread_is_preemptible(_current) || thread_is_metairq(thread)) {
		return true;
	}

	/* Edge case on ARM where a thread can be pended out of an
	 * interrupt handler before the "synchronous" swap starts
	 * context switching.  Platforms with atomic swap can never
@@ -214,13 +221,6 @@ static ALWAYS_INLINE bool should_preempt(struct k_thread *thread,
		return true;
	}

	/* Otherwise we have to be running a preemptible thread or
	 * switching to a metairq
	 */
	if (thread_is_preemptible(_current) || thread_is_metairq(thread)) {
		return true;
	}

	return false;
}