From: Petr Mladek <pmladek@suse.com>
To: Marcos Paulo de Souza <mpdesouza@suse.com>
Cc: Josh Poimboeuf <jpoimboe@kernel.org>,
Jiri Kosina <jikos@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
Joe Lawrence <joe.lawrence@redhat.com>,
Shuah Khan <shuah@kernel.org>,
live-patching@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 4/6] selftests: livepatch: Check if patched sysfs attribute exists
Date: Fri, 17 Apr 2026 17:21:30 +0200 [thread overview]
Message-ID: <aeJP-tdGdSov3ogP@pathway.suse.cz> (raw)
In-Reply-To: <20260413-lp-tests-old-fixes-v2-4-367c7cb5006f@suse.com>
On Mon 2026-04-13 14:26:15, Marcos Paulo de Souza wrote:
> In order to run the selftests on older kernels, check if given kernel
> has support for the attribute. If the attribute is not supported, skip
> the checks.
>
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> ---
> tools/testing/selftests/livepatch/test-sysfs.sh | 38 +++++++++++++++----------
> 1 file changed, 23 insertions(+), 15 deletions(-)
>
> diff --git a/tools/testing/selftests/livepatch/test-sysfs.sh b/tools/testing/selftests/livepatch/test-sysfs.sh
> index 58fe1d96997c..a2d649404a63 100755
> --- a/tools/testing/selftests/livepatch/test-sysfs.sh
> +++ b/tools/testing/selftests/livepatch/test-sysfs.sh
> @@ -8,6 +8,8 @@ MOD_LIVEPATCH=test_klp_livepatch
> MOD_LIVEPATCH2=test_klp_callbacks_demo
> MOD_LIVEPATCH3=test_klp_syscall
>
It would be nice to add a comment in which upstream kernel version
the attribute was introduced. It might help to decide when it is
time to remove the check, see below.
> +HAS_PATCH_ATTR=0
> +
> setup_config
>
> # - load a livepatch and verifies the sysfs entries work as expected
> @@ -25,8 +27,12 @@ check_sysfs_rights "$MOD_LIVEPATCH" "stack_order" "-r--r--r--"
> check_sysfs_value "$MOD_LIVEPATCH" "stack_order" "1"
> check_sysfs_rights "$MOD_LIVEPATCH" "transition" "-r--r--r--"
> check_sysfs_value "$MOD_LIVEPATCH" "transition" "0"
> -check_sysfs_rights "$MOD_LIVEPATCH" "vmlinux/patched" "-r--r--r--"
> -check_sysfs_value "$MOD_LIVEPATCH" "vmlinux/patched" "1"
> +
> +if does_sysfs_exists "$MOD_LIVEPATCH/vmlinux" "patched"; then
> + check_sysfs_rights "$MOD_LIVEPATCH" "vmlinux/patched" "-r--r--r--"
> + check_sysfs_value "$MOD_LIVEPATCH" "vmlinux/patched" "1"
> + HAS_PATCH_ATTR=1
> +fi
>
> disable_lp $MOD_LIVEPATCH
>
> @@ -45,23 +51,24 @@ livepatch: '$MOD_LIVEPATCH': completing unpatching transition
> livepatch: '$MOD_LIVEPATCH': unpatching complete
> % rmmod $MOD_LIVEPATCH"
>
> -start_test "sysfs test object/patched"
> +if [[ "$HAS_PATCH_ATTR" == "1" ]]; then
> + start_test "sysfs test object/patched"
>
> -MOD_LIVEPATCH=test_klp_callbacks_demo
> -MOD_TARGET=test_klp_callbacks_mod
> -load_lp $MOD_LIVEPATCH
> + MOD_LIVEPATCH=test_klp_callbacks_demo
> + MOD_TARGET=test_klp_callbacks_mod
> + load_lp $MOD_LIVEPATCH
>
> -# check the "patch" file changes as target module loads/unloads
> -check_sysfs_value "$MOD_LIVEPATCH" "$MOD_TARGET/patched" "0"
> -load_mod $MOD_TARGET
> -check_sysfs_value "$MOD_LIVEPATCH" "$MOD_TARGET/patched" "1"
> -unload_mod $MOD_TARGET
> -check_sysfs_value "$MOD_LIVEPATCH" "$MOD_TARGET/patched" "0"
> + # check the "patch" file changes as target module loads/unloads
> + check_sysfs_value "$MOD_LIVEPATCH" "$MOD_TARGET/patched" "0"
> + load_mod $MOD_TARGET
> + check_sysfs_value "$MOD_LIVEPATCH" "$MOD_TARGET/patched" "1"
> + unload_mod $MOD_TARGET
> + check_sysfs_value "$MOD_LIVEPATCH" "$MOD_TARGET/patched" "0"
>
> -disable_lp $MOD_LIVEPATCH
> -unload_lp $MOD_LIVEPATCH
> + disable_lp $MOD_LIVEPATCH
> + unload_lp $MOD_LIVEPATCH
>
> -check_result "% insmod test_modules/test_klp_callbacks_demo.ko
> + check_result "% insmod test_modules/test_klp_callbacks_demo.ko
> livepatch: enabling patch 'test_klp_callbacks_demo'
> livepatch: 'test_klp_callbacks_demo': initializing patching transition
> test_klp_callbacks_demo: pre_patch_callback: vmlinux
> @@ -87,6 +94,7 @@ livepatch: 'test_klp_callbacks_demo': completing unpatching transition
> test_klp_callbacks_demo: post_unpatch_callback: vmlinux
> livepatch: 'test_klp_callbacks_demo': unpatching complete
> % rmmod test_klp_callbacks_demo"
> +fi
The indentation mismatch (code vs check_results) looks a bit ugly.
Well, it is rather common thing in bash scripts. And it might
even help to find where the next text starts.
I could live with it. But I am a bit biased.
I would like to see an ack from a non-SUSE person before
taking this ;-)
Best Regards,
Petr
PS: Otherwise, the patchset look good to me, modulo
the Sashiko AI comments.
next prev parent reply other threads:[~2026-04-17 15:21 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-13 17:26 [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
2026-04-13 17:26 ` [PATCH v2 1/6] selftests: livepatch: Check for ARCH_HAS_SYSCALL_WRAPPER config Marcos Paulo de Souza
2026-04-15 9:58 ` Miroslav Benes
2026-04-17 15:11 ` Petr Mladek
2026-04-17 18:10 ` Joe Lawrence
2026-04-17 18:14 ` Joe Lawrence
2026-04-13 17:26 ` [PATCH v2 2/6] selftests: livepatch: Replace true/false module parameter by y/n Marcos Paulo de Souza
2026-04-13 17:26 ` [PATCH v2 3/6] selftests: livepatch: Introduce does_sysfs_exists function Marcos Paulo de Souza
2026-04-17 18:15 ` Joe Lawrence
2026-04-17 18:18 ` Joe Lawrence
2026-04-13 17:26 ` [PATCH v2 4/6] selftests: livepatch: Check if patched sysfs attribute exists Marcos Paulo de Souza
2026-04-17 15:21 ` Petr Mladek [this message]
2026-04-13 17:26 ` [PATCH v2 5/6] selftests: livepatch: Check if replace " Marcos Paulo de Souza
2026-04-13 17:26 ` [PATCH v2 6/6] selftests: livepatch: Check if stack_order " Marcos Paulo de Souza
2026-04-14 12:12 ` [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels Marcos Paulo de Souza
2026-04-15 12:01 ` Miroslav Benes
2026-04-15 12:37 ` Marcos Paulo de Souza
2026-04-16 13:24 ` Miroslav Benes
2026-04-16 17:07 ` Josh Poimboeuf
2026-04-16 18:18 ` Marcos Paulo de Souza
2026-04-17 18:36 ` Joe Lawrence
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aeJP-tdGdSov3ogP@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=mpdesouza@suse.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox