Skip to content

Commit 4702f4e

Browse files
t-8chKAGA-KOKO
authored andcommitted
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
1 parent ba14500 commit 4702f4e

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

include/linux/restart_block.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct restart_block {
4343
struct __kernel_timespec __user *rmtp;
4444
struct old_timespec32 __user *compat_rmtp;
4545
};
46-
u64 expires;
46+
ktime_t expires;
4747
} nanosleep;
4848
/* For poll */
4949
struct {

kernel/time/hrtimer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,7 +2145,7 @@ static long __sched hrtimer_nanosleep_restart(struct restart_block *restart)
21452145
int ret;
21462146

21472147
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);
21492149
ret = do_nanosleep(&t, HRTIMER_MODE_ABS);
21502150
destroy_hrtimer_on_stack(&t.timer);
21512151
return ret;
@@ -2172,7 +2172,7 @@ long hrtimer_nanosleep(ktime_t rqtp, const enum hrtimer_mode mode,
21722172

21732173
restart = &current->restart_block;
21742174
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);
21762176
set_restart_fn(restart, hrtimer_nanosleep_restart);
21772177
out:
21782178
destroy_hrtimer_on_stack(&t.timer);

kernel/time/posix-cpu-timers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,7 @@ static int do_cpu_nanosleep(const clockid_t which_clock, int flags,
15571557
* Report back to the user the time still remaining.
15581558
*/
15591559
restart = &current->restart_block;
1560-
restart->nanosleep.expires = expires;
1560+
restart->nanosleep.expires = ns_to_ktime(expires);
15611561
if (restart->nanosleep.type != TT_NONE)
15621562
error = nanosleep_copyout(restart, &it.it_value);
15631563
}
@@ -1599,7 +1599,7 @@ static long posix_cpu_nsleep_restart(struct restart_block *restart_block)
15991599
clockid_t which_clock = restart_block->nanosleep.clockid;
16001600
struct timespec64 t;
16011601

1602-
t = ns_to_timespec64(restart_block->nanosleep.expires);
1602+
t = ktime_to_timespec64(restart_block->nanosleep.expires);
16031603

16041604
return do_cpu_nanosleep(which_clock, TIMER_ABSTIME, &t);
16051605
}

0 commit comments

Comments
 (0)