sched/wdog: Simplify tickless timer expiration. #17993
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This series of commits refactors and simplifies the tickless scheduler's timer expiration code.
The key changes are:
g_timer_interval): The global atomic variableg_timer_interval, which tracked the currently active timer interval, has been eliminated. The next expiration time is now calculated directly from the active watchdog list.CONFIG_SCHED_TICKLESS_LIMIT_MAX_SLEEPandCONFIG_TIMER_ADJUST_USEC) has been moved fromsched_timerexpiration.cinto the watchdog module as a new inline functionwd_adjust_next_tick(). This simplifies the scheduler'snxsched_timer_start()function.g_wdexpiredis introduced to store the tick count at which the watchdog timer actually expired. This allows the scheduler event handler (nxsched_process_event) to use this pre-fetched value, avoiding a redundant call toup_timer_gettick()during timer expiration processing. The tick is only fetched again when reassessing the timer vianxsched_reassess_timer().up_timer_tick_start,up_alarm_tick_start) are consolidated and thewd_timer_start()function is significantly simplified by usingwd_adjust_next_tick().nxsched_process_timer()to trigger the scheduler on every timer expiration whenCONFIG_RR_INTERVAL > 0. This mitigates an existing issue where a preempted round-robin task's timeslice counter may not decrement correctly. This is temporary until the core SCHED_RR behavior is fixed.wd_get_next_expire()is added to provide a safe way to get the next watchdog expiration time relative to the current time, returning 0 if it's in the past.These changes improve code maintainability by reducing state duplication, centralizing configuration-dependent logic, and clarifying the flow of time information through the tickless scheduler and watchdog subsystem.
Impact
up_timer_gettick(),up_timer_start(), andup_alarm_start()architecture interfaces.Testing
Internal CT passed. Tested on
rv-virt:smp,ostestpassed.