Skip to contentSkip to conversation

test/monitor.sh: remove useless sleeps

PATCH In review [email protected] 3 participants 4 messages May 14, 2025 – May 15, 2025 libnvdimm: non-volatile memory device

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 test/monitor.sh: remove useless sleeps

From: Alison Schofield <[email protected]>

monitor.sh runs for 50 seconds and spends 48 of those seconds sleeping. Removing the sleeps entirely has no effect on the test in this users environment. It passes and produces the same test log.

Experiments replacing sleeps with polling for monitor ready and log file updates proved that both are always available following the sync so there is no need to replace the sleeps with a more precise or reliable polling method. Simply remove the sleeps. Run time is now < 3s.

I'd especially like to get Tested-by tags on this one to confirm that my environment isn't special and that this succeeds elsewhere.

---
 test/monitor.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
test/monitor.sh +3 -3
index be8e24d6f3aa..88e253e5df00 100755
@@ -26,7 +26,7 @@ start_monitor()
 	logfile=$(mktemp)
 	$NDCTL monitor -c "$monitor_conf" -l "$logfile" $1 &
 	monitor_pid=$!
-	sync; sleep 3
+	sync
 	truncate --size 0 "$logfile" #remove startup log
 }
 
@@ -49,13 +49,13 @@ get_monitor_dimm()
 call_notify()
 {
 	"$TEST_PATH"/smart-notify "$smart_supported_bus"
-	sync; sleep 3
+	sync
 }
 
 inject_smart()
 {
 	$NDCTL inject-smart "$monitor_dimms" $1
-	sync; sleep 3
+	sync
 }
 
 check_result()
Signature · 1 line
2.37.3
Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · On 14/05/2025 09:41, [email protected] wrote:

From: Alison Schofield <[email protected]>

monitor.sh runs for 50 seconds and spends 48 of those seconds sleeping. Removing the sleeps entirely has no effect on the test in this users environment. It passes and produces the same test log.

Experiments replacing sleeps with polling for monitor ready and log file updates proved that both are always available following the sync so there is no need to replace the sleeps with a more precise or reliable polling method. Simply remove the sleeps. Run time is now < 3s.

Quoted 4 lines

I'd especially like to get Tested-by tags on this one to confirm that my environment isn't special and that this succeeds elsewhere.

Quoted 33 lines
---
  test/monitor.sh | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
test/monitor.sh +3 -3
index be8e24d6f3aa..88e253e5df00 100755
@@ -26,7 +26,7 @@ start_monitor()
  	logfile=$(mktemp)
  	$NDCTL monitor -c "$monitor_conf" -l "$logfile" $1 &
  	monitor_pid=$!
-	sync; sleep 3
+	sync
  	truncate --size 0 "$logfile" #remove startup log
  }
 
@@ -49,13 +49,13 @@ get_monitor_dimm()
  call_notify()
  {
  	"$TEST_PATH"/smart-notify "$smart_supported_bus"
-	sync; sleep 3
+	sync
  }
 
  inject_smart()
  {
  	$NDCTL inject-smart "$monitor_dimms" $1
-	sync; sleep 3
+	sync
  }
 
  check_result()
#2 lore raw
In reply to [email protected]
Quoted 6 lines · On 2025-05-13 18:41, [email protected] wrote:

From: Alison Schofield <[email protected]>

monitor.sh runs for 50 seconds and spends 48 of those seconds sleeping. Removing the sleeps entirely has no effect on the test in this users environment. It passes and produces the same test log.

Quoted 7 lines

Experiments replacing sleeps with polling for monitor ready and log file updates proved that both are always available following the sync so there is no need to replace the sleeps with a more precise or reliable polling method. Simply remove the sleeps. Run time is now < 3s.

I'd especially like to get Tested-by tags on this one to confirm that my environment isn't special and that this succeeds elsewhere.

In my configuration, this patch makes the test fail 100% of the time. It passes 100% of the time without this patch.

Also, it leaves a "ndctl monitor" behind which makes meson hang forever, believing the test is never done.

Tested on top of current "origin/pending" 1850ddcbcbf9

Marc

nmem6: supported alarms: 0x7
nmem6: set spare threshold: 99
libndctl: do_cmd: bus: 2 dimm: 0x100 cmd: cmd_call:smart_set_thresh status: 0 fw: 0 (success)
nmem6: set mtemp threshold: 11.50
libndctl: do_cmd: bus: 2 dimm: 0x100 cmd: cmd_call:smart_set_thresh status: 0 fw: 0 (success)
nmem6: set ctemp threshold: 12.50
libndctl: do_cmd: bus: 2 dimm: 0x100 cmd: cmd_call:smart_set_thresh status: 0 fw: 0 (success)
nmem6: set thresholds back to defaults
libndctl: do_cmd: bus: 2 dimm: 0x100 cmd: cmd_call:smart_set_thresh status: 0 fw: 0 (success)
libdaxctl: daxctl_unref: context 0x56469566a9d0 released
libndctl: ndctl_unref: context 0x56469566b050 released
+ sync
+ check_result 'nmem4 nmem5 nmem6 nmem7'
++ cat /tmp/tmp.mYY263Hk3f
+ jlog=
++ jq .dimm.dev
++ sort
++ uniq
++ xargs
+ notify_dimms=
+ [[ nmem4 nmem5 nmem6 nmem7 == '' ]]
++ err 65
+++ basename /root/CXL/ndctl/test/monitor.sh
++ echo test/monitor.sh: failed at line 65
test/monitor.sh: failed at line 65
++ '[' -n '' ']'
++ exit 1

Quoted 34 lines
---
 test/monitor.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
test/monitor.sh +3 -3
index be8e24d6f3aa..88e253e5df00 100755
@@ -26,7 +26,7 @@ start_monitor()
 	logfile=$(mktemp)
 	$NDCTL monitor -c "$monitor_conf" -l "$logfile" $1 &
 	monitor_pid=$!
-	sync; sleep 3
+	sync
 	truncate --size 0 "$logfile" #remove startup log
 }
 
@@ -49,13 +49,13 @@ get_monitor_dimm()
 call_notify()
 {
 	"$TEST_PATH"/smart-notify "$smart_supported_bus"
-	sync; sleep 3
+	sync
 }
 
 inject_smart()
 {
 	$NDCTL inject-smart "$monitor_dimms" $1
-	sync; sleep 3
+	sync
 }
 
 check_result()
author maintainer
#3 lore raw
Quoted 12 lines · Marc Herbert
Quoted 11 lines · On 2025-05-13 18:41, [email protected] wrote:

From: Alison Schofield <[email protected]>

monitor.sh runs for 50 seconds and spends 48 of those seconds sleeping. Removing the sleeps entirely has no effect on the test in this users environment. It passes and produces the same test log.

Experiments replacing sleeps with polling for monitor ready and log file updates proved that both are always available following the sync so there is no need to replace the sleeps with a more precise or reliable polling method. Simply remove the sleeps. Run time is now < 3s.

Quoted 5 lines
Quoted 2 lines

I'd especially like to get Tested-by tags on this one to confirm that my environment isn't special and that this succeeds elsewhere.

In my configuration, this patch makes the test fail 100% of the time. It passes 100% of the time without this patch.

Thanks for testing!
Let me resurrect the polling version and I'll pass it by you to try out.

--Alison

Quoted 73 lines

Also, it leaves a "ndctl monitor" behind which makes meson hang forever, believing the test is never done.

Tested on top of current "origin/pending" 1850ddcbcbf9

Marc

nmem6: supported alarms: 0x7
nmem6: set spare threshold: 99
libndctl: do_cmd: bus: 2 dimm: 0x100 cmd: cmd_call:smart_set_thresh status: 0 fw: 0 (success)
nmem6: set mtemp threshold: 11.50
libndctl: do_cmd: bus: 2 dimm: 0x100 cmd: cmd_call:smart_set_thresh status: 0 fw: 0 (success)
nmem6: set ctemp threshold: 12.50
libndctl: do_cmd: bus: 2 dimm: 0x100 cmd: cmd_call:smart_set_thresh status: 0 fw: 0 (success)
nmem6: set thresholds back to defaults
libndctl: do_cmd: bus: 2 dimm: 0x100 cmd: cmd_call:smart_set_thresh status: 0 fw: 0 (success)
libdaxctl: daxctl_unref: context 0x56469566a9d0 released
libndctl: ndctl_unref: context 0x56469566b050 released
+ sync
+ check_result 'nmem4 nmem5 nmem6 nmem7'
++ cat /tmp/tmp.mYY263Hk3f
+ jlog=
++ jq .dimm.dev
++ sort
++ uniq
++ xargs
+ notify_dimms=
+ [[ nmem4 nmem5 nmem6 nmem7 == '' ]]
++ err 65
+++ basename /root/CXL/ndctl/test/monitor.sh
++ echo test/monitor.sh: failed at line 65
test/monitor.sh: failed at line 65
++ '[' -n '' ']'
++ exit 1

Quoted 34 lines
---
 test/monitor.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
test/monitor.sh +3 -3
index be8e24d6f3aa..88e253e5df00 100755
@@ -26,7 +26,7 @@ start_monitor()
 	logfile=$(mktemp)
 	$NDCTL monitor -c "$monitor_conf" -l "$logfile" $1 &
 	monitor_pid=$!
-	sync; sleep 3
+	sync
 	truncate --size 0 "$logfile" #remove startup log
 }
 
@@ -49,13 +49,13 @@ get_monitor_dimm()
 call_notify()
 {
 	"$TEST_PATH"/smart-notify "$smart_supported_bus"
-	sync; sleep 3
+	sync
 }
 
 inject_smart()
 {
 	$NDCTL inject-smart "$monitor_dimms" $1
-	sync; sleep 3
+	sync
 }
 
 check_result()