Re: [RFC PATCH v3 03/13] module: Move livepatch support to a separate file

From: Joe Perches
Date: Sat Jan 29 2022 - 02:27:58 EST


On Fri, 2022-01-28 at 20:39 +0000, Aaron Tomlin wrote:
> No functional change.
>
> This patch migrates livepatch support (i.e. used during module
> add/or load and remove/or deletion) from core module code into
> kernel/module/livepatch.c. At the moment it contains code to
> persist Elf information about a given livepatch module, only.
[]
> diff --git a/include/linux/module.h b/include/linux/module.h
[]
> @@ -668,11 +668,22 @@ static inline bool is_livepatch_module(struct module *mod)
> {
> return mod->klp;
> }
> +
> +static inline bool set_livepatch_module(struct module *mod)
> +{
> + mod->klp = true;
> + return true;
> +}
> #else /* !CONFIG_LIVEPATCH */
> static inline bool is_livepatch_module(struct module *mod)
> {
> return false;
> }
> +
> +static inline bool set_livepatch_module(struct module *mod)
> +{
> + return false;
> +}
> #endif /* CONFIG_LIVEPATCH */

style trivia:

Generally, these static inlines can be written deduplicating
the function declaration and using IS_ENABLED or #if inside
the definition.

Something like:

static inline bool is_livepatch_module(struct module *mod)
{
if (IS_ENABLED(CONFIG_LIVEPATCH)) {
mod->klp = true;
return true;
}
return false;
}

or

static inline bool is_livepatch_module(struct module *mod)
{
#ifdef CONFIG_LIVEPATCH
mod->klp = true;
return true;
#else
return false;
#endif
}