Skip to contentSkip to conversation

selftests/livepatch: wait for atomic replace to occur

PATCH In review Ryan Sullivan 2 participants 4 messages Aug 22, 2024 – Aug 26, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/livepatch: wait for atomic replace to occur

On some machines with a large number of CPUs there is a sizable delay between an atomic replace occurring and when sysfs updates accordingly. This fix uses 'loop_until' to wait for the atomic replace to unload all previous livepatches.

---
 tools/testing/selftests/livepatch/test-livepatch.sh | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
tools/testing/selftests/livepatch/test-livepatch.sh +2 -5
index 65c9c058458d..bd13257bfdfe 100755
@@ -139,11 +139,8 @@ load_lp $MOD_REPLACE replace=1
 grep 'live patched' /proc/cmdline > /dev/kmsg
 grep 'live patched' /proc/meminfo > /dev/kmsg
 
-mods=(/sys/kernel/livepatch/*)
-nmods=${#mods[@]}
-if [ "$nmods" -ne 1 ]; then
-	die "Expecting only one moduled listed, found $nmods"
-fi
+loop_until 'mods=(/sys/kernel/livepatch/*); nmods=${#mods[@]}; [[ "$nmods" -eq 1 ]]' ||
+        die "Expecting only one moduled listed, found $nmods"
 
 # These modules were disabled by the atomic replace
 for mod in $MOD_LIVEPATCH3 $MOD_LIVEPATCH2 $MOD_LIVEPATCH1; do
Signature · 1 line
2.44.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi,

this is 2nd version of the patch. There should have been used [PATCH v2] in the Subject to make it clear in the mailbox.

Quoted 5 lines · Ryan Sullivan

On some machines with a large number of CPUs there is a sizable delay between an atomic replace occurring and when sysfs updates accordingly. This fix uses 'loop_until' to wait for the atomic replace to unload all previous livepatches.

I think that Joe suggested to add:

Quoted 2 lines

---

Also it is a good practice to summarize changes between versions. In this case it would have been something like:

Changes against v1:

- Cleaned the commit message.

Quoted 11 lines
 tools/testing/selftests/livepatch/test-livepatch.sh | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
tools/testing/selftests/livepatch/test-livepatch.sh +0 -0
index 65c9c058458d..bd13257bfdfe 100755
@@ -139,11 +139,8 @@ load_lp $MOD_REPLACE replace=1
 grep 'live patched' /proc/cmdline > /dev/kmsg
 grep 'live patched' /proc/meminfo > /dev/kmsg
 

tools/testing/selftests/livepatch/test-livepatch.sh load_lp $MOD_REPLACE replace=1 · line 146

Quoted 10 lines
tools/testing/selftests/livepatch/test-livepatch.sh +2 -5
-mods=(/sys/kernel/livepatch/*)
-nmods=${#mods[@]}
-if [ "$nmods" -ne 1 ]; then
-	die "Expecting only one moduled listed, found $nmods"
-fi
+loop_until 'mods=(/sys/kernel/livepatch/*); nmods=${#mods[@]}; [[ "$nmods" -eq 1 ]]' ||
+        die "Expecting only one moduled listed, found $nmods"
 
 # These modules were disabled by the atomic replace
 for mod in $MOD_LIVEPATCH3 $MOD_LIVEPATCH2 $MOD_LIVEPATCH1; do

Otherwise, it looks good to me. With the added references:

Best Regards,
Petr

PS: No need to resend the patch. I would add the references when
committing. I am going to wait few more days before committing.

#2 lore raw

Changes from v2:

Adds:

	Reported-by: CKI Project <[email protected]>
	Closes: https://datawarehouse.cki-project.org/kcidb/tests/redhat:1413102084-x86_64-kernel_upt_28

From 9d9bfb21e86a3a79fb92fd22d927329510c6a672 Mon Sep 17 00:00:00 2001
From: Ryan Sullivan <[email protected]>
Date: Thu, 22 Aug 2024 12:19:54 -0400
Subject: [PATCH v3] selftests/livepatch: wait for atomic replace to occur

On some machines with a large number of CPUs there is a sizable delay between an atomic replace occurring and when sysfs updates accordingly. This fix uses 'loop_until' to wait for the atomic replace to unload all previous livepatches.

---
 tools/testing/selftests/livepatch/test-livepatch.sh | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
tools/testing/selftests/livepatch/test-livepatch.sh +2 -5
index 65c9c058458d..bd13257bfdfe 100755
@@ -139,11 +139,8 @@ load_lp $MOD_REPLACE replace=1
 grep 'live patched' /proc/cmdline > /dev/kmsg
 grep 'live patched' /proc/meminfo > /dev/kmsg
 
-mods=(/sys/kernel/livepatch/*)
-nmods=${#mods[@]}
-if [ "$nmods" -ne 1 ]; then
-	die "Expecting only one moduled listed, found $nmods"
-fi
+loop_until 'mods=(/sys/kernel/livepatch/*); nmods=${#mods[@]}; [[ "$nmods" -eq 1 ]]' ||
+        die "Expecting only one moduled listed, found $nmods"
 
 # These modules were disabled by the atomic replace
 for mod in $MOD_LIVEPATCH3 $MOD_LIVEPATCH2 $MOD_LIVEPATCH1; do
Signature · 1 line
2.44.0
maintainer
#3 lore raw

Hi,

JFYI, I have committed the patch into livepatching.git, branch for-6.11/selftests-fixup.

Few nits below :-)

Quoted 5 lines · Ryan B. Sullivan

Changes from v2:

Adds:

	Reported-by: CKI Project <[email protected]>
	Closes: https://datawarehouse.cki-project.org/kcidb/tests/redhat:1413102084-x86_64-kernel_upt_28

The "changelog" should have been added after the "---" line.

It allows to send the patch as the main part of the mail (no attachment). The lines below the "---" gets automatically removed when the "mail" gets applied using "git am".

Best Regards,
Petr