Skip to contentSkip to conversation

linux/export.h: remove unneeded .balign directive

PATCH In review Masahiro Yamada 3 participants 7 messages Jan 3, 2024 – Jan 13, 2024 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---

 include/linux/export.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
include/linux/export.h +3 -7
index 0bbd02fd351d..dff230bb5aca 100644
@@ -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)
Signature · 1 line
2.40.1
#1 lore raw

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-

Quoted 43 lines · Masahiro Yamada

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

---

 include/linux/export.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
include/linux/export.h +3 -8
index 0bbd02fd351d..dff230bb5aca 100644
@@ -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

#2 lore raw
Quoted 7 lines · Sedat Dilek

Happy new 2024 Masahiro,

some small nits.

What about adding links to the commits...

Quoted 8 lines

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.

Quoted 2 lines

...and CC Helge Deller?

You did it.

Thanks.

Quoted 50 lines

Best regards,
-Sedat-

Quoted 43 lines · Masahiro Yamada

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

---

 include/linux/export.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
include/linux/export.h +3 -8
index 0bbd02fd351d..dff230bb5aca 100644
@@ -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

Signature · 2 lines
Best Regards
Masahiro Yamada
#3 lore raw
Quoted 19 lines · Masahiro Yamada
Quoted 7 lines · Sedat Dilek

Happy new 2024 Masahiro,

some small nits.

What about adding links to the commits...

Quoted 8 lines

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?

Quoted 6 lines

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?

Quoted 6 lines
Quoted 5 lines

...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-

Quoted 65 lines

You did it.

Thanks.

Quoted 44 lines

Best regards,
-Sedat-

Quoted 38 lines · Masahiro Yamada

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

---

 include/linux/export.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
include/linux/export.h +3 -7
index 0bbd02fd351d..dff230bb5aca 100644
@@ -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
 
Quoted 6 lines
Quoted 5 lines
include/linux/export.h +0 -1
 #if defined(__DISABLE_EXPORTS)
--

2.40.1

--
Best Regards
Masahiro Yamada

#4 lore raw
Quoted 25 lines · Sedat Dilek
Quoted 23 lines · Masahiro Yamada
Quoted 7 lines · Sedat Dilek

Happy new 2024 Masahiro,

some small nits.

What about adding links to the commits...

Quoted 8 lines

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.

Quoted 8 lines
Quoted 2 lines

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*)
Quoted 79 lines
Quoted 6 lines
Quoted 5 lines

...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-

Quoted 65 lines

You did it.

Thanks.

Quoted 44 lines

Best regards,
-Sedat-

Quoted 38 lines · Masahiro Yamada

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

---

 include/linux/export.h | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
include/linux/export.h +3 -7
index 0bbd02fd351d..dff230bb5aca 100644
@@ -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
 
Quoted 6 lines
Quoted 5 lines
include/linux/export.h +0 -1
 #if defined(__DISABLE_EXPORTS)
--

2.40.1

--
Best Regards
Masahiro Yamada

Signature · 2 lines
Best Regards
Masahiro Yamada
#5 lore raw
In reply to Masahiro Yamada
Quoted 4 lines · Masahiro Yamada

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

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
#6 lore raw
Quoted 8 lines · Guenter Roeck
Quoted 4 lines · Masahiro Yamada

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

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

Thanks.
I dropped it.

Quoted 48 lines

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
Signature · 2 lines
Best Regards
Masahiro Yamada