mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Petr Pavlu <petr.pavlu@suse.com>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: Alexey Gladkov <legion@kernel.org>,
	Ard Biesheuvel <ardb@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nicolas Schier <nicolas@fjasle.eu>,
	linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] module: remove meaningless 'name' parameter from __MODULE_INFO()
Date: Fri, 13 Jun 2025 12:21:19 +0200	[thread overview]
Message-ID: <f64cd2c7-905c-4554-b007-ad3fd528cec9@suse.com> (raw)
In-Reply-To: <20250606041029.614348-2-masahiroy@kernel.org>

On 6/6/25 6:10 AM, Masahiro Yamada wrote:
> The symbol names in the .modinfo section are never used and already
> randomized by the __UNIQUE_ID() macro.
> 
> Therefore, the second parameter of  __MODULE_INFO() is meaningless
> and can be removed to simplify the code.
> 
> With this change, the symbol names in the .modinfo section will be
> prefixed with __UNIQUE_ID_modinfo, making it clearer that they
> originate from MODULE_INFO().
> 
> [Before]
> 
>   $ objcopy  -j .modinfo vmlinux.o modinfo.o
>   $ nm -n modinfo.o | head -n10
>   0000000000000000 r __UNIQUE_ID_license560
>   0000000000000011 r __UNIQUE_ID_file559
>   0000000000000030 r __UNIQUE_ID_description558
>   0000000000000074 r __UNIQUE_ID_license580
>   000000000000008e r __UNIQUE_ID_file579
>   00000000000000bd r __UNIQUE_ID_description578
>   00000000000000e6 r __UNIQUE_ID_license581
>   00000000000000ff r __UNIQUE_ID_file580
>   0000000000000134 r __UNIQUE_ID_description579
>   0000000000000179 r __UNIQUE_ID_uncore_no_discover578
> 
> [After]
> 
>   $ objcopy  -j .modinfo vmlinux.o modinfo.o
>   $ nm -n modinfo.o | head -n10
>   0000000000000000 r __UNIQUE_ID_modinfo560
>   0000000000000011 r __UNIQUE_ID_modinfo559
>   0000000000000030 r __UNIQUE_ID_modinfo558
>   0000000000000074 r __UNIQUE_ID_modinfo580
>   000000000000008e r __UNIQUE_ID_modinfo579
>   00000000000000bd r __UNIQUE_ID_modinfo578
>   00000000000000e6 r __UNIQUE_ID_modinfo581
>   00000000000000ff r __UNIQUE_ID_modinfo580
>   0000000000000134 r __UNIQUE_ID_modinfo579
>   0000000000000179 r __UNIQUE_ID_modinfo578
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> [...]
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 92e1420fccdf..81b41cc6a19e 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -164,9 +164,6 @@ extern void cleanup_module(void);
>  
>  struct module_kobject *lookup_or_create_module_kobject(const char *name);
>  
> -/* Generic info of form tag = "info" */
> -#define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
> -
>  /* For userspace: you can also call me... */
>  #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
>  
> diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
> index bfb85fd13e1f..00166f747e27 100644
> --- a/include/linux/moduleparam.h
> +++ b/include/linux/moduleparam.h
> @@ -20,18 +20,19 @@
>  /* Chosen so that structs with an unsigned long line up. */
>  #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
>  
> -#define __MODULE_INFO(tag, name, info)					  \
> -	static const char __UNIQUE_ID(name)[]				  \
> +/* Generic info of form tag = "info" */
> +#define MODULE_INFO(tag, info)					  \
> +	static const char __UNIQUE_ID(modinfo)[]			  \
>  		__used __section(".modinfo") __aligned(1)		  \
>  		= __MODULE_INFO_PREFIX __stringify(tag) "=" info
>  

One nit is that MODULE_INFO() is now defined in moduleparam.h, even
though it is a general macro for adding module information and not
specifically tied to parameters. I realize it is needed in moduleparam.h
and that the dependency is from module.h to moduleparam.h, not the other
way around. We could potentially keep the MODULE_INFO() (in module.h) ->
__MODULE_INFO() (moduleparam.h) split solely for this, but it is
probably unnecessary.

The overall change looks ok to me.

Reviewed-by: Petr Pavlu <petr.pavlu@suse.com>

-- 
Thanks,
Petr

  reply	other threads:[~2025-06-13 10:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-06  4:10 [PATCH 0/4] kbuild: generate module.builtin.modinfo from vmlinux.unstripped instead of vmlinux.o Masahiro Yamada
2025-06-06  4:10 ` [PATCH 1/4] module: remove meaningless 'name' parameter from __MODULE_INFO() Masahiro Yamada
2025-06-13 10:21   ` Petr Pavlu [this message]
2025-06-06  4:10 ` [PATCH 2/4] kbuild: always create intermediate vmlinux.unstripped Masahiro Yamada
2025-06-06  4:10 ` [PATCH 3/4] kbuild: keep .modinfo section in vmlinux.unstripped Masahiro Yamada
2025-06-06 12:53   ` kernel test robot
2025-06-06  4:10 ` [PATCH 4/4] kbuild: extract modules.builtin.modinfo from vmlinux.unstripped Masahiro Yamada
2025-06-07  0:46   ` kernel test robot
2025-06-11 10:38   ` Alexey Gladkov
2025-06-08 14:44 ` [PATCH 0/4] kbuild: generate module.builtin.modinfo from vmlinux.unstripped instead of vmlinux.o Alexey Gladkov
2025-06-11 10:34 ` [PATCH 0/3] Add generated modalias to modules.builtin.modinfo Alexey Gladkov
2025-06-11 10:34   ` [PATCH 1/3] scsi: Always define blogic_pci_tbl structure Alexey Gladkov
2025-06-11 10:34   ` [PATCH 2/3] modpost: Add modname to mod_device_table alias Alexey Gladkov
2025-06-11 10:34   ` [PATCH 3/3] modpost: Create modalias for builtin modules Alexey Gladkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f64cd2c7-905c-4554-b007-ad3fd528cec9@suse.com \
    --to=petr.pavlu@suse.com \
    --cc=ardb@kernel.org \
    --cc=legion@kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nicolas@fjasle.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®