From: Charlie Jenkins <charlie@rivosinc.com>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nicolas@fjasle.eu>,
Paul Walmsley <paul.walmsley@sifive.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Albert Ou <aou@eecs.berkeley.edu>,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org
Subject: Re: [PATCH] kbuild: Use --strip-unneeded with INSTALL_MOD_STRIP
Date: Fri, 31 Jan 2025 13:33:25 -0800 [thread overview]
Message-ID: <Z51BpVEkmVCg7gTX@ghost> (raw)
In-Reply-To: <CAK7LNAR=1sNs+hOW8gL=7xOs=gHLToTAnAUTF1SizroYoui8sg@mail.gmail.com>
On Sat, Feb 01, 2025 at 12:10:02AM +0900, Masahiro Yamada wrote:
> On Fri, Jan 31, 2025 at 3:54 PM Charlie Jenkins <charlie@rivosinc.com> wrote:
> >
> > On Thu, Jan 30, 2025 at 08:52:45PM -0700, Nathan Chancellor wrote:
> > > On Wed, Jan 22, 2025 at 07:17:26PM -0800, Charlie Jenkins wrote:
> > > > On riscv, kernel modules end up with a significant number of local
> > > > symbols. This becomes apparent when compiling modules with debug symbols
> > > > enabled. Using amdgpu.ko as an example of a large module, on riscv the
> > > > size is 754MB (no stripping), 53MB (--strip-debug), and 21MB
> > > > (--strip-unneeded). ON x86, amdgpu.ko is 482MB (no stripping), 21MB
> > > > (--strip-debug), and 20MB (--strip-unneeded).
> > > >
> > > > Use --strip-unneeded instead of --strip-debug to strip modules so
> > > > decrease the size of the resulting modules. This is particularly
> > > > relevant for riscv, but also marginally aids other architectures.
> > > >
> > > > Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
> > >
> > > Is there any sort of regression risk with this patch? If so, another
> > > option may be to give another level to INSTALL_MOD_STRIP like 2 so that
> > > INSTALL_MOD_STRIP=1 continues to behave as before but people can easily
> > > opt into this option. No strong opinion because I am not sure but was
> > > not sure if it was considered.
> >
> > I do not believe this would cause regressions. The description on gnu
> > strip is:
> >
> > "Remove all symbols that are not needed for relocation processing in
> > addition to debugging symbols and sections stripped by --strip-debug."
> >
> > The description on llvm-strip is:
> >
> > "Remove from the output all local or undefined symbols that are not
> > required by relocations. Also remove all debug sections."
> >
> > gnu strip --strip-unneeded strips slightly more aggressively but it does
> > not appear this causes any issues.
> >
> > >
> > > Regardless:
> > >
> > > Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> >
> > Thanks!
> >
>
>
> It is true --strip-unneeded drops a lot of compiler-generated symbols, but
> it also drops real symbols that originate in the source code.
>
> So, this would give user-visible changes for kallsyms at least.
Adding INSTALL_MOD_STRIP="--strip-unneeded" would be sufficient for
riscv. However, this has the downside that riscv will require different
flags than other architectures to get reasonably sized modules.
I believe these symbols are only useful for debugging, is there a
usecase for them to be available when the user has modules compiled with
INSTALL_MOD_STRIP=1?
- Charlie
>
>
> $ riscv64-linux-gnu-nm -n
> /tmp/strip-unneeded/lib/modules/6.13.0-09760-g69e858e0b8b2/kernel/drivers/gpu/drm/amd/amdgpu/amdgpu.ko
> > /tmp/symbol-with-strip-unneeded
> $ riscv64-linux-gnu-nm -n
> /tmp/strip-debug/lib/modules/6.13.0-09760-g69e858e0b8b2/kernel/drivers/gpu/drm/amd/amdgpu/amdgpu.ko
> > /tmp/symbol-with-strip-debug
>
> $ diff -u /tmp/symbol-with-strip-debug /tmp/symbol-with-strip-unneeded
> [ snip ]
> 00000000001676cc t uvd_v6_0_ring_test_ring
> 0000000000167802 t uvd_v6_0_ring_emit_pipeline_sync
> 0000000000167a02 t uvd_v6_0_ring_emit_fence
> -0000000000167b58 r CSWTCH.2
> -0000000000167b68 r abm_settings
> -0000000000167b80 r abm_config
> -0000000000167b90 r min_reduction_table_v_2_2
> -0000000000167ba0 r max_reduction_table_v_2_2
> -0000000000167bb0 r min_reduction_table
> -0000000000167bc0 r max_reduction_table
> -0000000000167bd0 r custom_backlight_curve0
> 0000000000167c38 r abm_settings_config2
> 0000000000167c70 r abm_settings_config1
> 0000000000167ca8 r abm_settings_config0
>
>
>
>
> --
> Best Regards
> Masahiro Yamada
next prev parent reply other threads:[~2025-01-31 21:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-23 3:17 [PATCH] kbuild: Use --strip-unneeded with INSTALL_MOD_STRIP Charlie Jenkins
2025-01-31 3:52 ` Nathan Chancellor
2025-01-31 6:54 ` Charlie Jenkins
2025-01-31 15:10 ` Masahiro Yamada
2025-01-31 21:33 ` Charlie Jenkins [this message]
2025-02-04 4:04 ` Masahiro Yamada
2025-02-04 18:29 ` Charlie Jenkins
2025-02-05 15:00 ` Masahiro Yamada
2025-04-03 15:07 ` Alexandre Ghiti
2025-04-21 6:06 ` Alexandre Ghiti
2025-01-31 14:26 ` Masahiro Yamada
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=Z51BpVEkmVCg7gTX@ghost \
--to=charlie@rivosinc.com \
--cc=aou@eecs.berkeley.edu \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=masahiroy@kernel.org \
--cc=nathan@kernel.org \
--cc=nicolas@fjasle.eu \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox