All of lore.kernel.org
 help / color / mirror / Atom feed
From: Allen Webb <allenwebb@google.com>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: "linux-modules@vger.kernel.org" <linux-modules@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	gregkh@linuxfoundation.org, christophe.leroy@csgroup.eu,
	nick.alcock@oracle.com
Subject: Re: [PATCH v10 08/11] build: Add modules.builtin.alias
Date: Wed, 19 Jul 2023 14:51:48 -0500	[thread overview]
Message-ID: <CAJzde04MmfyGeAzQ_7FW-0sATk7TT-MkxCbNPSzb-94wK6nhkA@mail.gmail.com> (raw)
In-Reply-To: <ZG22iPLED+SJsEFa@bombadil.infradead.org>

I finally got a chance to go through the comments and work on a
follow-up to this series, but it probably makes sense to get this
sorted ahead of the follow-up (if possible).

On Wed, May 24, 2023 at 2:02 AM Luis Chamberlain <mcgrof@kernel.org> wrote:
>
> On Thu, Apr 06, 2023 at 02:00:27PM -0500, Allen Webb wrote:
> > Generate modules.builtin.alias using modpost and install it with the
> > modules.
>
> Why? This is probably one of the more important commits and the
> commit log is pretty slim.
>
> > Signed-off-by: Allen Webb <allenwebb@google.com>
> > ---
> >  .gitignore               |  1 +
> >  Makefile                 |  1 +
> >  scripts/Makefile.modpost | 15 +++++++++++++++
> >  3 files changed, 17 insertions(+)
> >
> > diff --git a/.gitignore b/.gitignore
> > index 13a7f08a3d73..ddaa622bddac 100644
> > --- a/.gitignore
> > +++ b/.gitignore
> > @@ -71,6 +71,7 @@ modules.order
> >  /System.map
> >  /Module.markers
> >  /modules.builtin
> > +/modules.builtin.alias
> >  /modules.builtin.modinfo
> >  /modules.nsdeps
> >
> > diff --git a/Makefile b/Makefile
> > index a2c310df2145..43dcc1ea5fcf 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -1578,6 +1578,7 @@ __modinst_pre:
> >       fi
> >       @sed 's:^\(.*\)\.o$$:kernel/\1.ko:' modules.order > $(MODLIB)/modules.order
> >       @cp -f modules.builtin $(MODLIB)/
> > +     @cp -f modules.builtin.alias $(MODLIB)/
> >       @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
> >
> >  endif # CONFIG_MODULES
> > diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
> > index 0980c58d8afc..e3ecc17a7a19 100644
> > --- a/scripts/Makefile.modpost
> > +++ b/scripts/Makefile.modpost
> > @@ -15,6 +15,7 @@
> >  # 2) modpost is then used to
> >  # 3)  create one <module>.mod.c file per module
> >  # 4)  create one Module.symvers file with CRC for all exported symbols
> > +# 5)  create modules.builtin.alias the aliases for built-in modules
>
> Does everyone want that file?

Not everyone needs it so we could exclude it, but the cost of adding
it isn't that high. I am fine with putting it behind a config, though
we would need to decide whether to have it default on/off.

>
> >  # Step 3 is used to place certain information in the module's ELF
> >  # section, including information such as:
> > @@ -63,6 +64,20 @@ modpost-args += -T $(MODORDER)
> >  modpost-deps += $(MODORDER)
> >  endif
> >
> > +ifneq ($(wildcard vmlinux.o),)
> > +output-builtin.alias := modules.builtin.alias
> > +modpost-args += -b .modules.builtin.alias.in
> > +.modules.builtin.alias.in: $(output-symdump)
> > +     @# Building $(output-symdump) generates .modules.builtin.alias.in as a
> > +     @# side effect.
> > +     @[ -e $@ ] || $(MODPOST) -b .modules.builtin.alias.in vmlinux.o
>
> Does using -b create a delay in builds ? What is the effect on build
> time on a typical 4-core or 8-core build? Does everyone want it?

Here is some data I collected related to build time and memory usage impact:

Without builtin.alias:
TIME="real %e\nuser %U\nsys %S\nres-max %M" time scripts/mod/modpost
-E -o Module.symvers -T modules.order
ERROR: modpost: "__x86_return_thunk"
[arch/x86/crypto/chacha-x86_64.ko] undefined!
ERROR: modpost: "kernel_fpu_end" [arch/x86/crypto/chacha-x86_64.ko] undefined!
ERROR: modpost: "hchacha_block_generic"
[arch/x86/crypto/chacha-x86_64.ko] undefined!
ERROR: modpost: "boot_cpu_data" [arch/x86/crypto/chacha-x86_64.ko] undefined!
ERROR: modpost: "static_key_enable" [arch/x86/crypto/chacha-x86_64.ko]
undefined!
ERROR: modpost: "cpu_has_xfeatures" [arch/x86/crypto/chacha-x86_64.ko]
undefined!
ERROR: modpost: "crypto_register_skciphers"
[arch/x86/crypto/chacha-x86_64.ko] undefined!
ERROR: modpost: "crypto_unregister_skciphers"
[arch/x86/crypto/chacha-x86_64.ko] undefined!
ERROR: modpost: "__stack_chk_fail" [arch/x86/crypto/chacha-x86_64.ko] undefined!
ERROR: modpost: "memset" [arch/x86/crypto/chacha-x86_64.ko] undefined!
WARNING: modpost: suppressed 17432 unresolved symbol warnings because
there were too many)
Command exited with non-zero status 1
real 0.44
user 0.43
sys 0.01
res-max 4896

With builtin.alias:
TIME="real %e\nuser %U\nsys %S\nres-max %M" time scripts/mod/modpost
-E -o Module.symvers -T modules.order -b .modules.builtin.alias.in
vmlinux.o
real 1.43
user 1.38
sys 0.05
res-max 51920

Notice that modpost only uses a single core, so multicore isn't really
as much of a factor here. While it more than triples the time required
for the modpost operation the difference is only about one second of
CPU time. The memory usage is much larger when generating
modules.builtin.alias because of the size of vmlinux.o.

My biggest performance related concern is actually the size difference
of vmlinux caused by the modules.h changes, but it looks like that is
negligible (24KiB):

Without builtin.alias:
du vmlinux.o
663048  vmlinux.o

With builtin.alias:
du vmlinux.o
663072  vmlinux.o

>
> Should we add a new option which lets people decide if they want this
> at build time or not?

I don't feel strongly that there should or should not be a config for
this. On the side for a config the extra second of CPU time and space
taken up by the modules.builtin.alias file would add up across all the
builds and machines, so removing it where it isn't used would help
mitigate that. On the flip side if it isn't used widely enough, it is
more likely that breakages are missed until someone who actually uses
it notices.

Please let me know if you feel strongly either way given the data.

Thanks,
Allen

>
>   Luis
>
> > +
> > +$(output-builtin.alias): .modules.builtin.alias.in
> > +     sort -o $@ $^
> > +
> > +__modpost: $(output-builtin.alias)
> > +endif
> > +
> >  ifeq ($(KBUILD_EXTMOD),)
> >
> >  # Generate the list of in-tree objects in vmlinux
> > --
> > 2.39.2
> >

  reply	other threads:[~2023-07-19 19:52 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAJzde06+FXNpyBzT+NfS2GCfqEERMkGDpdsmHQj=v1foLJW4Cw@mail.gmail.com>
2022-11-29 22:43 ` [PATCH v3] modules: add modalias file to sysfs for modules Allen Webb
2022-11-30  7:06   ` Greg Kroah-Hartman
2022-11-30 22:14     ` [PATCH v4] " Allen Webb
2022-12-01  4:33       ` kernel test robot
2022-12-01  6:06       ` Greg Kroah-Hartman
2022-12-01  9:46       ` kernel test robot
2022-12-08  2:34   ` [PATCH v3] " Luis Chamberlain
2022-12-08 14:22     ` Allen Webb
2022-12-08 15:20       ` Greg Kroah-Hartman
2022-12-16 22:16         ` [PATCH v7 0/5] Generate modules.builtin.alias from match ids Allen Webb
2022-12-16 22:16           ` [PATCH v7 1/5] module.h: MODULE_DEVICE_TABLE for built-in modules Allen Webb
2022-12-17  3:49             ` kernel test robot
2022-12-17  3:59             ` kernel test robot
2022-12-17  4:50             ` kernel test robot
2022-12-17 10:05             ` Christophe Leroy
2022-12-19 15:56               ` Allen Webb
2022-12-16 22:17           ` [PATCH v7 2/5] modpost: Track module name " Allen Webb
2022-12-17 10:08             ` Christophe Leroy
2022-12-16 22:17           ` [PATCH v7 3/5] modpost: Add -b option for emitting built-in aliases Allen Webb
2022-12-17 10:10             ` Christophe Leroy
2022-12-16 22:17           ` [PATCH v7 4/5] file2alias.c: Implement builtin.alias generation Allen Webb
2022-12-17  0:47             ` kernel test robot
2022-12-17  3:09             ` kernel test robot
2022-12-17 10:13             ` Christophe Leroy
2022-12-16 22:17           ` [PATCH v7 5/5] build: Add modules.builtin.alias Allen Webb
2022-12-19 19:18           ` [PATCH v8 0/9] Generate modules.builtin.alias from match ids Allen Webb
2022-12-19 19:18             ` [PATCH v8 1/9] imx: Fix typo Allen Webb
2022-12-19 19:21               ` Greg Kroah-Hartman
2022-12-19 19:55                 ` Allen Webb
2022-12-19 19:18             ` [PATCH v8 2/9] rockchip-mailbox: " Allen Webb
2022-12-19 19:18             ` [PATCH v8 3/9] scsi/BusLogic: Always include device id table Allen Webb
2022-12-19 19:18             ` [PATCH v8 4/9] stmpe-spi: Fix typo Allen Webb
2022-12-19 19:18             ` [PATCH v8 5/9] module.h: MODULE_DEVICE_TABLE for built-in modules Allen Webb
2022-12-19 19:18             ` [PATCH v8 6/9] modpost: Track module name " Allen Webb
2022-12-19 19:18             ` [PATCH v8 7/9] modpost: Add -b option for emitting built-in aliases Allen Webb
2022-12-19 19:18             ` [PATCH v8 8/9] file2alias.c: Implement builtin.alias generation Allen Webb
2022-12-19 19:18             ` [PATCH v8 9/9] build: Add modules.builtin.alias Allen Webb
2022-12-19 20:06             ` [PATCH v8 0/9] Generate modules.builtin.alias from match ids Luis Chamberlain
2022-12-19 20:42               ` Allen Webb
2022-12-19 20:46             ` [PATCH v9 00/10] " Allen Webb
2022-12-19 20:46               ` [PATCH v9 01/10] imx: Fix typo Allen Webb
2022-12-19 21:23                 ` Luis Chamberlain
2022-12-20  6:42                 ` Greg Kroah-Hartman
2022-12-20 14:26                   ` Allen Webb
2022-12-20 14:32                     ` Greg Kroah-Hartman
2022-12-20 14:45                       ` Allen Webb
2022-12-19 20:46               ` [PATCH v9 02/10] rockchip-mailbox: " Allen Webb
2022-12-20  6:46                 ` Greg Kroah-Hartman
2022-12-20 14:58                   ` Allen Webb
2022-12-20 18:12                     ` Luis Chamberlain
2022-12-20 18:19                       ` Allen Webb
2022-12-20 18:47                         ` Luis Chamberlain
2022-12-20 19:49                           ` Allen Webb
2022-12-20 20:03                             ` Luis Chamberlain
2022-12-20 21:57                               ` Allen Webb
2022-12-20 23:09                                 ` Luis Chamberlain
2022-12-27 17:42                                   ` Allen Webb
2023-01-10  0:25                                     ` Luis Chamberlain
2023-01-09 11:54                           ` Nick Alcock
2023-01-10 18:20                             ` Allen Webb
2022-12-19 20:46               ` [PATCH v9 03/10] scsi/BusLogic: Always include device id table Allen Webb
2022-12-19 20:46               ` [PATCH v9 04/10] stmpe-spi: Fix typo Allen Webb
2022-12-19 20:46               ` [PATCH v9 05/10] module.h: MODULE_DEVICE_TABLE for built-in modules Allen Webb
2022-12-20  6:45                 ` Greg Kroah-Hartman
2022-12-20 16:36                   ` Allen Webb
2022-12-19 20:46               ` [PATCH v9 06/10] modpost: Track module name " Allen Webb
2022-12-19 20:46               ` [PATCH v9 07/10] modpost: Add -b option for emitting built-in aliases Allen Webb
2022-12-20  6:43                 ` Greg Kroah-Hartman
2022-12-20 17:32                   ` Allen Webb
2022-12-19 20:46               ` [PATCH v9 08/10] file2alias.c: Implement builtin.alias generation Allen Webb
2022-12-19 20:46               ` [PATCH v9 09/10] build: Add modules.builtin.alias Allen Webb
2022-12-19 20:46               ` [PATCH v9 10/10] docs: Include modules.builtin.alias Allen Webb
2022-12-19 20:49                 ` Allen Webb
2022-12-19 21:23                 ` Luis Chamberlain
2022-12-19 21:40                   ` Allen Webb
2022-12-19 22:07                     ` Luis Chamberlain
2022-12-19 22:20                       ` Allen Webb
2022-12-19 22:51                         ` Luis Chamberlain
2022-12-19 20:46               ` [PATCH v9 10/10] Documentation: " Allen Webb
2023-04-06 19:00               ` [PATCH v10 00/11] Generate modules.builtin.alias from match ids Allen Webb
2023-04-06 19:00                 ` [PATCH v10 01/11] rockchip-mailbox: Remove unneeded MODULE_DEVICE_TABLE Allen Webb
2023-04-06 19:00                 ` [PATCH v10 02/11] scsi/BusLogic: Always include device id table Allen Webb
2023-04-06 19:00                 ` [PATCH v10 03/11] stmpe-spi: Fix MODULE_DEVICE_TABLE entries Allen Webb
2023-05-24  6:52                   ` Luis Chamberlain
2023-05-24  6:52                   ` Luis Chamberlain
2023-04-06 19:00                 ` [PATCH v10 04/11] module.h: MODULE_DEVICE_TABLE for built-in modules Allen Webb
2023-05-24  6:44                   ` Luis Chamberlain
2023-04-06 19:00                 ` [PATCH v10 05/11] modpost: Track module name " Allen Webb
2023-04-20  9:47                   ` Greg KH
2023-05-24  6:50                   ` Luis Chamberlain
2023-04-06 19:00                 ` [PATCH v10 06/11] modpost: Add -b option for emitting built-in aliases Allen Webb
2023-05-24  6:54                   ` Luis Chamberlain
2023-04-06 19:00                 ` [PATCH v10 07/11] file2alias.c: Implement builtin.alias generation Allen Webb
2023-05-24  7:00                   ` Luis Chamberlain
2023-04-06 19:00                 ` [PATCH v10 08/11] build: Add modules.builtin.alias Allen Webb
2023-05-24  7:02                   ` Luis Chamberlain
2023-07-19 19:51                     ` Allen Webb [this message]
2023-07-26 18:30                       ` Luis Chamberlain
2023-04-06 19:00                 ` [PATCH v10 09/11] Documentation: Include modules.builtin.alias Allen Webb
2023-04-06 19:00                 ` [PATCH v10 10/11] Documentation: Update writing_usb_driver for built-in modules Allen Webb
2023-04-06 19:00                 ` [PATCH v10 11/11] Documentation: add USB authorization document to driver-api Allen Webb
2023-04-20  9:51                   ` Greg KH

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=CAJzde04MmfyGeAzQ_7FW-0sATk7TT-MkxCbNPSzb-94wK6nhkA@mail.gmail.com \
    --to=allenwebb@google.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=nick.alcock@oracle.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.