From: Petr Mladek <pmladek@suse.com>
To: Yafang Shao <laoar.shao@gmail.com>
Cc: jpoimboe@kernel.org, jikos@kernel.org, mbenes@suse.cz,
joe.lawrence@redhat.com, song@kernel.org,
live-patching@vger.kernel.org
Subject: Re: [PATCH v10 2/9] selftests/livepatch: Adapt atomic replace tests to provides/obsoletes
Date: Thu, 1 Oct 2026 17:57:04 +0200 [thread overview]
Message-ID: <ar6C0B2aWg-4ayVU@pathway.suse.cz> (raw)
In-Reply-To: <20260930030323.14396-3-laoar.shao@gmail.com>
On Wed 2026-09-30 11:03:16, Yafang Shao wrote:
> The legacy "replace" field in struct klp_patch will be replaced by the
> provides/obsoletes mechanism. As a result, the atomic replace
> selftests fail to build against kernels that only support
> provides/obsoletes.
>
> Adapt the selftests so that they build and run on both old and new
> kernels. On kernels without the legacy "replace" support, the
> replace-related test cases are skipped with a SKIP message instead
> of being run.
>
> Also introduce the CONFIG_KLP_HAS_PROVIDES compile-time marker in
> kernel/livepatch/Kconfig. It defaults to n and will be set to y once
> the provides/obsoletes support is implemented later in this series.
>
> The provides/obsoletes-based selftests will be added later in this
> series, after the legacy "replace" field has been substituted by the
> new mechanism.
>
> Suggested-by: Petr Mladek <pmladek@suse.com>
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> Acked-by: Song Liu <song@kernel.org>
Looks good and passes selftests. Feel free to use:
Reviewed-by: Petr Mladek <pmladek@suse.com>
Tested-by: Petr Mladek <pmladek@suse.com>
Thouhg, see few nits below:
> --- a/tools/testing/selftests/livepatch/test-callbacks.sh
> +++ b/tools/testing/selftests/livepatch/test-callbacks.sh
> @@ -458,16 +459,17 @@ $MOD_TARGET_BUSY: ${MOD_TARGET_BUSY}_exit"
> # execute as each patch progresses through its (un)patching
> # transition.
>
> -start_test "multiple livepatches"
> +function test_multiple_livepatches() {
I really like the approach with bash functions. It separates
the test code from the skip-check.
> + start_test "multiple livepatches"
>
> -load_lp $MOD_LIVEPATCH
> -load_lp $MOD_LIVEPATCH2
> -disable_lp $MOD_LIVEPATCH2
> -disable_lp $MOD_LIVEPATCH
> -unload_lp $MOD_LIVEPATCH2
> -unload_lp $MOD_LIVEPATCH
> + load_lp $MOD_LIVEPATCH
> + load_lp $MOD_LIVEPATCH2
> + disable_lp $MOD_LIVEPATCH2
> + disable_lp $MOD_LIVEPATCH
> + unload_lp $MOD_LIVEPATCH2
> + unload_lp $MOD_LIVEPATCH
>
> -check_result "% insmod test_modules/$MOD_LIVEPATCH.ko
> + check_result "% insmod test_modules/$MOD_LIVEPATCH.ko
> livepatch: enabling patch '$MOD_LIVEPATCH'
> livepatch: '$MOD_LIVEPATCH': initializing patching transition
> $MOD_LIVEPATCH: pre_patch_callback: vmlinux
> @@ -548,6 +552,15 @@ $MOD_LIVEPATCH2: post_unpatch_callback: vmlinux
> livepatch: '$MOD_LIVEPATCH2': unpatching complete
> % rmmod $MOD_LIVEPATCH2
> % rmmod $MOD_LIVEPATCH"
> +}
> +
>
> +if [[ "$HAS_PROVIDES_ATTR" != "1" ]]; then
> + test_multiple_livepatches
> + test_atomic_replace
> +else
> + skip "multiple livepatches" "legacy replace attribute not present"
> + skip "atomic replace" "legacy replace attribute not present"
> +fi
I would revert the logic and ordering:
+ Positive checks are easier to read ;-)
+ It would make sense to have the obsolete checks in the "else" part.
+ It would be the same ordering as in the .c files.
> --- a/tools/testing/selftests/livepatch/test-kprobe.sh
> +++ b/tools/testing/selftests/livepatch/test-kprobe.sh
> @@ -196,6 +200,16 @@ livepatch: '$MOD_REPLACE': starting unpatching transition
> livepatch: '$MOD_REPLACE': completing unpatching transition
> livepatch: '$MOD_REPLACE': unpatching complete
> % rmmod $MOD_REPLACE"
> +}
> +
> +
> +if [[ "$HAS_PROVIDES_ATTR" != "1" ]]; then
> + test_multiple_livepatches
> + test_atomic_replace_livepatch
> +else
> + skip "multiple livepatches" "legacy replace attribute not present"
> + skip "atomic replace livepatch" "legacy replace attribute not present"
> +fi
Same here.
>
> # - load a target module that provides /proc/test_klp_mod_target with
> diff --git a/tools/testing/selftests/livepatch/test_modules/test_klp_callbacks_demo2.c b/tools/testing/selftests/livepatch/test_modules/test_klp_callbacks_demo2.c
> index 5417573e80af..6c46ce575f5c 100644
> --- a/tools/testing/selftests/livepatch/test_modules/test_klp_callbacks_demo2.c
> +++ b/tools/testing/selftests/livepatch/test_modules/test_klp_callbacks_demo2.c
> @@ -7,9 +7,16 @@
> #include <linux/kernel.h>
> #include <linux/livepatch.h>
>
> +#ifdef CONFIG_KLP_HAS_PROVIDES
JFYI, this is the related check in the .c code.
> +/*
> + * TODO: Add provides/obsoletes module parameters for the
> + * provides/obsoletes based tests (to be added later).
> + */
> +#else
> static int replace;
> module_param(replace, int, 0644);
> MODULE_PARM_DESC(replace, "replace (default=0)");
> +#endif
>
> static const char *const module_state[] = {
> [MODULE_STATE_LIVE] = "[MODULE_STATE_LIVE] Normal state",
Best Regardss,
Petr
next prev parent reply other threads:[~2026-10-01 15:57 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-30 3:03 [PATCH v10 0/9] livepatch: Add support for scoped atomic replace Yafang Shao
2026-09-30 3:03 ` [PATCH v10 1/9] selftests/livepatch: Clarify test module file names Yafang Shao
2026-10-01 15:27 ` Petr Mladek
2026-09-30 3:03 ` [PATCH v10 2/9] selftests/livepatch: Adapt atomic replace tests to provides/obsoletes Yafang Shao
2026-10-01 15:57 ` Petr Mladek [this message]
2026-10-02 12:01 ` Miroslav Benes
2026-09-30 3:03 ` [PATCH v10 3/9] livepatch: Make klp_find_func() non static Yafang Shao
2026-10-02 14:19 ` Petr Mladek
2026-09-30 3:03 ` [PATCH v10 4/9] livepatch: Call klp_init_patch_early() earlier Yafang Shao
2026-10-02 15:58 ` Petr Mladek
2026-09-30 3:03 ` [PATCH v10 5/9] livepatch: Implement provides and obsoletes for scoped atomic replace Yafang Shao
2026-10-02 12:01 ` Miroslav Benes
2026-10-02 17:06 ` Petr Mladek
2026-10-04 15:46 ` Yafang Shao
2026-10-08 10:30 ` Petr Mladek
2026-10-08 11:04 ` Yafang Shao
2026-10-09 8:33 ` Yafang Shao
2026-09-30 3:03 ` [PATCH v10 6/9] livepatch: Deprecate stack_order Yafang Shao
2026-09-30 3:03 ` [PATCH v10 7/9] selftests/livepatch: Add provides/obsoletes test scenarios Yafang Shao
2026-09-30 3:13 ` sashiko-bot
2026-09-30 3:29 ` Yafang Shao
2026-10-02 12:27 ` Miroslav Benes
2026-09-30 3:03 ` [PATCH v10 8/9] selftests/livepatch: Add state test for provides/obsoletes Yafang Shao
2026-09-30 3:03 ` [PATCH v10 9/9] selftests/livepatch: Add function " Yafang Shao
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=ar6C0B2aWg-4ayVU@pathway.suse.cz \
--to=pmladek@suse.com \
--cc=jikos@kernel.org \
--cc=joe.lawrence@redhat.com \
--cc=jpoimboe@kernel.org \
--cc=laoar.shao@gmail.com \
--cc=live-patching@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=song@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