Skip to content

Commit 278911e

Browse files
jmberg-intelrichardweinberger
authored andcommitted
um: time-travel: Restrict time update in IRQ handler
We currently do the time updates in the timer handler, even if we just call the timer handler ourselves. In basic mode we must in fact do it there since otherwise the OS timer signal won't move time forward, but in inf-cpu mode we don't need to, and it's harder to understand. Restrict the update there to basic mode, adding a comment, and do it before calling the timer_handler() in inf-cpu mode. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent eec94b8 commit 278911e

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎arch/um/kernel/process.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,13 @@ static void time_travel_sleep(unsigned long long duration)
220220
if (time_travel_timer_mode == TT_TMR_ONESHOT)
221221
time_travel_set_timer_mode(TT_TMR_DISABLED);
222222
/*
223-
* time_travel_time will be adjusted in the timer
224-
* IRQ handler so it works even when the signal
225-
* comes from the OS timer
223+
* In basic mode, time_travel_time will be adjusted in
224+
* the timer IRQ handler so it works even when the signal
225+
* comes from the OS timer, see there.
226226
*/
227+
if (time_travel_mode != TT_MODE_BASIC)
228+
time_travel_set_time(time_travel_timer_expiry);
229+
227230
deliver_alarm();
228231
} else {
229232
time_travel_set_time(next);

‎arch/um/kernel/time.c‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@ void timer_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs)
3939
{
4040
unsigned long flags;
4141

42-
if (time_travel_mode != TT_MODE_OFF)
42+
/*
43+
* In basic time-travel mode we still get real interrupts
44+
* (signals) but since we don't read time from the OS, we
45+
* must update the simulated time here to the expiry when
46+
* we get a signal.
47+
* This is not the case in inf-cpu mode, since there we
48+
* never get any real signals from the OS.
49+
*/
50+
if (time_travel_mode == TT_MODE_BASIC)
4351
time_travel_set_time(time_travel_timer_expiry);
4452

4553
local_irq_save(flags);

0 commit comments

Comments
 (0)