[v2,2/2] um: time-travel: restrict time update in IRQ handler
diff mbox series

Message ID 1568127832-Iaa969e227dff394fd66cc145454590a435cf646d@changeid
State Accepted
Headers show
Series
  • Untitled series #129977
Related show

Commit Message

Johannes Berg Sept. 10, 2019, 3:03 p.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

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>
---
v2:
 - tweak commit log slightly
---
 arch/um/kernel/process.c |  9 ++++++---
 arch/um/kernel/time.c    | 10 +++++++++-
 2 files changed, 15 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index cf242fc5fe94..094028720567 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -220,10 +220,13 @@  static void time_travel_sleep(unsigned long long duration)
 		if (time_travel_timer_mode == TT_TMR_ONESHOT)
 			time_travel_set_timer_mode(TT_TMR_DISABLED);
 		/*
-		 * time_travel_time will be adjusted in the timer
-		 * IRQ handler so it works even when the signal
-		 * comes from the OS timer
+		 * In basic mode, time_travel_time will be adjusted in
+		 * the timer IRQ handler so it works even when the signal
+		 * comes from the OS timer, see there.
 		 */
+		if (time_travel_mode != TT_MODE_BASIC)
+			time_travel_set_time(time_travel_timer_expiry);
+
 		deliver_alarm();
 	} else {
 		time_travel_set_time(next);
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c
index 4ecabf7e54c9..15f2e88ba927 100644
--- a/arch/um/kernel/time.c
+++ b/arch/um/kernel/time.c
@@ -39,7 +39,15 @@  void timer_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs)
 {
 	unsigned long flags;
 
-	if (time_travel_mode != TT_MODE_OFF)
+	/*
+	 * In basic time-travel mode we still get real interrupts
+	 * (signals) but since we don't read time from the OS, we
+	 * must update the simulated time here to the expiry when
+	 * we get a signal.
+	 * This is not the case in inf-cpu mode, since there we
+	 * never get any real signals from the OS.
+	 */
+	if (time_travel_mode == TT_MODE_BASIC)
 		time_travel_set_time(time_travel_timer_expiry);
 
 	local_irq_save(flags);