Re: [RFC PATCH 1/6] livepatch: Support scoped atomic replace using replace set
Petr Mladek <[email protected]>
| Newsgroups | org.kernel.vger.live-patching |
|---|---|
| Message-ID | <[email protected]> |
On Mon 2026-05-18 14:25:04, Song Liu wrote: > On Wed, May 13, 2026 at 7:34 AM Yafang Shao <[email protected]> wrote: > > > > Convert the replace attribute from a boolean to a u32 to function as a > > "replace set." A newly loaded livepatch will now atomically replace > > existing patches that belong to the same set. > > > > This change currently supports function replacement only; support for > > state and shadow variables will be introduced in subsequent patches. > > > > Suggested-by: Song Liu <[email protected]> > > Signed-off-by: Yafang Shao <[email protected]> > > --- > > .../livepatch/cumulative-patches.rst | 17 ++++++++------ > > Documentation/livepatch/livepatch.rst | 23 +++++++++++-------- > > include/linux/livepatch.h | 5 ++-- > > kernel/livepatch/core.c | 16 ++++++++----- > > kernel/livepatch/state.c | 17 +++++++------- > > kernel/livepatch/transition.c | 10 ++++---- > > scripts/livepatch/init.c | 7 +----- > > scripts/livepatch/klp-build | 14 +++++------ > > 8 files changed, 59 insertions(+), 50 deletions(-) > > > > diff --git a/Documentation/livepatch/cumulative-patches.rst b/Documentation/livepatch/cumulative-patches.rst > > index 1931f318976a..6ef49748110e 100644 > > --- a/Documentation/livepatch/cumulative-patches.rst > > +++ b/Documentation/livepatch/cumulative-patches.rst > > @@ -17,18 +17,20 @@ from all older livepatches and completely replace them in one transition. > > Usage > > ----- > > > > -The atomic replace can be enabled by setting "replace" flag in struct klp_patch, > > -for example:: > > +The "replace_set" attribute in ``struct klp_patch`` acts as a **replace set**, > > +defining the scope of the replacement. By default, the replace set is 1. > > + > > +For example:: > > > > static struct klp_patch patch = { > > .mod = THIS_MODULE, > > .objs = objs, > > - .replace = true, > > + .replace_set = 1, > > }; > > I wonder whether we should have "replace_set = 0" means no replace. > This will simplify the transition for users of the existing replace=false > option. I would like to hear other folks' thoughts on this. I would find this confusing. Also it would complicate the code. I always considered the "replace" and "no replace" mode as two separate worlds: + people using many "no replace" livepatches + people always using atomic replace But the code had to handle also the world where: + people might combine "no replace" and "replace all" livepatches which looked like a clash of the two worlds. And different people might have different expectations about the behavior. The "replace_set" allows to remove this clash. It looks like a win-win. And it makes the change acceptable for me. Best Regards, Petr