diff mbox series

[1/3] libkmod: Prefer builtin index over builtin.alias

Message ID 20220211084230.4489-1-lucas.demarchi@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/3] libkmod: Prefer builtin index over builtin.alias | expand

Commit Message

Lucas De Marchi Feb. 11, 2022, 8:42 a.m. UTC
The modules.builtin.alias.bin is way larger than the
modules.builtin.bin.  On a normal "distro kernel":

	21k modules.builtin.alias.bin
	11k modules.builtin.bin

From the kernel we get both modules.builtin and modules.builtin.modinfo.
depmod generates modules.builtin.bin and modules.builtin.alias.bin
from them respectively. modules.bultin is not going away: it's not
deprecated by the new index added. So, let's just stop duplicating the
information inside modules.builtin.alias.bin and just use the other
index.
---
 libkmod/libkmod-module.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

Comments

Alexey Gladkov Feb. 11, 2022, 10:45 a.m. UTC | #1
On Fri, Feb 11, 2022 at 12:42:28AM -0800, Lucas De Marchi wrote:
> The modules.builtin.alias.bin is way larger than the
> modules.builtin.bin.  On a normal "distro kernel":
> 
> 	21k modules.builtin.alias.bin
> 	11k modules.builtin.bin
> 
> >From the kernel we get both modules.builtin and modules.builtin.modinfo.
> depmod generates modules.builtin.bin and modules.builtin.alias.bin
> from them respectively. modules.bultin is not going away: it's not
> deprecated by the new index added. So, let's just stop duplicating the
> information inside modules.builtin.alias.bin and just use the other
> index.
> ---
>  libkmod/libkmod-module.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
> index 6f7747c..40d394a 100644
> --- a/libkmod/libkmod-module.c
> +++ b/libkmod/libkmod-module.c
> @@ -576,13 +576,14 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx,
>  	err = kmod_lookup_alias_from_aliases_file(ctx, alias, list);
>  	CHECK_ERR_AND_FINISH(err, fail, list, finish);
>  
> +	DBG(ctx, "lookup modules.builtin %s\n", alias);
> +	err = kmod_lookup_alias_from_builtin_file(ctx, alias, list);
> +

assigning to the err variable looks useless. It will be overwritten
anyway.

>  	DBG(ctx, "lookup modules.builtin.modinfo %s\n", alias);
>  	err = kmod_lookup_alias_from_kernel_builtin_file(ctx, alias, list);
> -	if (err == -ENOSYS) {
> -		/* Optional index missing, try the old one */
> -		DBG(ctx, "lookup modules.builtin %s\n", alias);
> -		err = kmod_lookup_alias_from_builtin_file(ctx, alias, list);
> -	}
> +	/* Optional index missing, ignore */
> +	if (err == -ENOSYS)
> +		err = 0;
>  	CHECK_ERR_AND_FINISH(err, fail, list, finish);
>  
>  
> -- 
> 2.35.1
>
Lucas De Marchi Feb. 12, 2022, 6:04 a.m. UTC | #2
On Fri, Feb 11, 2022 at 4:28 AM Alexey Gladkov <gladkov.alexey@gmail.com> wrote:
>
> On Fri, Feb 11, 2022 at 12:42:28AM -0800, Lucas De Marchi wrote:
> > The modules.builtin.alias.bin is way larger than the
> > modules.builtin.bin.  On a normal "distro kernel":
> >
> >       21k modules.builtin.alias.bin
> >       11k modules.builtin.bin
> >
> > >From the kernel we get both modules.builtin and modules.builtin.modinfo.
> > depmod generates modules.builtin.bin and modules.builtin.alias.bin
> > from them respectively. modules.bultin is not going away: it's not
> > deprecated by the new index added. So, let's just stop duplicating the
> > information inside modules.builtin.alias.bin and just use the other
> > index.
> > ---
> >  libkmod/libkmod-module.c | 11 ++++++-----
> >  1 file changed, 6 insertions(+), 5 deletions(-)
> >
> > diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
> > index 6f7747c..40d394a 100644
> > --- a/libkmod/libkmod-module.c
> > +++ b/libkmod/libkmod-module.c
> > @@ -576,13 +576,14 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx,
> >       err = kmod_lookup_alias_from_aliases_file(ctx, alias, list);
> >       CHECK_ERR_AND_FINISH(err, fail, list, finish);
> >
> > +     DBG(ctx, "lookup modules.builtin %s\n", alias);
> > +     err = kmod_lookup_alias_from_builtin_file(ctx, alias, list);
> > +
>
> assigning to the err variable looks useless. It will be overwritten
> anyway.
>


we were supposed to have a CHECK_ERR_AND_FINISH(err, fail, list, finish);
here.

thanks
Lucas De Marchi
diff mbox series

Patch

diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index 6f7747c..40d394a 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -576,13 +576,14 @@  KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx,
 	err = kmod_lookup_alias_from_aliases_file(ctx, alias, list);
 	CHECK_ERR_AND_FINISH(err, fail, list, finish);
 
+	DBG(ctx, "lookup modules.builtin %s\n", alias);
+	err = kmod_lookup_alias_from_builtin_file(ctx, alias, list);
+
 	DBG(ctx, "lookup modules.builtin.modinfo %s\n", alias);
 	err = kmod_lookup_alias_from_kernel_builtin_file(ctx, alias, list);
-	if (err == -ENOSYS) {
-		/* Optional index missing, try the old one */
-		DBG(ctx, "lookup modules.builtin %s\n", alias);
-		err = kmod_lookup_alias_from_builtin_file(ctx, alias, list);
-	}
+	/* Optional index missing, ignore */
+	if (err == -ENOSYS)
+		err = 0;
 	CHECK_ERR_AND_FINISH(err, fail, list, finish);