Skip to content

Commit 2f58bf9

Browse files
avaginKAGA-KOKO
authored andcommitted
alarmtimer: Provide get_timespec() callback
The upcoming support for time namespaces requires to have access to: - The time in a task's time namespace for sys_clock_gettime() - The time in the root name space for common_timer_get() Wire up alarm bases with get_timespec(). Suggested-by: Thomas Gleixner <[email protected]> Co-developed-by: Dmitry Safonov <[email protected]> Signed-off-by: Andrei Vagin <[email protected]> Signed-off-by: Dmitry Safonov <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 41b3b8d commit 2f58bf9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kernel/time/alarmtimer.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@
3737
* @lock: Lock for syncrhonized access to the base
3838
* @timerqueue: Timerqueue head managing the list of events
3939
* @get_ktime: Function to read the time correlating to the base
40+
* @get_timespec: Function to read the namespace time correlating to the base
4041
* @base_clockid: clockid for the base
4142
*/
4243
static struct alarm_base {
4344
spinlock_t lock;
4445
struct timerqueue_head timerqueue;
4546
ktime_t (*get_ktime)(void);
47+
void (*get_timespec)(struct timespec64 *tp);
4648
clockid_t base_clockid;
4749
} alarm_bases[ALARM_NUMTYPE];
4850

@@ -670,7 +672,8 @@ static int alarm_clock_get_timespec(clockid_t which_clock, struct timespec64 *tp
670672
if (!alarmtimer_get_rtcdev())
671673
return -EINVAL;
672674

673-
*tp = ktime_to_timespec64(base->get_ktime());
675+
base->get_timespec(tp);
676+
674677
return 0;
675678
}
676679

@@ -883,8 +886,10 @@ static int __init alarmtimer_init(void)
883886
/* Initialize alarm bases */
884887
alarm_bases[ALARM_REALTIME].base_clockid = CLOCK_REALTIME;
885888
alarm_bases[ALARM_REALTIME].get_ktime = &ktime_get_real;
889+
alarm_bases[ALARM_REALTIME].get_timespec = ktime_get_real_ts64,
886890
alarm_bases[ALARM_BOOTTIME].base_clockid = CLOCK_BOOTTIME;
887891
alarm_bases[ALARM_BOOTTIME].get_ktime = &ktime_get_boottime;
892+
alarm_bases[ALARM_BOOTTIME].get_timespec = ktime_get_boottime_ts64;
888893
for (i = 0; i < ALARM_NUMTYPE; i++) {
889894
timerqueue_init_head(&alarm_bases[i].timerqueue);
890895
spin_lock_init(&alarm_bases[i].lock);

0 commit comments

Comments
 (0)