speaker-test-module: Re: [PATCH] selftests/livepatch: add test for module function patching

From: Petr Mladek

Date: Mon Mar 30 2026 - 09:59:32 EST


On Thu 2026-03-26 16:41:02, Joe Lawrence wrote:
> On Thu, Mar 26, 2026 at 03:34:36PM +0100, Petr Mladek wrote:
> > On Fri 2026-03-20 17:11:17, Pablo Hugen wrote:
> > > From: Pablo Alessandro Santos Hugen <phugen@xxxxxxxxxx>
> > In my RFC, I created a helper module which implemented a person
> > (speaker) which would come on the stage and welcome the audience.
> > I am not sure if it was a good idea. But it became a bit confusing
> > when everything (module name, sysfs interface, function name, message)
> > included the same strings like (livepatch, callback, shadow_var).
> >
> > Anyway, my tests produced messages like these:
> >
> > +% cat $SYSFS_MODULE_DIR/$MOD_TARGET/parameters/welcome
> > +$MOD_TARGET: speaker_welcome: Hello, World!
> >
> > , see https://lore.kernel.org/all/20250115082431.5550-9-pmladek@xxxxxxxx/
> >
> >
> > There were even tests which blocked the transition. They tested shadow
> > variables which added an applause to the message. They did something like:
> >
> > <paste>
> > All four callbacks are used as follows:
> >
> > + pre_patch() allocates a shadow variable with a string and fills
> > it with "[]".
> > + post_patch() fills the string with "[APPLAUSE]".
> > + pre_unpatch() reverts the string back to "[]".
> > + post_unpatch() releases the shadow variable.
> >
> > The welcome message printed by the livepatched function allows us to
> > distinguish between the transition and the completed transition.
> > Specifically, the speaker's welcome message appears as:
> >
> > + Not patched system: "Hello, World!"
> > + Transition (unpatched task): "[] Hello, World!"
> > + Transition (patched task): "[] Ladies and gentlemen, ..."
> > + Patched system: "[APPLAUSE] Ladies and gentlemen, ..."
> > </paste>
> >
> > , see https://lore.kernel.org/all/20250115082431.5550-11-pmladek@xxxxxxxx/
> >
> > Sigh, I have done many changes in the tests for v1. But they still
> > need some love (and rebasing) for sending.
> >
>
> If these can be pulled out independently from the v1 patch, perhaps
> Pablo would want to hack on that in a follow up series?

Unfortunately, the selftest changes can't be pulled out easily.
The new test module and related livepatches are implemented using
the reworked livepatch API. :-/

I hope that I'll find time to work on it rather sooner than later.

Best Regards,
Petr