modules: Ensure 64-bit alignment on __ksymtab_* sections

On 64-bit architectures without CONFIG_HAVE_ARCH_PREL32_RELOCATIONS
(e.g. ppc64, ppc64le, parisc, s390x,...) the __KSYM_REF() macro stores
64-bit pointers into the __ksymtab* sections.
Make sure that those sections will be correctly aligned at module link time,
otherwise unaligned memory accesses may happen at runtime.

The __kcrctab* sections store 32-bit entities, so use ALIGN(4) for those.

Testing with the kallsyms selftest on x86_64 we see a savings of about
1,958,153 ns in the worst case which may or not be within noise. Testing
on parisc would be useful and welcomed.

On x86_64 before:

 Performance counter stats for '/sbin/modprobe test_kallsyms_b':

        86,430,119 ns   duration_time
        84,407,000 ns   system_time
               213      page-faults

       0.086430119 seconds time elapsed

       0.000000000 seconds user
       0.084407000 seconds sys

 Performance counter stats for '/sbin/modprobe test_kallsyms_b':

        85,777,474 ns   duration_time
        82,581,000 ns   system_time
               212      page-faults

       0.085777474 seconds time elapsed

       0.000000000 seconds user
       0.082581000 seconds sys

 Performance counter stats for '/sbin/modprobe test_kallsyms_b':

        87,906,053 ns   duration_time
        87,939,000 ns   system_time
               212      page-faults

       0.087906053 seconds time elapsed

       0.000000000 seconds user
       0.087939000 seconds sys

After:

 Performance counter stats for '/sbin/modprobe test_kallsyms_b':

        82,925,631 ns   duration_time
        83,000,000 ns   system_time
               212      page-faults

       0.082925631 seconds time elapsed

       0.000000000 seconds user
       0.083000000 seconds sys

 Performance counter stats for '/sbin/modprobe test_kallsyms_b':

        87,776,380 ns   duration_time
        86,678,000 ns   system_time
               213      page-faults

       0.087776380 seconds time elapsed

       0.000000000 seconds user
       0.086678000 seconds sys

 Performance counter stats for '/sbin/modprobe test_kallsyms_b':

        85,947,900 ns   duration_time
        82,006,000 ns   system_time
               212      page-faults

       0.085947900 seconds time elapsed

       0.000000000 seconds user
       0.082006000 seconds sys

Signed-off-by: Helge Deller <deller@gmx.de>
[mcgrof: ran kallsyms selftests on x86_64]
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
1 file changed