Skip to contentSkip to conversation

proc: uptime: print 64-bit seconds values

PATCH New Jaime Saguillo Revilla 1 participant 1 message Dec 22, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc: uptime: print 64-bit seconds values

uptime.tv_sec and idle.tv_sec are time64_t and may exceed unsigned long on 32-bit kernels. Print them using a 64-bit format to avoid truncation in /proc/uptime.

---
 fs/proc/uptime.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/proc/uptime.c +3 -3
index b5343d209381..2b83435ad01e 100644
@@ -30,10 +30,10 @@ static int uptime_proc_show(struct seq_file *m, void *v)
 
 	idle.tv_sec = div_u64_rem(idle_nsec, NSEC_PER_SEC, &rem);
 	idle.tv_nsec = rem;
-	seq_printf(m, "%lu.%02lu %lu.%02lu\n",
-			(unsigned long) uptime.tv_sec,
+	seq_printf(m, "%lld.%02lu %lld.%02lu\n",
+			(long long) uptime.tv_sec,
 			(uptime.tv_nsec / (NSEC_PER_SEC / 100)),
-			(unsigned long) idle.tv_sec,
+			(long long) idle.tv_sec,
 			(idle.tv_nsec / (NSEC_PER_SEC / 100)));
 	return 0;
 }
Signature · 1 line
2.43.0