sched/wdog: Faster wdog deleting.

This commit reduced 1 write operation for wdog deleting and decoupled
the WDOG_ISACTIVE with the list implementation.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
ouyangxiangzhen
2025-12-22 16:13:55 +08:00
committed by Xiang Xiao
parent 694dfc7a0c
commit 476e02c7e0
4 changed files with 20 additions and 8 deletions
+10 -3
View File
@@ -138,20 +138,27 @@
} \ } \
while (0) while (0)
#define list_delete(item) \ #define list_delete_fast(item) \
do \ do \
{ \ { \
FAR struct list_node *__item = (item); \ FAR struct list_node *__item = (item); \
__item->next->prev = __item->prev; \ __item->next->prev = __item->prev; \
__item->prev->next = __item->next; \ __item->prev->next = __item->next; \
__item->prev = __item->next = NULL; \ } \
while (0)
#define list_delete(item) \
do \
{ \
list_delete_fast(item); \
list_clear_node(item); \
} \ } \
while (0) while (0)
#define list_delete_init(item) \ #define list_delete_init(item) \
do \ do \
{ \ { \
list_delete(item); \ list_delete_fast(item); \
list_initialize(item); \ list_initialize(item); \
} \ } \
while (0) while (0)
+1 -1
View File
@@ -39,7 +39,7 @@
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
#define WDOG_ISACTIVE(w) (list_in_list(&((w)->node))) #define WDOG_ISACTIVE(w) ((w)->func != NULL)
/* The maximum delay tick are supposed to be CLOCK_MAX >> 1. /* The maximum delay tick are supposed to be CLOCK_MAX >> 1.
* However, if there are expired wdog timers in the wdog queue, * However, if there are expired wdog timers in the wdog queue,
+5 -1
View File
@@ -84,7 +84,11 @@ int wd_cancel(FAR struct wdog_s *wdog)
/* Now, remove the watchdog from the timer queue */ /* Now, remove the watchdog from the timer queue */
list_delete(&wdog->node); list_delete_fast(&wdog->node);
/* Mark the watchdog inactive */
wdog->func = NULL;
spin_unlock_irqrestore(&g_wdspinlock, flags); spin_unlock_irqrestore(&g_wdspinlock, flags);
+4 -3
View File
@@ -140,12 +140,13 @@ static inline_function void wd_expiration(clock_t ticks)
/* Remove the watchdog from the head of the list */ /* Remove the watchdog from the head of the list */
list_delete(&wdog->node); list_delete_fast(&wdog->node);
/* Indicate that the watchdog is no longer active. */ /* Indicate that the watchdog is no longer active. */
func = wdog->func; func = wdog->func;
arg = wdog->arg; arg = wdog->arg;
wdog->func = NULL;
/* Execute the watchdog function */ /* Execute the watchdog function */
@@ -286,7 +287,7 @@ int wd_start_abstick(FAR struct wdog_s *wdog, clock_t ticks,
if (WDOG_ISACTIVE(wdog)) if (WDOG_ISACTIVE(wdog))
{ {
reassess |= list_is_head(&g_wdactivelist, &wdog->node); reassess |= list_is_head(&g_wdactivelist, &wdog->node);
list_delete(&wdog->node); list_delete_fast(&wdog->node);
} }
reassess |= wd_insert(wdog, ticks, wdentry, arg); reassess |= wd_insert(wdog, ticks, wdentry, arg);
@@ -312,7 +313,7 @@ int wd_start_abstick(FAR struct wdog_s *wdog, clock_t ticks,
if (WDOG_ISACTIVE(wdog)) if (WDOG_ISACTIVE(wdog))
{ {
list_delete(&wdog->node); list_delete_fast(&wdog->node);
} }
wd_insert(wdog, ticks, wdentry, arg); wd_insert(wdog, ticks, wdentry, arg);