Skip to content

Commit 5212223

Browse files
LKL patch: update jiffies on interrupts while the tick is stopped
irq_enter() brings a stale jiffies up to date only when the idle task is current, but LKL idles in idle_host_task or in a host task that stays current after a system call. With the tick stopped by 0002, interrupts ran with an old jiffies, and the timers armed from them, such as the TCP retransmission timer armed on an incoming ACK, expired early: a transfer losing 10 segments retransmitted 84. Update jiffies on interrupt entry when another task is current, as the idle task would.
1 parent 5ae1892 commit 5212223

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
From 23feee119a3e54e3c6e7af58fc3d6ab54a8a0fd6 Mon Sep 17 00:00:00 2001
2+
From: Gabriel Ferreira <gabrielcarvfer@gmail.com>
3+
Date: Tue, 13 Oct 2026 20:30:00 +0200
4+
Subject: [PATCH] lkl: update jiffies on interrupts while the tick is stopped
5+
6+
irq_enter() brings a stale jiffies up to date (tick_irq_enter) only
7+
when the idle task is current. LKL idles in idle_host_task, a regular
8+
task, or in a host task that stays current after a system call, so the
9+
interrupts taken while the tick is stopped (see "lkl: stop the tick
10+
while the host is idle") ran with an old jiffies. The timers armed from
11+
them, such as the TCP retransmission timer armed on an incoming ACK,
12+
expired early by the time elapsed since the tick stopped, which caused
13+
spurious retransmissions: in ns-3 DCE, a transfer losing 10 segments
14+
retransmitted 84.
15+
16+
Update jiffies as the idle task would when an interrupt starts while
17+
another task is current.
18+
---
19+
arch/lkl/kernel/irq.c | 8 ++++++++
20+
1 file changed, 8 insertions(+)
21+
22+
diff --git a/arch/lkl/kernel/irq.c b/arch/lkl/kernel/irq.c
23+
index 54c5686ab..dca9dc1af 100644
24+
--- a/arch/lkl/kernel/irq.c
25+
+++ b/arch/lkl/kernel/irq.c
26+
@@ -61,6 +61,14 @@ static void run_irq(int irq)
27+
/* interrupt handlers need to run with interrupts disabled */
28+
local_irq_save(flags);
29+
irq_enter();
30+
+ /*
31+
+ * irq_enter() brings a stale jiffies up to date only when the idle
32+
+ * task is current, but LKL idles in idle_host_task or in a host
33+
+ * task: without this, handlers running while the tick is stopped
34+
+ * see an old jiffies and arm their timers too early.
35+
+ */
36+
+ if (!is_idle_task(current) && irq_count() == HARDIRQ_OFFSET)
37+
+ tick_irq_enter();
38+
generic_handle_irq(irq);
39+
irq_exit();
40+
set_irq_regs(old_regs);
41+
--
42+
2.43.0
43+

0 commit comments

Comments
 (0)