From 7b41c7a65aff89d870deb2a00911e2688dcd8425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jere=20Lepp=C3=A4nen?= Date: Wed, 17 Jan 2024 11:29:46 +0200 Subject: [PATCH] linux-gen: sched: avoid odp_time_cmp() in schedule_loop_sleep() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reorganize some conditionals in schedule_loop_sleep() in order to make them clearer, and to avoid calling odp_time_cmp() needlessly in some situations. Signed-off-by: Jere Leppänen --- platform/linux-generic/odp_schedule_basic.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/platform/linux-generic/odp_schedule_basic.c b/platform/linux-generic/odp_schedule_basic.c index 3b0a4dce9ae..379f1f828dc 100644 --- a/platform/linux-generic/odp_schedule_basic.c +++ b/platform/linux-generic/odp_schedule_basic.c @@ -1698,16 +1698,13 @@ static inline int schedule_loop_sleep(odp_queue_t *out_queue, uint64_t wait, nanosleep(&ts, NULL); } - if (wait != ODP_SCHED_WAIT || !sleep) { + if (!sleep || wait != ODP_SCHED_WAIT) current = odp_time_local(); - if (odp_time_cmp(start_sleep, current) < 0) - sleep = 1; - } - if (wait == ODP_SCHED_WAIT) - continue; + if (!sleep && odp_time_cmp(start_sleep, current) < 0) + sleep = 1; - if (odp_time_cmp(end, current) < 0) + if (wait != ODP_SCHED_WAIT && odp_time_cmp(end, current) < 0) break; }