* [PATCH] m68k: Enable dead code elimination
@ 2025-04-16 11:42 Daniel Palmer
2025-04-27 23:37 ` Greg Ungerer
` (2 more replies)
0 siblings, 3 replies; 11+ messages in thread
From: Daniel Palmer @ 2025-04-16 11:42 UTC (permalink / raw)
To: geert, linux-m68k; +Cc: linux-kernel, Daniel Palmer
Allow the experimental dead code elimination config to be enabled.
For my 68000 nommu config this frees up a few hundred K of memory
so seems worth while.
Boot and build tested on nommu and mmu enabled configs.
Before:
Memory: 5388K/8192K available (1986K kernel code, 114K rwdata,
244K rodata, 92K init, 41K bss, 2624K reserved, 0K cma-reserved)
After
Memory: 5684K/8192K available (1714K kernel code, 112K rwdata,
228K rodata, 92K init, 37K bss, 2328K reserved, 0K cma-reserved)
Signed-off-by: Daniel Palmer <daniel@0x0f.com>
---
arch/m68k/Kconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index eb5bb6d36899..11835eb59d94 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -32,6 +32,7 @@ config M68K
select HAVE_ASM_MODVERSIONS
select HAVE_DEBUG_BUGVERBOSE
select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_HAS_NO_UNALIGNED
+ select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
select HAVE_MOD_ARCH_SPECIFIC
select HAVE_UID16
select MMU_GATHER_NO_RANGE if MMU
--
2.47.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] m68k: Enable dead code elimination
2025-04-16 11:42 [PATCH] m68k: Enable dead code elimination Daniel Palmer
@ 2025-04-27 23:37 ` Greg Ungerer
2025-04-29 0:04 ` Daniel Palmer
2025-06-16 4:48 ` Finn Thain
2025-07-06 9:14 ` Geert Uytterhoeven
2 siblings, 1 reply; 11+ messages in thread
From: Greg Ungerer @ 2025-04-27 23:37 UTC (permalink / raw)
To: Daniel Palmer, geert, linux-m68k; +Cc: linux-kernel
Hi Daniel,
On 16/4/25 21:42, Daniel Palmer wrote:
> Allow the experimental dead code elimination config to be enabled.
>
> For my 68000 nommu config this frees up a few hundred K of memory
> so seems worth while.
>
> Boot and build tested on nommu and mmu enabled configs.
>
> Before:
> Memory: 5388K/8192K available (1986K kernel code, 114K rwdata,
> 244K rodata, 92K init, 41K bss, 2624K reserved, 0K cma-reserved)
>
> After
> Memory: 5684K/8192K available (1714K kernel code, 112K rwdata,
> 228K rodata, 92K init, 37K bss, 2328K reserved, 0K cma-reserved)
>
> Signed-off-by: Daniel Palmer <daniel@0x0f.com>
Nice. It worked fine on ColdFire builds as well (both nommu and mmu).
Acked-by: Greg Ungerer <gerg@linux-m68k.org>
I notice that some other architectures (arm and powerpc) have version
checks on gcc or ld in the config. Do you know if there is any version
limitations for m68k here?
Regards
Greg
> ---
> arch/m68k/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> index eb5bb6d36899..11835eb59d94 100644
> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k/Kconfig
> @@ -32,6 +32,7 @@ config M68K
> select HAVE_ASM_MODVERSIONS
> select HAVE_DEBUG_BUGVERBOSE
> select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_HAS_NO_UNALIGNED
> + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
> select HAVE_MOD_ARCH_SPECIFIC
> select HAVE_UID16
> select MMU_GATHER_NO_RANGE if MMU
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] m68k: Enable dead code elimination
2025-04-27 23:37 ` Greg Ungerer
@ 2025-04-29 0:04 ` Daniel Palmer
2025-04-29 2:18 ` Greg Ungerer
0 siblings, 1 reply; 11+ messages in thread
From: Daniel Palmer @ 2025-04-29 0:04 UTC (permalink / raw)
To: Greg Ungerer; +Cc: geert, linux-m68k, linux-kernel
Hi Greg,
On Mon, 28 Apr 2025 at 08:37, Greg Ungerer <gerg@linux-m68k.org> wrote:
> I notice that some other architectures (arm and powerpc) have version
> checks on gcc or ld in the config. Do you know if there is any version
> limitations for m68k here?
I'm not sure about that. I'll try to work out why they have the checks
and see if that affects m68k too.
I'm using GCC13 so probably new enough that most things work.
Cheers,
Daniel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] m68k: Enable dead code elimination
2025-04-29 0:04 ` Daniel Palmer
@ 2025-04-29 2:18 ` Greg Ungerer
2025-06-08 8:32 ` Finn Thain
0 siblings, 1 reply; 11+ messages in thread
From: Greg Ungerer @ 2025-04-29 2:18 UTC (permalink / raw)
To: Daniel Palmer; +Cc: geert, linux-m68k, linux-kernel
Hi Daniel,
On 29/4/25 10:04, Daniel Palmer wrote:
> Hi Greg,
>
> On Mon, 28 Apr 2025 at 08:37, Greg Ungerer <gerg@linux-m68k.org> wrote:
>> I notice that some other architectures (arm and powerpc) have version
>> checks on gcc or ld in the config. Do you know if there is any version
>> limitations for m68k here?
>
> I'm not sure about that. I'll try to work out why they have the checks
> and see if that affects m68k too.
> I'm using GCC13 so probably new enough that most things work.
FWIW, the oldest toolchain I had lying around was based on gcc 8.3.0
and binutils 2.32. This patch worked fine on that.
Regards
Greg
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] m68k: Enable dead code elimination
2025-04-29 2:18 ` Greg Ungerer
@ 2025-06-08 8:32 ` Finn Thain
2025-06-08 9:22 ` Finn Thain
2025-06-08 9:36 ` Geert Uytterhoeven
0 siblings, 2 replies; 11+ messages in thread
From: Finn Thain @ 2025-06-08 8:32 UTC (permalink / raw)
To: Greg Ungerer; +Cc: Daniel Palmer, geert, linux-m68k, linux-kernel
On Tue, 29 Apr 2025, Greg Ungerer wrote:
> On 29/4/25 10:04, Daniel Palmer wrote:
> >
> > On Mon, 28 Apr 2025 at 08:37, Greg Ungerer <gerg@linux-m68k.org> wrote:
> >> I notice that some other architectures (arm and powerpc) have version
> >> checks on gcc or ld in the config. Do you know if there is any
> >> version limitations for m68k here?
> >
> > I'm not sure about that. I'll try to work out why they have the checks
> > and see if that affects m68k too. I'm using GCC13 so probably new
> > enough that most things work.
>
> FWIW, the oldest toolchain I had lying around was based on gcc 8.3.0 and
> binutils 2.32. This patch worked fine on that.
>
I was going to try the patch with gcc-6.4.0 but apparently that's too old
to build stock linux-6.15 (see below). Documentation/admin-guide/README.rst
says I should have "at least gcc 5.1".
Anyway, I think this patch should not cause any unpleasant surprises,
given that "make oldconfig" says dead code elimination is EXPERIMENTAL.
CC mm/vmscan.o
In file included from <command-line>:0:0:
mm/vmscan.c: In function 'read_ctrl_pos':
././include/linux/compiler_types.h:557:38: error: call to '__compiletime_assert_469' declared with attribute error: min(tier, 4U - 1) signedness error
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
././include/linux/compiler_types.h:538:4: note: in definition of macro '__compiletime_assert'
prefix ## suffix(); \
^~~~~~
././include/linux/compiler_types.h:557:2: note: in expansion of macro '_compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~~~~~~~~~~~~~~~
./include/linux/minmax.h:93:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
BUILD_BUG_ON_MSG(!__types_ok(ux, uy), \
^~~~~~~~~~~~~~~~
./include/linux/minmax.h:98:2: note: in expansion of macro '__careful_cmp_once'
__careful_cmp_once(op, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_))
^~~~~~~~~~~~~~~~~~
./include/linux/minmax.h:105:19: note: in expansion of macro '__careful_cmp'
#define min(x, y) __careful_cmp(min, x, y)
^~~~~~~~~~~~~
mm/vmscan.c:3166:37: note: in expansion of macro 'min'
for (i = tier % MAX_NR_TIERS; i <= min(tier, MAX_NR_TIERS - 1); i++) {
^~~
make[4]: *** [scripts/Makefile.build:203: mm/vmscan.o] Error 1
make[3]: *** [scripts/Makefile.build:461: mm] Error 2
make[2]: *** [Makefile:2003: .] Error 2
make[1]: *** [/home/fthain/src/kernel.org/linux/Makefile:369: __build_one_by_one] Error 2
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] m68k: Enable dead code elimination
2025-06-08 8:32 ` Finn Thain
@ 2025-06-08 9:22 ` Finn Thain
2025-06-08 9:36 ` Geert Uytterhoeven
1 sibling, 0 replies; 11+ messages in thread
From: Finn Thain @ 2025-06-08 9:22 UTC (permalink / raw)
To: Greg Ungerer; +Cc: Daniel Palmer, geert, linux-m68k, linux-kernel
On Sun, 8 Jun 2025, Finn Thain wrote:
>
> Anyway, I think this patch should not cause any unpleasant surprises,
> given that "make oldconfig" says dead code elimination is EXPERIMENTAL.
>
(their emphasis).
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] m68k: Enable dead code elimination
2025-06-08 8:32 ` Finn Thain
2025-06-08 9:22 ` Finn Thain
@ 2025-06-08 9:36 ` Geert Uytterhoeven
2025-06-11 22:41 ` Daniel Palmer
1 sibling, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2025-06-08 9:36 UTC (permalink / raw)
To: Finn Thain; +Cc: Greg Ungerer, Daniel Palmer, linux-m68k, linux-kernel
Hi Finn,
On Sun, 8 Jun 2025 at 10:32, Finn Thain <fthain@linux-m68k.org> wrote:
> On Tue, 29 Apr 2025, Greg Ungerer wrote:
> > On 29/4/25 10:04, Daniel Palmer wrote:
> > > On Mon, 28 Apr 2025 at 08:37, Greg Ungerer <gerg@linux-m68k.org> wrote:
> > >> I notice that some other architectures (arm and powerpc) have version
> > >> checks on gcc or ld in the config. Do you know if there is any
> > >> version limitations for m68k here?
> > >
> > > I'm not sure about that. I'll try to work out why they have the checks
> > > and see if that affects m68k too. I'm using GCC13 so probably new
> > > enough that most things work.
> >
> > FWIW, the oldest toolchain I had lying around was based on gcc 8.3.0 and
> > binutils 2.32. This patch worked fine on that.
> >
>
> I was going to try the patch with gcc-6.4.0 but apparently that's too old
> to build stock linux-6.15 (see below). Documentation/admin-guide/README.rst
> says I should have "at least gcc 5.1".
Someone forgot to update that file...
Anyway, it has just been increased again for v6.16-rc1 by Arnd in
commit 118c40b7b50340bf ("kbuild: require gcc-8 and binutils-2.30").
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] m68k: Enable dead code elimination
2025-06-08 9:36 ` Geert Uytterhoeven
@ 2025-06-11 22:41 ` Daniel Palmer
0 siblings, 0 replies; 11+ messages in thread
From: Daniel Palmer @ 2025-06-11 22:41 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Finn Thain, Greg Ungerer, linux-m68k, linux-kernel
Hi Geert and Finn,
On Sun, 8 Jun 2025 at 18:36, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
>
> Hi Finn,
>
> On Sun, 8 Jun 2025 at 10:32, Finn Thain <fthain@linux-m68k.org> wrote:
> > On Tue, 29 Apr 2025, Greg Ungerer wrote:
> > > On 29/4/25 10:04, Daniel Palmer wrote:
> > > > On Mon, 28 Apr 2025 at 08:37, Greg Ungerer <gerg@linux-m68k.org> wrote:
> > > >> I notice that some other architectures (arm and powerpc) have version
> > > >> checks on gcc or ld in the config. Do you know if there is any
> > > >> version limitations for m68k here?
> > > >
> > > > I'm not sure about that. I'll try to work out why they have the checks
> > > > and see if that affects m68k too. I'm using GCC13 so probably new
> > > > enough that most things work.
> > >
> > > FWIW, the oldest toolchain I had lying around was based on gcc 8.3.0 and
> > > binutils 2.32. This patch worked fine on that.
> > >
> >
> > I was going to try the patch with gcc-6.4.0 but apparently that's too old
> > to build stock linux-6.15 (see below). Documentation/admin-guide/README.rst
> > says I should have "at least gcc 5.1".
>
> Someone forgot to update that file...
> Anyway, it has just been increased again for v6.16-rc1 by Arnd in
> commit 118c40b7b50340bf ("kbuild: require gcc-8 and binutils-2.30").
I sort of lost track of this[0].. anyhow I looked at the other archs
that have HAVE_LD_DEAD_CODE_DATA_ELIMINATION they all have different
constraints.
I think we should add them if/when someone finds a toolchain that
fails to build. I don't want to add some constraint for an issue that
only happens on arm by mistake.
Cheers,
Daniel
0 - trying to get the Amiga m68k bootloader to build without a hacked
up amigaos gcc :)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] m68k: Enable dead code elimination
2025-04-16 11:42 [PATCH] m68k: Enable dead code elimination Daniel Palmer
2025-04-27 23:37 ` Greg Ungerer
@ 2025-06-16 4:48 ` Finn Thain
2025-07-06 9:14 ` Geert Uytterhoeven
2 siblings, 0 replies; 11+ messages in thread
From: Finn Thain @ 2025-06-16 4:48 UTC (permalink / raw)
To: Daniel Palmer; +Cc: geert, linux-m68k, linux-kernel
On Wed, 16 Apr 2025, Daniel Palmer wrote:
> Allow the experimental dead code elimination config to be enabled.
>
> For my 68000 nommu config this frees up a few hundred K of memory
> so seems worth while.
>
> Boot and build tested on nommu and mmu enabled configs.
>
> Before:
> Memory: 5388K/8192K available (1986K kernel code, 114K rwdata,
> 244K rodata, 92K init, 41K bss, 2624K reserved, 0K cma-reserved)
>
> After
> Memory: 5684K/8192K available (1714K kernel code, 112K rwdata,
> 228K rodata, 92K init, 37K bss, 2328K reserved, 0K cma-reserved)
>
> Signed-off-by: Daniel Palmer <daniel@0x0f.com>
With gcc-13.3, enabling DCE here recovered 0.5 MB of memory. Very nice! I
saw no regressions in basic functionality. I tested on Aranym, Qemu and
Quadra 605, including module load & unload.
Tested-by: Finn Thain <fthain@linux-m68k.org>
> ---
> arch/m68k/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
> index eb5bb6d36899..11835eb59d94 100644
> --- a/arch/m68k/Kconfig
> +++ b/arch/m68k/Kconfig
> @@ -32,6 +32,7 @@ config M68K
> select HAVE_ASM_MODVERSIONS
> select HAVE_DEBUG_BUGVERBOSE
> select HAVE_EFFICIENT_UNALIGNED_ACCESS if !CPU_HAS_NO_UNALIGNED
> + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION
> select HAVE_MOD_ARCH_SPECIFIC
> select HAVE_UID16
> select MMU_GATHER_NO_RANGE if MMU
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] m68k: Enable dead code elimination
2025-04-16 11:42 [PATCH] m68k: Enable dead code elimination Daniel Palmer
2025-04-27 23:37 ` Greg Ungerer
2025-06-16 4:48 ` Finn Thain
@ 2025-07-06 9:14 ` Geert Uytterhoeven
2025-07-06 10:43 ` Geert Uytterhoeven
2 siblings, 1 reply; 11+ messages in thread
From: Geert Uytterhoeven @ 2025-07-06 9:14 UTC (permalink / raw)
To: Daniel Palmer; +Cc: linux-m68k, linux-kernel
Hi Daniel,
On Wed, 16 Apr 2025 at 13:42, Daniel Palmer <daniel@0x0f.com> wrote:
> Allow the experimental dead code elimination config to be enabled.
>
> For my 68000 nommu config this frees up a few hundred K of memory
> so seems worth while.
>
> Boot and build tested on nommu and mmu enabled configs.
>
> Before:
> Memory: 5388K/8192K available (1986K kernel code, 114K rwdata,
> 244K rodata, 92K init, 41K bss, 2624K reserved, 0K cma-reserved)
>
> After
> Memory: 5684K/8192K available (1714K kernel code, 112K rwdata,
> 228K rodata, 92K init, 37K bss, 2328K reserved, 0K cma-reserved)
>
> Signed-off-by: Daniel Palmer <daniel@0x0f.com>
Thanks for your patch!
Note that enabling this requires enabling CONFIG_EXPERT first, which is
currently enabled in the Coldfire defconfigs, but not in the Classic
defconfigs. For atari_defconfig, I see a size reduction of ca. 150 KiB
(gcc 13.3.0).
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
i.e. will queue in the m68k tree for v6.17.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] m68k: Enable dead code elimination
2025-07-06 9:14 ` Geert Uytterhoeven
@ 2025-07-06 10:43 ` Geert Uytterhoeven
0 siblings, 0 replies; 11+ messages in thread
From: Geert Uytterhoeven @ 2025-07-06 10:43 UTC (permalink / raw)
To: Daniel Palmer; +Cc: linux-m68k, linux-kernel
On Sun, 6 Jul 2025 at 11:14, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> On Wed, 16 Apr 2025 at 13:42, Daniel Palmer <daniel@0x0f.com> wrote:
> > Allow the experimental dead code elimination config to be enabled.
> >
> > For my 68000 nommu config this frees up a few hundred K of memory
> > so seems worth while.
> >
> > Boot and build tested on nommu and mmu enabled configs.
> >
> > Before:
> > Memory: 5388K/8192K available (1986K kernel code, 114K rwdata,
> > 244K rodata, 92K init, 41K bss, 2624K reserved, 0K cma-reserved)
> >
> > After
> > Memory: 5684K/8192K available (1714K kernel code, 112K rwdata,
> > 228K rodata, 92K init, 37K bss, 2328K reserved, 0K cma-reserved)
> >
> > Signed-off-by: Daniel Palmer <daniel@0x0f.com>
>
> Thanks for your patch!
>
> Note that enabling this requires enabling CONFIG_EXPERT first, which is
> currently enabled in the Coldfire defconfigs, but not in the Classic
> defconfigs. For atari_defconfig, I see a size reduction of ca. 150 KiB
> (gcc 13.3.0).
Let's share the actual figures I had saved before:
$ bloat-o-meter vmlinux-v6.16-rc2+EXPERT{,+LD_DEAD_CODE_DATA_ELIMINATION}
add/remove: 0/2125 grow/shrink: 10275/32 up/down: 52254/-205419 (-153165)
[...]
Total: Before=5277826, After=5124661, chg -2.90%
dmesg:
-Memory: 265412K/276480K available (4345K kernel code, 486K
rwdata, 1240K rodata, 164K init, 143K bss, 10440K reserved, 0K
cma-reserved)
+Memory: 265616K/276480K available (4205K kernel code, 484K
rwdata, 1180K rodata, 160K init, 143K bss, 10236K reserved, 0K
cma-reserved)
gcc version 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-07-06 10:44 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-16 11:42 [PATCH] m68k: Enable dead code elimination Daniel Palmer
2025-04-27 23:37 ` Greg Ungerer
2025-04-29 0:04 ` Daniel Palmer
2025-04-29 2:18 ` Greg Ungerer
2025-06-08 8:32 ` Finn Thain
2025-06-08 9:22 ` Finn Thain
2025-06-08 9:36 ` Geert Uytterhoeven
2025-06-11 22:41 ` Daniel Palmer
2025-06-16 4:48 ` Finn Thain
2025-07-06 9:14 ` Geert Uytterhoeven
2025-07-06 10:43 ` Geert Uytterhoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).