2024-01-03 13:55:27

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH] linux/export.h: remove unneeded .balign directive

The .export_symbol section is discarded by the linker script, hence
no alignment is needed. Simplify the code.

Signed-off-by: Masahiro Yamada <[email protected]>
---

include/linux/export.h | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/include/linux/export.h b/include/linux/export.h
index 0bbd02fd351d..dff230bb5aca 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -15,13 +15,9 @@
*/

#ifdef CONFIG_64BIT
-#define __EXPORT_SYMBOL_REF(sym) \
- .balign 8 ASM_NL \
- .quad sym
+#define __EXPORT_SYMBOL_PTR .quad
#else
-#define __EXPORT_SYMBOL_REF(sym) \
- .balign 4 ASM_NL \
- .long sym
+#define __EXPORT_SYMBOL_PTR .long
#endif

#define ___EXPORT_SYMBOL(sym, license, ns) \
@@ -29,7 +25,7 @@
__export_symbol_##sym: ASM_NL \
.asciz license ASM_NL \
.asciz ns ASM_NL \
- __EXPORT_SYMBOL_REF(sym) ASM_NL \
+ __EXPORT_SYMBOL_PTR sym ASM_NL \
.previous

#if defined(__DISABLE_EXPORTS)
--
2.40.1



2024-01-03 16:05:22

by Sedat Dilek

[permalink] [raw]
Subject: Re: [PATCH] linux/export.h: remove unneeded .balign directive

Happy new 2024 Masahiro,

some small nits.

What about adding links to the commits...

linux/export: Fix alignment for 64-bit ksymtab entries
[ Upstream commit f6847807c22f6944c71c981b630b9fff30801e73 ]

linux/export: Ensure natural alignment of kcrctab array
[ Upstream commit 753547de0daecbdbd1af3618987ddade325d9aaa ]

^^ AFAICS in linux-stable - v6.6.10-rc1 includes both
^^ Is yours a follow-up and makes sense for linux-stable releases?

...and CC Helge Deller?

Best regards,
-Sedat-

Link: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/log/?h=linux-6.6.y

On Wed, Jan 3, 2024 at 2:55 PM Masahiro Yamada <[email protected]> wrote:
>
> The .export_symbol section is discarded by the linker script, hence
> no alignment is needed. Simplify the code.
>
> Signed-off-by: Masahiro Yamada <[email protected]>
> ---
>
> include/linux/export.h | 10 +++-------
> 1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/include/linux/export.h b/include/linux/export.h
> index 0bbd02fd351d..dff230bb5aca 100644
> --- a/include/linux/export.h
> +++ b/include/linux/export.h
> @@ -15,13 +15,9 @@
> */
>
> #ifdef CONFIG_64BIT
> -#define __EXPORT_SYMBOL_REF(sym) \
> - .balign 8 ASM_NL \
> - .quad sym
> +#define __EXPORT_SYMBOL_PTR .quad
> #else
> -#define __EXPORT_SYMBOL_REF(sym) \
> - .balign 4 ASM_NL \
> - .long sym
> +#define __EXPORT_SYMBOL_PTR .long
> #endif
>
> #define ___EXPORT_SYMBOL(sym, license, ns) \
> @@ -29,7 +25,7 @@
> __export_symbol_##sym: ASM_NL \
> .asciz license ASM_NL \
> .asciz ns ASM_NL \
> - __EXPORT_SYMBOL_REF(sym) ASM_NL \
> + __EXPORT_SYMBOL_PTR sym ASM_NL \
> .previous
>
> #if defined(__DISABLE_EXPORTS)
> --
> 2.40.1
>
>

2024-01-04 14:17:53

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] linux/export.h: remove unneeded .balign directive

On Thu, Jan 4, 2024 at 1:05 AM Sedat Dilek <[email protected]> wrote:
>
> Happy new 2024 Masahiro,
>
> some small nits.
>
> What about adding links to the commits...
>
> linux/export: Fix alignment for 64-bit ksymtab entries
> [ Upstream commit f6847807c22f6944c71c981b630b9fff30801e73 ]
>
> linux/export: Ensure natural alignment of kcrctab array
> [ Upstream commit 753547de0daecbdbd1af3618987ddade325d9aaa ]
>
> ^^ AFAICS in linux-stable - v6.6.10-rc1 includes both
> ^^ Is yours a follow-up and makes sense for linux-stable releases?


No.

This patch is a separate clean-up, not a bug fix.

No need for back-porting.




>
> ...and CC Helge Deller?


You did it.


Thanks.





> Best regards,
> -Sedat-
>
> Link: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/log/?h=linux-6.6.y
>
> On Wed, Jan 3, 2024 at 2:55 PM Masahiro Yamada <[email protected]> wrote:
> >
> > The .export_symbol section is discarded by the linker script, hence
> > no alignment is needed. Simplify the code.
> >
> > Signed-off-by: Masahiro Yamada <[email protected]>
> > ---
> >
> > include/linux/export.h | 10 +++-------
> > 1 file changed, 3 insertions(+), 7 deletions(-)
> >
> > diff --git a/include/linux/export.h b/include/linux/export.h
> > index 0bbd02fd351d..dff230bb5aca 100644
> > --- a/include/linux/export.h
> > +++ b/include/linux/export.h
> > @@ -15,13 +15,9 @@
> > */
> >
> > #ifdef CONFIG_64BIT
> > -#define __EXPORT_SYMBOL_REF(sym) \
> > - .balign 8 ASM_NL \
> > - .quad sym
> > +#define __EXPORT_SYMBOL_PTR .quad
> > #else
> > -#define __EXPORT_SYMBOL_REF(sym) \
> > - .balign 4 ASM_NL \
> > - .long sym
> > +#define __EXPORT_SYMBOL_PTR .long
> > #endif
> >
> > #define ___EXPORT_SYMBOL(sym, license, ns) \
> > @@ -29,7 +25,7 @@
> > __export_symbol_##sym: ASM_NL \
> > .asciz license ASM_NL \
> > .asciz ns ASM_NL \
> > - __EXPORT_SYMBOL_REF(sym) ASM_NL \
> > + __EXPORT_SYMBOL_PTR sym ASM_NL \
> > .previous
> >
> > #if defined(__DISABLE_EXPORTS)
> > --
> > 2.40.1
> >
> >
>


--
Best Regards
Masahiro Yamada

2024-01-05 08:21:46

by Sedat Dilek

[permalink] [raw]
Subject: Re: [PATCH] linux/export.h: remove unneeded .balign directive

On Thu, Jan 4, 2024 at 3:17 PM Masahiro Yamada <[email protected]> wrote:
>
> On Thu, Jan 4, 2024 at 1:05 AM Sedat Dilek <[email protected]> wrote:
> >
> > Happy new 2024 Masahiro,
> >
> > some small nits.
> >
> > What about adding links to the commits...
> >
> > linux/export: Fix alignment for 64-bit ksymtab entries
> > [ Upstream commit f6847807c22f6944c71c981b630b9fff30801e73 ]
> >
> > linux/export: Ensure natural alignment of kcrctab array
> > [ Upstream commit 753547de0daecbdbd1af3618987ddade325d9aaa ]
> >
> > ^^ AFAICS in linux-stable - v6.6.10-rc1 includes both
> > ^^ Is yours a follow-up and makes sense for linux-stable releases?
>
>
> No.
>
> This patch is a separate clean-up, not a bug fix.
>
> No need for back-porting.
>

Thanks for the clarification.

But it is an improvement - so no discarding at link-time means
reduction of build-time?
Amy numbers?

>
>
>
> >
> > ...and CC Helge Deller?
>

CC in the patch - makes for me only sense if you agree on adding above
commit-ids of Helge's work.
I think this is good in sense of follow-able references.

Best regards,
-Sedat-

>
> You did it.
>
>
> Thanks.
>
>
>
>
>
> > Best regards,
> > -Sedat-
> >
> > Link: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/log/?h=linux-6.6.y
> >
> > On Wed, Jan 3, 2024 at 2:55 PM Masahiro Yamada <[email protected]> wrote:
> > >
> > > The .export_symbol section is discarded by the linker script, hence
> > > no alignment is needed. Simplify the code.
> > >
> > > Signed-off-by: Masahiro Yamada <[email protected]>
> > > ---
> > >
> > > include/linux/export.h | 10 +++-------
> > > 1 file changed, 3 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/include/linux/export.h b/include/linux/export.h
> > > index 0bbd02fd351d..dff230bb5aca 100644
> > > --- a/include/linux/export.h
> > > +++ b/include/linux/export.h
> > > @@ -15,13 +15,9 @@
> > > */
> > >
> > > #ifdef CONFIG_64BIT
> > > -#define __EXPORT_SYMBOL_REF(sym) \
> > > - .balign 8 ASM_NL \
> > > - .quad sym
> > > +#define __EXPORT_SYMBOL_PTR .quad
> > > #else
> > > -#define __EXPORT_SYMBOL_REF(sym) \
> > > - .balign 4 ASM_NL \
> > > - .long sym
> > > +#define __EXPORT_SYMBOL_PTR .long
> > > #endif
> > >
> > > #define ___EXPORT_SYMBOL(sym, license, ns) \
> > > @@ -29,7 +25,7 @@
> > > __export_symbol_##sym: ASM_NL \
> > > .asciz license ASM_NL \
> > > .asciz ns ASM_NL \
> > > - __EXPORT_SYMBOL_REF(sym) ASM_NL \
> > > + __EXPORT_SYMBOL_PTR sym ASM_NL \
> > > .previous
> > >
> > > #if defined(__DISABLE_EXPORTS)
> > > --
> > > 2.40.1
> > >
> > >
> >
>
>
> --
> Best Regards
> Masahiro Yamada

2024-01-07 11:35:00

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] linux/export.h: remove unneeded .balign directive

On Fri, Jan 5, 2024 at 5:21 PM Sedat Dilek <[email protected]> wrote:
>
> On Thu, Jan 4, 2024 at 3:17 PM Masahiro Yamada <[email protected]> wrote:
> >
> > On Thu, Jan 4, 2024 at 1:05 AM Sedat Dilek <[email protected]> wrote:
> > >
> > > Happy new 2024 Masahiro,
> > >
> > > some small nits.
> > >
> > > What about adding links to the commits...
> > >
> > > linux/export: Fix alignment for 64-bit ksymtab entries
> > > [ Upstream commit f6847807c22f6944c71c981b630b9fff30801e73 ]
> > >
> > > linux/export: Ensure natural alignment of kcrctab array
> > > [ Upstream commit 753547de0daecbdbd1af3618987ddade325d9aaa ]
> > >
> > > ^^ AFAICS in linux-stable - v6.6.10-rc1 includes both
> > > ^^ Is yours a follow-up and makes sense for linux-stable releases?
> >
> >
> > No.
> >
> > This patch is a separate clean-up, not a bug fix.
> >
> > No need for back-porting.
> >
>
> Thanks for the clarification.
>
> But it is an improvement - so no discarding at link-time means
> reduction of build-time?
> Amy numbers?


The .export_symbol is already discarded.

The alignment of discarded code is "don't care".
So, this is a code clean-up.

I do not think there is a noticeable difference
in the build speed.




See line 1005 of include/asm-generic/vmlinux.h.lds


#define COMMON_DISCARDS \
SANITIZER_DISCARDS \
PATCHABLE_DISCARDS \
*(.discard) \
*(.discard.*) \
*(.export_symbol) \
*(.modinfo) \
/* ld.bfd warns about .gnu.version* even when not emitted */ \
*(.gnu.version*)










> >
> >
> >
> > >
> > > ...and CC Helge Deller?
> >
>
> CC in the patch - makes for me only sense if you agree on adding above
> commit-ids of Helge's work.
> I think this is good in sense of follow-able references.
>
> Best regards,
> -Sedat-
>
> >
> > You did it.
> >
> >
> > Thanks.
> >
> >
> >
> >
> >
> > > Best regards,
> > > -Sedat-
> > >
> > > Link: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git/log/?h=linux-6.6.y
> > >
> > > On Wed, Jan 3, 2024 at 2:55 PM Masahiro Yamada <[email protected]> wrote:
> > > >
> > > > The .export_symbol section is discarded by the linker script, hence
> > > > no alignment is needed. Simplify the code.
> > > >
> > > > Signed-off-by: Masahiro Yamada <[email protected]>
> > > > ---
> > > >
> > > > include/linux/export.h | 10 +++-------
> > > > 1 file changed, 3 insertions(+), 7 deletions(-)
> > > >
> > > > diff --git a/include/linux/export.h b/include/linux/export.h
> > > > index 0bbd02fd351d..dff230bb5aca 100644
> > > > --- a/include/linux/export.h
> > > > +++ b/include/linux/export.h
> > > > @@ -15,13 +15,9 @@
> > > > */
> > > >
> > > > #ifdef CONFIG_64BIT
> > > > -#define __EXPORT_SYMBOL_REF(sym) \
> > > > - .balign 8 ASM_NL \
> > > > - .quad sym
> > > > +#define __EXPORT_SYMBOL_PTR .quad
> > > > #else
> > > > -#define __EXPORT_SYMBOL_REF(sym) \
> > > > - .balign 4 ASM_NL \
> > > > - .long sym
> > > > +#define __EXPORT_SYMBOL_PTR .long
> > > > #endif
> > > >
> > > > #define ___EXPORT_SYMBOL(sym, license, ns) \
> > > > @@ -29,7 +25,7 @@
> > > > __export_symbol_##sym: ASM_NL \
> > > > .asciz license ASM_NL \
> > > > .asciz ns ASM_NL \
> > > > - __EXPORT_SYMBOL_REF(sym) ASM_NL \
> > > > + __EXPORT_SYMBOL_PTR sym ASM_NL \
> > > > .previous
> > > >
> > > > #if defined(__DISABLE_EXPORTS)
> > > > --
> > > > 2.40.1
> > > >
> > > >
> > >
> >
> >
> > --
> > Best Regards
> > Masahiro Yamada



--
Best Regards
Masahiro Yamada

2024-01-10 23:13:14

by Guenter Roeck

[permalink] [raw]
Subject: Re: [PATCH] linux/export.h: remove unneeded .balign directive

On Wed, Jan 03, 2024 at 10:54:54PM +0900, Masahiro Yamada wrote:
> The .export_symbol section is discarded by the linker script, hence
> no alignment is needed. Simplify the code.
>
> Signed-off-by: Masahiro Yamada <[email protected]>

With this patch in linux-next, all sh4 builds fail.

Building sh:defconfig ... failed
--------------
Error log:
<stdin>:1519:2: warning: #warning syscall clone3 not implemented [-Wcpp]
{standard input}: Assembler messages:
{standard input}:6: Error: misaligned data
{standard input}:7: Error: misaligned data
{standard input}:8: Error: misaligned data
make[6]: *** [scripts/Makefile.build:243: arch/sh/boards/mach-x3proto/ilsel.o] Error 1

Reverting this patch fixes the problem.

Guenter

---
# bad: [8cb47d7cd090a690c1785385b2f3d407d4a53ad0] Add linux-next specific files for 20240110
# good: [0dd3ee31125508cd67f7e7172247f05b7fd1753a] Linux 6.7
git bisect start 'HEAD' 'v6.7'
# bad: [b14da9dd6f977c6e18a4c81e4b92692fd9b6997f] Merge branch 'main' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git
git bisect bad b14da9dd6f977c6e18a4c81e4b92692fd9b6997f
# bad: [e85ebbed67d0d74e8602d11a496183d8f65e0b2f] Merge branch 'for-next' of https://evilpiepirate.org/git/bcachefs.git
git bisect bad e85ebbed67d0d74e8602d11a496183d8f65e0b2f
# bad: [65d7e41dbca9e31017cfd36c2ce4cb8408b1f2c6] Merge branch 'perf-tools-next' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git
git bisect bad 65d7e41dbca9e31017cfd36c2ce4cb8408b1f2c6
# good: [fb46e22a9e3863e08aef8815df9f17d0f4b9aede] Merge tag 'mm-stable-2024-01-08-15-31' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
git bisect good fb46e22a9e3863e08aef8815df9f17d0f4b9aede
# good: [fd38dd6abda589a8771e7872e4dea28c99c6a6ef] kselftest/alsa - conf: Stringify the printed errno in sysfs_get()
git bisect good fd38dd6abda589a8771e7872e4dea28c99c6a6ef
# good: [8a0bd6d47301eefd80fdfeb3a00ec09011546155] Merge branch 'mtd/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git
git bisect good 8a0bd6d47301eefd80fdfeb3a00ec09011546155
# good: [16f533ade706d33e60324ff32e526bda20bccbd9] perf unwind: Use function to add missing maps lock
git bisect good 16f533ade706d33e60324ff32e526bda20bccbd9
# bad: [c6113f13957f918762d54080b2e2adbe0d7889e5] linux/export.h: remove unneeded .balign directive
git bisect bad c6113f13957f918762d54080b2e2adbe0d7889e5
# good: [d821f8a26efb6789666d70ce7a8f27df6c33c12e] sparc: vdso: use $(addprefix ) instead of $(foreach )
git bisect good d821f8a26efb6789666d70ce7a8f27df6c33c12e
# good: [9c65810cfb215f40f14d2c00694911fbc5408761] kbuild: deb-pkg: split debian/copyright from the mkdebian script
git bisect good 9c65810cfb215f40f14d2c00694911fbc5408761
# good: [5e73758b43c3defba2578df6d3a53e942fa6b41e] kbuild: deb-pkg: use more debhelper commands in builddeb
git bisect good 5e73758b43c3defba2578df6d3a53e942fa6b41e
# good: [343f74e7779c482c2fd4492cc6b45c64e18fe321] kbuild: deb-pkg: make debian/rules quiet by default
git bisect good 343f74e7779c482c2fd4492cc6b45c64e18fe321
# good: [0832e9bcfb0dc48833bbc8054cdc9b697afa8cd9] kbuild: deb-pkg: build binary-arch in parallel
git bisect good 0832e9bcfb0dc48833bbc8054cdc9b697afa8cd9
# good: [53bc4fa98f8dd5ccca9a8e038660bf0d30d9e22d] kbuild: deb-pkg: call more misc debhelper commands
git bisect good 53bc4fa98f8dd5ccca9a8e038660bf0d30d9e22d
# first bad commit: [c6113f13957f918762d54080b2e2adbe0d7889e5] linux/export.h: remove unneeded .balign directive

2024-01-13 07:13:03

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] linux/export.h: remove unneeded .balign directive

On Thu, Jan 11, 2024 at 8:11 AM Guenter Roeck <[email protected]> wrote:
>
> On Wed, Jan 03, 2024 at 10:54:54PM +0900, Masahiro Yamada wrote:
> > The .export_symbol section is discarded by the linker script, hence
> > no alignment is needed. Simplify the code.
> >
> > Signed-off-by: Masahiro Yamada <[email protected]>
>
> With this patch in linux-next, all sh4 builds fail.


Thanks.
I dropped it.







>
> Building sh:defconfig ... failed
> --------------
> Error log:
> <stdin>:1519:2: warning: #warning syscall clone3 not implemented [-Wcpp]
> {standard input}: Assembler messages:
> {standard input}:6: Error: misaligned data
> {standard input}:7: Error: misaligned data
> {standard input}:8: Error: misaligned data
> make[6]: *** [scripts/Makefile.build:243: arch/sh/boards/mach-x3proto/ilsel.o] Error 1
>
> Reverting this patch fixes the problem.
>
> Guenter
>
> ---
> # bad: [8cb47d7cd090a690c1785385b2f3d407d4a53ad0] Add linux-next specific files for 20240110
> # good: [0dd3ee31125508cd67f7e7172247f05b7fd1753a] Linux 6.7
> git bisect start 'HEAD' 'v6.7'
> # bad: [b14da9dd6f977c6e18a4c81e4b92692fd9b6997f] Merge branch 'main' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git
> git bisect bad b14da9dd6f977c6e18a4c81e4b92692fd9b6997f
> # bad: [e85ebbed67d0d74e8602d11a496183d8f65e0b2f] Merge branch 'for-next' of https://evilpiepirate.org/git/bcachefs.git
> git bisect bad e85ebbed67d0d74e8602d11a496183d8f65e0b2f
> # bad: [65d7e41dbca9e31017cfd36c2ce4cb8408b1f2c6] Merge branch 'perf-tools-next' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git
> git bisect bad 65d7e41dbca9e31017cfd36c2ce4cb8408b1f2c6
> # good: [fb46e22a9e3863e08aef8815df9f17d0f4b9aede] Merge tag 'mm-stable-2024-01-08-15-31' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
> git bisect good fb46e22a9e3863e08aef8815df9f17d0f4b9aede
> # good: [fd38dd6abda589a8771e7872e4dea28c99c6a6ef] kselftest/alsa - conf: Stringify the printed errno in sysfs_get()
> git bisect good fd38dd6abda589a8771e7872e4dea28c99c6a6ef
> # good: [8a0bd6d47301eefd80fdfeb3a00ec09011546155] Merge branch 'mtd/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git
> git bisect good 8a0bd6d47301eefd80fdfeb3a00ec09011546155
> # good: [16f533ade706d33e60324ff32e526bda20bccbd9] perf unwind: Use function to add missing maps lock
> git bisect good 16f533ade706d33e60324ff32e526bda20bccbd9
> # bad: [c6113f13957f918762d54080b2e2adbe0d7889e5] linux/export.h: remove unneeded .balign directive
> git bisect bad c6113f13957f918762d54080b2e2adbe0d7889e5
> # good: [d821f8a26efb6789666d70ce7a8f27df6c33c12e] sparc: vdso: use $(addprefix ) instead of $(foreach )
> git bisect good d821f8a26efb6789666d70ce7a8f27df6c33c12e
> # good: [9c65810cfb215f40f14d2c00694911fbc5408761] kbuild: deb-pkg: split debian/copyright from the mkdebian script
> git bisect good 9c65810cfb215f40f14d2c00694911fbc5408761
> # good: [5e73758b43c3defba2578df6d3a53e942fa6b41e] kbuild: deb-pkg: use more debhelper commands in builddeb
> git bisect good 5e73758b43c3defba2578df6d3a53e942fa6b41e
> # good: [343f74e7779c482c2fd4492cc6b45c64e18fe321] kbuild: deb-pkg: make debian/rules quiet by default
> git bisect good 343f74e7779c482c2fd4492cc6b45c64e18fe321
> # good: [0832e9bcfb0dc48833bbc8054cdc9b697afa8cd9] kbuild: deb-pkg: build binary-arch in parallel
> git bisect good 0832e9bcfb0dc48833bbc8054cdc9b697afa8cd9
> # good: [53bc4fa98f8dd5ccca9a8e038660bf0d30d9e22d] kbuild: deb-pkg: call more misc debhelper commands
> git bisect good 53bc4fa98f8dd5ccca9a8e038660bf0d30d9e22d
> # first bad commit: [c6113f13957f918762d54080b2e2adbe0d7889e5] linux/export.h: remove unneeded .balign directive



--
Best Regards
Masahiro Yamada