Skip to contentSkip to conversation

: um: time-travel=ext fixes

PATCH In review Johannes Berg 2 participants 5 messages Sep 10, 2020 – Sep 16, 2020 User-mode Linux (UML)

lore
Share & tools
lore

Johannes Berg

author maintainer
#0 lore raw

PATCH v2 1/2 : um: time-travel=ext fixes

Hi,

I had been noticing some hangs in my simulations, and finally had enough time (and a machine that they reproduce on easily - it's a timing thing) to debug, so two small fixes for this.

v2:
* remove change-id ...

johannes

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um

author maintainer
#1 lore raw

PATCH v2 1/2 um: time-travel: fix IRQ handling in time_travel_handle_message()

From: Johannes Berg <[email protected]>

As the comment here indicates, we need to do the polling in the idle loop without blocking interrupts, since interrupts can be vhost-user messages that we must process even while in our idle loop.

I don't know why I explained one thing and implemented another, but we have indeed observed random hangs due to this, depending on the timing of the messages.

Fixes 88ce64249233 ("um: Implement time-travel=ext")
---
 arch/um/kernel/time.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
arch/um/kernel/time.c +9 -5
index 25eaa6a0c658..c07436e89e59 100644
@@ -70,13 +70,17 @@ static void time_travel_handle_message(struct um_timetravel_msg *msg,
 	 * read of the message and write of the ACK.
 	 */
 	if (mode != TTMH_READ) {
+		bool disabled = irqs_disabled();
+
+		BUG_ON(mode == TTMH_IDLE && !disabled);
+
+		if (disabled)
+			local_irq_enable();
 		while (os_poll(1, &time_travel_ext_fd) != 0) {
-			if (mode == TTMH_IDLE) {
-				BUG_ON(!irqs_disabled());
-				local_irq_enable();
-				local_irq_disable();
-			}
+			/* nothing */
 		}
+		if (disabled)
+			local_irq_disable();
 	}
 
 	ret = os_read_file(time_travel_ext_fd, msg, sizeof(*msg));
Signature · 7 lines
2.26.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Acked-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] um: time-travel: fix IRQ handling in time_travel_handle_message()

Quoted 35 lines · Johannes Berg

From: Johannes Berg <[email protected]>

As the comment here indicates, we need to do the polling in the idle loop without blocking interrupts, since interrupts can be vhost-user messages that we must process even while in our idle loop.

I don't know why I explained one thing and implemented another, but we have indeed observed random hangs due to this, depending on the timing of the messages.

Fixes 88ce64249233 ("um: Implement time-travel=ext")
---
  arch/um/kernel/time.c | 14 +++++++++-----
  1 file changed, 9 insertions(+), 5 deletions(-)
arch/um/kernel/time.c +6 -2
index 25eaa6a0c658..c07436e89e59 100644
@@ -70,13 +70,17 @@ static void time_travel_handle_message(struct um_timetravel_msg *msg,
  	 * read of the message and write of the ACK.
  	 */
  	if (mode != TTMH_READ) {
+		bool disabled = irqs_disabled();
+
+		BUG_ON(mode == TTMH_IDLE && !disabled);
+
+		if (disabled)
+			local_irq_enable();
  		while (os_poll(1, &time_travel_ext_fd) != 0) {
-			if (mode == TTMH_IDLE) {
-				BUG_ON(!irqs_disabled());

arch/um/kernel/time.c static void time_travel_handle_message(struct um_timetravel_msg *msg, · line 86

Quoted 10 lines
arch/um/kernel/time.c +3 -3
-				local_irq_enable();
-				local_irq_disable();
-			}
+			/* nothing */
  		}
+		if (disabled)
+			local_irq_disable();
  	}
 
  	ret = os_read_file(time_travel_ext_fd, msg, sizeof(*msg));
Signature · 7 lines
Anton R. Ivanov
https://www.kot-begemot.co.uk/

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
author maintainer
#3 lore raw

PATCH v2 2/2 um: time-travel: return the sequence number in ACK messages

In reply to Johannes Berg

From: Johannes Berg <[email protected]>

For external time travel, the protocol says to return the incoming sequence number in the ACK message to aid debugging, so do that.

---
 arch/um/kernel/time.c | 1 +
 1 file changed, 1 insertion(+)
arch/um/kernel/time.c +1 -0
index c07436e89e59..3d109ff3309b 100644
@@ -106,6 +106,7 @@ static void time_travel_handle_message(struct um_timetravel_msg *msg,
 		break;
 	}
 
+	resp.seq = msg->seq;
 	os_write_file(time_travel_ext_fd, &resp, sizeof(resp));
 }
 
Signature · 7 lines
2.26.2


_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Acked-by on v2 2/2
#4 lore raw

Re: [PATCH v2 2/2] um: time-travel: return the sequence number in ACK messages

Quoted 17 lines · Johannes Berg

From: Johannes Berg <[email protected]>

For external time travel, the protocol says to return the incoming sequence number in the ACK message to aid debugging, so do that.

---
  arch/um/kernel/time.c | 1 +
  1 file changed, 1 insertion(+)
arch/um/kernel/time.c +0 -0
index c07436e89e59..3d109ff3309b 100644

arch/um/kernel/time.c static void time_travel_handle_message(struct um_timetravel_msg *msg, · line 112

Quoted 7 lines
arch/um/kernel/time.c +1 -0
@@ -106,6 +106,7 @@ static void time_travel_handle_message(struct um_timetravel_msg *msg,
  		break;
  	}
 
+	resp.seq = msg->seq;
  	os_write_file(time_travel_ext_fd, &resp, sizeof(resp));
  }
 
Signature · 7 lines
Anton R. Ivanov
https://www.kot-begemot.co.uk/

_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um