Skip to contentSkip to conversation

automation: fix race condition in adl-suspend test

PATCH Superseded Marek Marczykowski-Górecki 2 participants 4 messages Oct 28, 2023 – Oct 30, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 automation: fix race condition in adl-suspend test

If system suspends too quickly, the message for the test controller to wake up the system may be not sent to the console before suspending. This will cause the test to timeout.

Fix this by waiting a bit after printing the message. The test controller then resumes the system 30s after the message, so as long as the delay + suspending takes less time it is okay.

---
This is consistent with the observation that sync_console "fixes" the issue.

---
 automation/scripts/qubes-x86-64.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
automation/scripts/qubes-x86-64.sh +2 -2
index 26131b082671..a34db96e4585 100755
@@ -54,11 +54,11 @@ until grep 'domU started' /var/log/xen/console/guest-domU.log; do
     sleep 1
 done
 echo \"${wait_and_wakeup}\"
+# let the above message flow to console, then suspend
+sleep 5
 set -x
 echo deep > /sys/power/mem_sleep
 echo mem > /sys/power/state
-# now wait for resume
-sleep 5
 xl list
 xl dmesg | grep 'Finishing wakeup from ACPI S3 state' || exit 1
 # check if domU is still alive
Signature · 1 line
2.41.0
#1 lore raw
Quoted 21 lines · Marek Marczykowski-Górecki

If system suspends too quickly, the message for the test controller to wake up the system may be not sent to the console before suspending. This will cause the test to timeout.

Fix this by waiting a bit after printing the message. The test controller then resumes the system 30s after the message, so as long as the delay + suspending takes less time it is okay.

---
This is consistent with the observation that sync_console "fixes" the issue.

---
 automation/scripts/qubes-x86-64.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
automation/scripts/qubes-x86-64.sh +0 -0
index 26131b082671..a34db96e4585 100755

automation/scripts/qubes-x86-64.sh until grep 'domU started' /var/log/xen/console/guest-domU.log; do · line 58

Quoted 5 lines
automation/scripts/qubes-x86-64.sh +2 -0
@@ -54,11 +54,11 @@ until grep 'domU started' /var/log/xen/console/guest-domU.log; do
     sleep 1
 done
 echo \"${wait_and_wakeup}\"
+# let the above message flow to console, then suspend
+sleep 5

Could you use sync /dev/stdout? I guess that might not be enough, since the sync won't be propagated to the hypervisor, and hence even if flushed from Linux, we have no guarantee that the hypervisor has also flushed it.

Xen should flush the buffer when a newline character is found, but I have no idea whether context could return to guest while the buffer is still in the process of being fully flushed.

Anyway, adding the extra sync might be good regardless, and keeping the sleep.

Thanks, Roger.

#2 lore raw
Quoted 17 lines · Roger Pau Monné
Quoted 16 lines · Marek Marczykowski-Górecki

If system suspends too quickly, the message for the test controller to wake up the system may be not sent to the console before suspending. This will cause the test to timeout.

Fix this by waiting a bit after printing the message. The test controller then resumes the system 30s after the message, so as long as the delay + suspending takes less time it is okay.

---
This is consistent with the observation that sync_console "fixes" the issue.

---
 automation/scripts/qubes-x86-64.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 15 lines

automation/scripts/qubes-x86-64.sh until grep 'domU started' /var/log/xen/console/guest-domU.log; do · line 58

Quoted 10 lines
automation/scripts/qubes-x86-64.sh +2 -0
index 26131b082671..a34db96e4585 100755
@@ -54,11 +54,11 @@ until grep 'domU started' /var/log/xen/console/guest-domU.log; do
     sleep 1
 done
 echo \"${wait_and_wakeup}\"
+# let the above message flow to console, then suspend
+sleep 5

Could you use sync /dev/stdout? I guess that might not be enough, since the sync won't be propagated to the hypervisor, and hence even if flushed from Linux, we have no guarantee that the hypervisor has also flushed it.

It seems sync /dev/stdout helps too, at least in a limited sample of two.

Quoted 3 lines

Xen should flush the buffer when a newline character is found, but I have no idea whether context could return to guest while the buffer is still in the process of being fully flushed.

IIC Xen should flush the console buffer on the suspend path (there is console_start_sync() in enter_state()). So, if linux manages to send it to Xen in time, all should be good (in theory at least).

Quoted 2 lines

Anyway, adding the extra sync might be good regardless, and keeping the sleep.

Good idea, I'll send v2 with it included.

Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
#3 lore raw
Quoted 34 lines · Marek Marczykowski-Górecki
Quoted 17 lines · Roger Pau Monné
Quoted 16 lines · Marek Marczykowski-Górecki

If system suspends too quickly, the message for the test controller to wake up the system may be not sent to the console before suspending. This will cause the test to timeout.

Fix this by waiting a bit after printing the message. The test controller then resumes the system 30s after the message, so as long as the delay + suspending takes less time it is okay.

---
This is consistent with the observation that sync_console "fixes" the issue.

---
 automation/scripts/qubes-x86-64.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 15 lines

automation/scripts/qubes-x86-64.sh until grep 'domU started' /var/log/xen/console/guest-domU.log; do · line 58

Quoted 10 lines
automation/scripts/qubes-x86-64.sh +2 -0
index 26131b082671..a34db96e4585 100755
@@ -54,11 +54,11 @@ until grep 'domU started' /var/log/xen/console/guest-domU.log; do
     sleep 1
 done
 echo \"${wait_and_wakeup}\"
+# let the above message flow to console, then suspend
+sleep 5

Could you use sync /dev/stdout? I guess that might not be enough, since the sync won't be propagated to the hypervisor, and hence even if flushed from Linux, we have no guarantee that the hypervisor has also flushed it.

Quoted 2 lines

It seems sync /dev/stdout helps too, at least in a limited sample of two.

... and the third attempt (with sync instead of sleep) failed.

Quoted 12 lines
Quoted 3 lines

Xen should flush the buffer when a newline character is found, but I have no idea whether context could return to guest while the buffer is still in the process of being fully flushed.

IIC Xen should flush the console buffer on the suspend path (there is console_start_sync() in enter_state()). So, if linux manages to send it to Xen in time, all should be good (in theory at least).

Quoted 2 lines

Anyway, adding the extra sync might be good regardless, and keeping the sleep.

Good idea, I'll send v2 with it included.

Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab