[PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels

Marcos Paulo de Souza posted 6 patches 2 months ago
There is a newer version of this series
tools/testing/selftests/livepatch/functions.sh     |  10 ++
tools/testing/selftests/livepatch/test-kprobe.sh   |   8 +-
tools/testing/selftests/livepatch/test-sysfs.sh    | 120 ++++++++++++---------
.../livepatch/test_modules/test_klp_syscall.c      |  17 ++-
4 files changed, 99 insertions(+), 56 deletions(-)
[PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels
Posted by Marcos Paulo de Souza 2 months ago
A new version of the patchset, with fewer patches now. Please take a look!

Original cover-letter:
These patches don't really change how the patches are run, just skip
some tests on kernels that don't support a feature (like kprobe and
livepatched living together) or when a livepatch sysfs attribute is
missing.

The last patch slightly adjusts check_result function to skip dmesg
messages on SLE kernels when a livepatch is removed.

These patches are based on printk/for-next branch.

Please review! Thanks!

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
---
Changes in v2:
- Patch descriptions were changed to remove "test-X", since it was polluting the commit subjects (Miroslav Benes)
- Patch 8 was dropped since it was checking for a message from an out-of-tree patch. (Petr Mladek)
- Patch 3 was dropped as should be treated as expected failure for older kernels. (Petr Mladek)
- Patch 2 was changed to use y/n instead of 1/0, since it's more natural to use it.
- Patch 1 was changed to handle ppc and loongson, and error out if dealing with a different architecture that sets
  CONFIG_ARCH_HAS_SYSCALL_WRAPPER and haven't changed the test to include the proper wrapper prefix.
- Patch 4 was changed to invert the return of the bash function to return 1 in failure, like
  a normal bash function (Joe Lawrence)
- Patches 5, 6 an 7 were changed to not split the tests, but to only run the tests
  when the attribute were present (Miroslav Benes)
- Link to v1: https://patch.msgid.link/20260313-lp-tests-old-fixes-v1-0-71ac6dfb3253@suse.com

---
Marcos Paulo de Souza (6):
      selftests: livepatch: Check for ARCH_HAS_SYSCALL_WRAPPER config
      selftests: livepatch: Replace true/false module parameter by y/n
      selftests: livepatch: Introduce does_sysfs_exists function
      selftests: livepatch: Check if patched sysfs attribute exists
      selftests: livepatch: Check if replace sysfs attribute exists
      selftests: livepatch: Check if stack_order sysfs attribute exists

 tools/testing/selftests/livepatch/functions.sh     |  10 ++
 tools/testing/selftests/livepatch/test-kprobe.sh   |   8 +-
 tools/testing/selftests/livepatch/test-sysfs.sh    | 120 ++++++++++++---------
 .../livepatch/test_modules/test_klp_syscall.c      |  17 ++-
 4 files changed, 99 insertions(+), 56 deletions(-)
---
base-commit: 712c0756828becbfc629ff8d8b82deff5d1115e4
change-id: 20260309-lp-tests-old-fixes-f955abc8ec27

Best regards,
--  
Marcos Paulo de Souza <mpdesouza@suse.com>
Re: [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels
Posted by Josh Poimboeuf 2 months ago
On Mon, Apr 13, 2026 at 02:26:11PM -0300, Marcos Paulo de Souza wrote:
> A new version of the patchset, with fewer patches now. Please take a look!
> 
> Original cover-letter:
> These patches don't really change how the patches are run, just skip
> some tests on kernels that don't support a feature (like kprobe and
> livepatched living together) or when a livepatch sysfs attribute is
> missing.
> 
> The last patch slightly adjusts check_result function to skip dmesg
> messages on SLE kernels when a livepatch is removed.

Why are we adding complexity to support Linux 4.12 in mainline?  Isn't
that what enterprise distros are for?

-- 
Josh
Re: [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels
Posted by Marcos Paulo de Souza 2 months ago
On Thu, 2026-04-16 at 10:07 -0700, Josh Poimboeuf wrote:
> On Mon, Apr 13, 2026 at 02:26:11PM -0300, Marcos Paulo de Souza
> wrote:
> > A new version of the patchset, with fewer patches now. Please take
> > a look!
> > 
> > Original cover-letter:
> > These patches don't really change how the patches are run, just
> > skip
> > some tests on kernels that don't support a feature (like kprobe and
> > livepatched living together) or when a livepatch sysfs attribute is
> > missing.
> > 
> > The last patch slightly adjusts check_result function to skip dmesg
> > messages on SLE kernels when a livepatch is removed.
> 
> Why are we adding complexity to support Linux 4.12 in mainline? 
> Isn't
> that what enterprise distros are for?

These changes do not add any new complex code, just checks to enable
the tests to run on older kernels. I believe that it would be good for
all enterprises distros if they could run more tests in maintenance
updates of their kernels using the upstream tests.

The changes are not really that big. Some patches were removed from v1
because there were adding checks for out-of-tree messages (like the
last paragraph of the v2 erroneously shows), and another one was to
check if kprobes could live alongside livepatches, which fails for 4.12
kernels.

The patches for this versions introduce only checks to avoid testing
sysfs attributes for kernels that don't supports them.
Re: [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels
Posted by Joe Lawrence 1 month, 4 weeks ago
On Thu, Apr 16, 2026 at 03:18:33PM -0300, Marcos Paulo de Souza wrote:
> On Thu, 2026-04-16 at 10:07 -0700, Josh Poimboeuf wrote:
> > On Mon, Apr 13, 2026 at 02:26:11PM -0300, Marcos Paulo de Souza
> > wrote:
> > > A new version of the patchset, with fewer patches now. Please take
> > > a look!
> > > 
> > > Original cover-letter:
> > > These patches don't really change how the patches are run, just
> > > skip
> > > some tests on kernels that don't support a feature (like kprobe and
> > > livepatched living together) or when a livepatch sysfs attribute is
> > > missing.
> > > 
> > > The last patch slightly adjusts check_result function to skip dmesg
> > > messages on SLE kernels when a livepatch is removed.
> > 
> > Why are we adding complexity to support Linux 4.12 in mainline? 
> > Isn't
> > that what enterprise distros are for?
> 
> These changes do not add any new complex code, just checks to enable
> the tests to run on older kernels. I believe that it would be good for
> all enterprises distros if they could run more tests in maintenance
> updates of their kernels using the upstream tests.
> 
> The changes are not really that big. Some patches were removed from v1
> because there were adding checks for out-of-tree messages (like the
> last paragraph of the v2 erroneously shows), and another one was to
> check if kprobes could live alongside livepatches, which fails for 4.12
> kernels.
> 
> The patches for this versions introduce only checks to avoid testing
> sysfs attributes for kernels that don't supports them.
> 

IMHO when the changes are reasonably small, I think we should consider
accomodating older kernels for the selftest suite.  If we reach the
point of having to introduce version #ifdef-erry, that opinion would
flip pretty quickly.  It's pretty amazing that modern tests still run on
older kernels (with this patchset) -- not an explicit kselftest goal
AFAIK, but nice to have.

If we do merge this patchset, it should update the doc
tools/testing/selftests/livepatch/README to note the oldest
expected/tested upstream kernel.  (So new selftest authors may have some
idea of what API / sysfs features to use.)  And that this compatibility
was only an incidental "feature" that came for nearly free.  It's not a
promise to never add backwards-incompatible tests in the future.

--
Joe
Re: [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels
Posted by Miroslav Benes 1 month, 3 weeks ago
On Fri, 17 Apr 2026, Joe Lawrence wrote:

> On Thu, Apr 16, 2026 at 03:18:33PM -0300, Marcos Paulo de Souza wrote:
> > On Thu, 2026-04-16 at 10:07 -0700, Josh Poimboeuf wrote:
> > > On Mon, Apr 13, 2026 at 02:26:11PM -0300, Marcos Paulo de Souza
> > > wrote:
> > > > A new version of the patchset, with fewer patches now. Please take
> > > > a look!
> > > > 
> > > > Original cover-letter:
> > > > These patches don't really change how the patches are run, just
> > > > skip
> > > > some tests on kernels that don't support a feature (like kprobe and
> > > > livepatched living together) or when a livepatch sysfs attribute is
> > > > missing.
> > > > 
> > > > The last patch slightly adjusts check_result function to skip dmesg
> > > > messages on SLE kernels when a livepatch is removed.
> > > 
> > > Why are we adding complexity to support Linux 4.12 in mainline? 
> > > Isn't
> > > that what enterprise distros are for?
> > 
> > These changes do not add any new complex code, just checks to enable
> > the tests to run on older kernels. I believe that it would be good for
> > all enterprises distros if they could run more tests in maintenance
> > updates of their kernels using the upstream tests.
> > 
> > The changes are not really that big. Some patches were removed from v1
> > because there were adding checks for out-of-tree messages (like the
> > last paragraph of the v2 erroneously shows), and another one was to
> > check if kprobes could live alongside livepatches, which fails for 4.12
> > kernels.
> > 
> > The patches for this versions introduce only checks to avoid testing
> > sysfs attributes for kernels that don't supports them.
> > 
> 
> IMHO when the changes are reasonably small, I think we should consider
> accomodating older kernels for the selftest suite.  If we reach the
> point of having to introduce version #ifdef-erry, that opinion would
> flip pretty quickly.  It's pretty amazing that modern tests still run on
> older kernels (with this patchset) -- not an explicit kselftest goal
> AFAIK, but nice to have.
> 
> If we do merge this patchset, it should update the doc
> tools/testing/selftests/livepatch/README to note the oldest
> expected/tested upstream kernel.  (So new selftest authors may have some
> idea of what API / sysfs features to use.)  And that this compatibility
> was only an incidental "feature" that came for nearly free.  It's not a
> promise to never add backwards-incompatible tests in the future.

I agree with Joe on both points.

Miroslav
Re: [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels
Posted by Miroslav Benes 2 months ago
On Mon, 13 Apr 2026, Marcos Paulo de Souza wrote:

> A new version of the patchset, with fewer patches now. Please take a look!
> 
> Original cover-letter:
> These patches don't really change how the patches are run, just skip
> some tests on kernels that don't support a feature (like kprobe and
> livepatched living together) or when a livepatch sysfs attribute is
> missing.
> 
> The last patch slightly adjusts check_result function to skip dmesg
> messages on SLE kernels when a livepatch is removed.
> 
> These patches are based on printk/for-next branch.
> 
> Please review! Thanks!
> 
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>

Besides my comment for 1/6 and what Sashiko discovered, it looks good to 
me.

However, please also take a look at brand new 
test_modules/test_klp_mod_target.c. It does not build on old kernels since 
they lack proc_create_single(). I think it should be covered in this patch 
set too.

Regards
Miroslav
Re: [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels
Posted by Marcos Paulo de Souza 2 months ago
On Wed, 2026-04-15 at 14:01 +0200, Miroslav Benes wrote:
> On Mon, 13 Apr 2026, Marcos Paulo de Souza wrote:
> 
> > A new version of the patchset, with fewer patches now. Please take
> > a look!
> > 
> > Original cover-letter:
> > These patches don't really change how the patches are run, just
> > skip
> > some tests on kernels that don't support a feature (like kprobe and
> > livepatched living together) or when a livepatch sysfs attribute is
> > missing.
> > 
> > The last patch slightly adjusts check_result function to skip dmesg
> > messages on SLE kernels when a livepatch is removed.
> > 
> > These patches are based on printk/for-next branch.
> > 
> > Please review! Thanks!
> > 
> > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> 
> Besides my comment for 1/6 and what Sashiko discovered, it looks good
> to 
> me.
> 
> However, please also take a look at brand new 
> test_modules/test_klp_mod_target.c. It does not build on old kernels
> since 
> they lack proc_create_single(). I think it should be covered in this
> patch 
> set too.

I saw that yesterday as well, but I wanted to merge this series first.
I have plans to create a way to unregister the livepatches if something
fails, so we can continue to run the other tests. I was planning to fix
the test_klp_mod_target.c in the same patchset.

> 
> Regards
> Miroslav
Re: [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels
Posted by Miroslav Benes 2 months ago
On Wed, 15 Apr 2026, Marcos Paulo de Souza wrote:

> On Wed, 2026-04-15 at 14:01 +0200, Miroslav Benes wrote:
> > On Mon, 13 Apr 2026, Marcos Paulo de Souza wrote:
> > 
> > > A new version of the patchset, with fewer patches now. Please take
> > > a look!
> > > 
> > > Original cover-letter:
> > > These patches don't really change how the patches are run, just
> > > skip
> > > some tests on kernels that don't support a feature (like kprobe and
> > > livepatched living together) or when a livepatch sysfs attribute is
> > > missing.
> > > 
> > > The last patch slightly adjusts check_result function to skip dmesg
> > > messages on SLE kernels when a livepatch is removed.
> > > 
> > > These patches are based on printk/for-next branch.
> > > 
> > > Please review! Thanks!
> > > 
> > > Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
> > 
> > Besides my comment for 1/6 and what Sashiko discovered, it looks good
> > to 
> > me.
> > 
> > However, please also take a look at brand new 
> > test_modules/test_klp_mod_target.c. It does not build on old kernels
> > since 
> > they lack proc_create_single(). I think it should be covered in this
> > patch 
> > set too.
> 
> I saw that yesterday as well, but I wanted to merge this series first.
> I have plans to create a way to unregister the livepatches if something
> fails, so we can continue to run the other tests. I was planning to fix
> the test_klp_mod_target.c in the same patchset.

Fair enough.

Miroslav
Re: [PATCH v2 0/6] kselftests: livepatch: Adapt tests to be executed on 4.12 kernels
Posted by Marcos Paulo de Souza 2 months ago
On Mon, 2026-04-13 at 14:26 -0300, Marcos Paulo de Souza wrote:
> A new version of the patchset, with fewer patches now. Please take a
> look!
> 
> Original cover-letter:
> These patches don't really change how the patches are run, just skip
> some tests on kernels that don't support a feature (like kprobe and
> livepatched living together) or when a livepatch sysfs attribute is
> missing.
> 
> The last patch slightly adjusts check_result function to skip dmesg
> messages on SLE kernels when a livepatch is removed.
> 
> These patches are based on printk/for-next branch.
> 
> Please review! Thanks!
> 
> Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>


I saw some checks made by sashiko, and besides they not being so
horrible, I believe that I should fix me an send a v3 to address them.
But still, feel free to take a look :)

https://sashiko.dev/#/patchset/20260413-lp-tests-old-fixes-v2-0-367c7cb5006f%40suse.com

> ---
> Changes in v2:
> - Patch descriptions were changed to remove "test-X", since it was
> polluting the commit subjects (Miroslav Benes)
> - Patch 8 was dropped since it was checking for a message from an
> out-of-tree patch. (Petr Mladek)
> - Patch 3 was dropped as should be treated as expected failure for
> older kernels. (Petr Mladek)
> - Patch 2 was changed to use y/n instead of 1/0, since it's more
> natural to use it.
> - Patch 1 was changed to handle ppc and loongson, and error out if
> dealing with a different architecture that sets
>   CONFIG_ARCH_HAS_SYSCALL_WRAPPER and haven't changed the test to
> include the proper wrapper prefix.
> - Patch 4 was changed to invert the return of the bash function to
> return 1 in failure, like
>   a normal bash function (Joe Lawrence)
> - Patches 5, 6 an 7 were changed to not split the tests, but to only
> run the tests
>   when the attribute were present (Miroslav Benes)
> - Link to v1:
> https://patch.msgid.link/20260313-lp-tests-old-fixes-v1-0-71ac6dfb3253@suse.com
> 
> ---
> Marcos Paulo de Souza (6):
>       selftests: livepatch: Check for ARCH_HAS_SYSCALL_WRAPPER config
>       selftests: livepatch: Replace true/false module parameter by
> y/n
>       selftests: livepatch: Introduce does_sysfs_exists function
>       selftests: livepatch: Check if patched sysfs attribute exists
>       selftests: livepatch: Check if replace sysfs attribute exists
>       selftests: livepatch: Check if stack_order sysfs attribute
> exists
> 
>  tools/testing/selftests/livepatch/functions.sh     |  10 ++
>  tools/testing/selftests/livepatch/test-kprobe.sh   |   8 +-
>  tools/testing/selftests/livepatch/test-sysfs.sh    | 120
> ++++++++++++---------
>  .../livepatch/test_modules/test_klp_syscall.c      |  17 ++-
>  4 files changed, 99 insertions(+), 56 deletions(-)
> ---
> base-commit: 712c0756828becbfc629ff8d8b82deff5d1115e4
> change-id: 20260309-lp-tests-old-fixes-f955abc8ec27
> 
> Best regards,
> --  
> Marcos Paulo de Souza <mpdesouza@suse.com>