From 7ff7f6ec21614ebfd02575b43c35f350f6157523 Mon Sep 17 00:00:00 2001 From: ligd Date: Fri, 6 Sep 2024 21:01:43 +0800 Subject: [PATCH] wdog: optimize a bit speed in wd_start After these wdog refactor: We conducted a latency measurement using the rt-tests/cyclictest (commit cadd661) on an x86_64 NUC12 equipped with an i7-1255U processor and 16GB of LPDDR5 memory. The specific command used for this microbenchmark was cyclictest -q -l 100000 -h 30000, which is designed to assess the responsiveness of the cyclic timer. The findings from our benchmark are summarized below, highlighting the minimum, median, and maximum latency values for each operating system tested: Operating System Minimum Latency (us) Median Latency (us) Maximum Latency (us) Linux 48 53 410 PreemptRT 6 57 148 Xenomai 53 53 64 NuttX 64 626 1212 NuttX (refactor) 1 1 3 In this table, "Min" indicates the shortest latency observed, "Median" represents the middle value of the latency distribution, and "Max" denotes the longest latency encountered. The systems tested were as follows: Linux: ACRN version 6.1.80 (commit f528146) PreemptRT: Linux kernel 5.4.251 with the 5.4.254-rt85 patch applied Xenomai: Linux kernel 5.4.251 patched with ipipe-core-5.4.239-x86-13 These results clearly demonstrate the varying performance of different operating systems in terms of timer latency, the refactored NuttX showing particularly low latency values. Signed-off-by: ligd --- sched/wdog/wd_start.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sched/wdog/wd_start.c b/sched/wdog/wd_start.c index 1e0a1141d9d..d7a3af9bc7a 100644 --- a/sched/wdog/wd_start.c +++ b/sched/wdog/wd_start.c @@ -178,8 +178,6 @@ void wd_insert(FAR struct wdog_s *wdog, clock_t expired, { FAR struct wdog_s *curr; - DEBUGASSERT(wdog && wdentry); - /* Traverse the watchdog list */ list_for_every_entry(&g_wdactivelist, curr, struct wdog_s, node) @@ -295,8 +293,8 @@ int wd_start_absolute(FAR struct wdog_s *wdog, clock_t ticks, wd_insert(wdog, ticks, wdentry, arg); - reassess |= list_is_head(&g_wdactivelist, &wdog->node); - if (!g_wdtimernested && reassess) + if (!g_wdtimernested && + (reassess || list_is_head(&g_wdactivelist, &wdog->node))) { /* Resume the interval timer that will generate the next * interval event. If the timer at the head of the list changed,