Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

hrtimer: Store time as ktime_t in restart block

The hrtimer core uses ktime_t to represent times, use that also for the
restart block. CPU timers internally use nanoseconds instead of ktime_t
but use the same restart block, so use the correct accessors for those.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://patch.msgid.link/20251110-restart-block-expiration-v1-3-5d39cc93df4f@linutronix.de

authored by

Thomas Weißschuh and committed by
Thomas Gleixner
4702f4ec ba14500e

+5 -5
+1 -1
include/linux/restart_block.h
··· 43 43 struct __kernel_timespec __user *rmtp; 44 44 struct old_timespec32 __user *compat_rmtp; 45 45 }; 46 - u64 expires; 46 + ktime_t expires; 47 47 } nanosleep; 48 48 /* For poll */ 49 49 struct {
+2 -2
kernel/time/hrtimer.c
··· 2145 2145 int ret; 2146 2146 2147 2147 hrtimer_setup_sleeper_on_stack(&t, restart->nanosleep.clockid, HRTIMER_MODE_ABS); 2148 - hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires); 2148 + hrtimer_set_expires(&t.timer, restart->nanosleep.expires); 2149 2149 ret = do_nanosleep(&t, HRTIMER_MODE_ABS); 2150 2150 destroy_hrtimer_on_stack(&t.timer); 2151 2151 return ret; ··· 2172 2172 2173 2173 restart = &current->restart_block; 2174 2174 restart->nanosleep.clockid = t.timer.base->clockid; 2175 - restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer); 2175 + restart->nanosleep.expires = hrtimer_get_expires(&t.timer); 2176 2176 set_restart_fn(restart, hrtimer_nanosleep_restart); 2177 2177 out: 2178 2178 destroy_hrtimer_on_stack(&t.timer);
+2 -2
kernel/time/posix-cpu-timers.c
··· 1557 1557 * Report back to the user the time still remaining. 1558 1558 */ 1559 1559 restart = &current->restart_block; 1560 - restart->nanosleep.expires = expires; 1560 + restart->nanosleep.expires = ns_to_ktime(expires); 1561 1561 if (restart->nanosleep.type != TT_NONE) 1562 1562 error = nanosleep_copyout(restart, &it.it_value); 1563 1563 } ··· 1599 1599 clockid_t which_clock = restart_block->nanosleep.clockid; 1600 1600 struct timespec64 t; 1601 1601 1602 - t = ns_to_timespec64(restart_block->nanosleep.expires); 1602 + t = ktime_to_timespec64(restart_block->nanosleep.expires); 1603 1603 1604 1604 return do_cpu_nanosleep(which_clock, TIMER_ABSTIME, &t); 1605 1605 }