This is an automated email from the ASF dual-hosted git repository.
xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 982cf53544f sched/clock: Remove INITIAL_SYSTEM_TIMER_TICKS.
982cf53544f is described below
commit 982cf53544f55177ee5c5e5f78d52cd11fe90e33
Author: Marco Casaroli <[email protected]>
AuthorDate: Wed Nov 11 03:25:26 2026 +0100
sched/clock: Remove INITIAL_SYSTEM_TIMER_TICKS.
With CONFIG_DEBUG_SCHED, the tick counter started 5 seconds before
UINT32_MAX. This showed errors that cut the 64-bit tick to 32 bits.
But the time since boot then showed the offset:
- With an arch timer (CONFIG_ALARM_ARCH, for example qemu-armv8a:knsh),
clock_systime_ticks() starts at 0 and /proc/uptime subtracts the
offset: it prints "184467440737052".
- With the software tick counter (for example lm3s6965-ek:qemu-flat),
sysinfo() does not subtract the offset: NSH uptime shows 497 days.
The /proc/critmon busy-wait rate also divides by the offset.
clock_t is int64_t, thus the tick counter cannot overflow. Remove
INITIAL_SYSTEM_TIMER_TICKS. The tick counter now starts at 0 in all
configurations. Only configurations with CONFIG_DEBUG_SCHED change.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
fs/procfs/fs_procfsuptime.c | 2 +-
include/nuttx/clock.h | 12 ------------
sched/clock/clock_sched_ticks.c | 2 +-
3 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/fs/procfs/fs_procfsuptime.c b/fs/procfs/fs_procfsuptime.c
index 55b67e33f2c..ffed34e8430 100644
--- a/fs/procfs/fs_procfsuptime.c
+++ b/fs/procfs/fs_procfsuptime.c
@@ -213,7 +213,7 @@ static ssize_t uptime_read(FAR struct file *filep, FAR char
*buffer,
{
/* System time */
- ticktime = clock_systime_ticks() - INITIAL_SYSTEM_TIMER_TICKS;
+ ticktime = clock_systime_ticks();
/* Convert the system up time to seconds + hundredths of seconds */
diff --git a/include/nuttx/clock.h b/include/nuttx/clock.h
index 88ee7c711a2..888db154600 100644
--- a/include/nuttx/clock.h
+++ b/include/nuttx/clock.h
@@ -250,18 +250,6 @@
#define NSEC2MSEC(nsec) div_const(nsec, NSEC_PER_MSEC)
-#if defined(CONFIG_DEBUG_SCHED) && !defined(CONFIG_SCHED_TICKLESS)
-/* Initial system timer ticks value close to maximum 32-bit value, to test
- * 64-bit system-timer after going over 32-bit value. This is to make errors
- * of casting 64-bit system-timer to 32-bit variables more visible.
- */
-
-# define INITIAL_SYSTEM_TIMER_TICKS \
- (UINT32_MAX - (TICK_PER_SEC * 5))
-#else
-# define INITIAL_SYSTEM_TIMER_TICKS 0
-#endif
-
/* If Gregorian time is not supported, then neither is Julian */
#ifndef CONFIG_GREGORIAN_TIME
diff --git a/sched/clock/clock_sched_ticks.c b/sched/clock/clock_sched_ticks.c
index 48de47c272d..c37b099b60b 100644
--- a/sched/clock/clock_sched_ticks.c
+++ b/sched/clock/clock_sched_ticks.c
@@ -39,7 +39,7 @@
* Private Data
****************************************************************************/
-static volatile clock_t g_system_ticks = INITIAL_SYSTEM_TIMER_TICKS;
+static volatile clock_t g_system_ticks;
static seqcount_t g_system_tick_lock = SEQLOCK_INITIALIZER;
/****************************************************************************