The module loader currently runs expensive address pairing logic for all sections blindly during relocation. For massive modules like amdgpu, this causes the loader to waste lots of CPU cycles analyzing non-exec sections. Furthermore, there is an inconsistency since module_frob_arch_sections() already ignores non-exec sections during the counting phase. Check the SHF_EXECINSTR flag in apply_relocate_add(). If the section is non-exec, skip address pairing and then jump to normal relocation. This eliminates redundant search loops to improve module loading efficiency. Signed-off-by: Tiezhu Yang --- arch/loongarch/kernel/module.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/loongarch/kernel/module.c b/arch/loongarch/kernel/module.c index 7d4d571ee55e..c84ac1546dc6 100644 --- a/arch/loongarch/kernel/module.c +++ b/arch/loongarch/kernel/module.c @@ -484,6 +484,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, Elf_Addr v; Elf_Sym *sym; Elf_Rela *rel = (void *) sechdrs[relsec].sh_addr; + Elf_Shdr *dst_sec = sechdrs + sechdrs[relsec].sh_info; pr_debug("%s: Applying relocate section %u to %u\n", __func__, relsec, sechdrs[relsec].sh_info); @@ -522,6 +523,10 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, v = sym->st_value + rel[i].r_addend; + /* Skip address pairing for non-exec sections */ + if (!(dst_sec->sh_flags & SHF_EXECINSTR)) + goto apply_normal; + if (type == R_LARCH_PCADD_LO12 || type == R_LARCH_GOT_PCADD_LO12) { bool found = false; unsigned int j = idx; @@ -562,6 +567,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab, idx = j; /* Record the previous j-loop end index */ } +apply_normal: switch (type) { case R_LARCH_B26: err = apply_r_larch_b26(mod, sechdrs, location, -- 2.42.0