Hi, Tiezhu,

On Thu, Aug 20, 2026 at 8:50 PM Tiezhu Yang <[email protected]> wrote:
>
> The helper function is_mapping_symbol() historically checks for both
> local labels prefixed with ".L" or "L0" and mapping symbols prefixed
> with "$".
>
> Rename it to is_ignored_kernel_symbol() to better reflect this actual
> behavior and scope, preventing conceptual confusion.
I think is_ignored_symbol() is enough, no "kernel" needed.

Huacai

>
> While at it, update the related non-module files, no functional changes.
>
> Suggested-by: Petr Pavlu <[email protected]>
> Signed-off-by: Tiezhu Yang <[email protected]>
> Reviewed-by: Huacai Chen <[email protected]>
> ---
>  include/linux/module_symbol.h | 7 +++++--
>  kernel/module/kallsyms.c      | 2 +-
>  scripts/faddr2line            | 2 +-
>  scripts/mod/modpost.h         | 2 +-
>  tools/perf/util/symbol.h      | 4 +---
>  5 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/include/linux/module_symbol.h b/include/linux/module_symbol.h
> index 574609aced99..698d3db2b37e 100644
> --- a/include/linux/module_symbol.h
> +++ b/include/linux/module_symbol.h
> @@ -7,8 +7,11 @@ enum ksym_flags {
>         KSYM_FLAG_GPL_ONLY      = 1 << 0,
>  };
>
> -/* This ignores the intensely annoying "mapping symbols" found in ELF files. 
> */
> -static inline bool is_mapping_symbol(const char *str)
> +/*
> + * Ignore local labels (.L*, L0*) and mapping symbols ($*). These symbols are
> + * not useful for the kernel, for example, they should not appear in 
> kallsyms.
> + */
> +static inline bool is_ignored_kernel_symbol(const char *str)
>  {
>         if (str[0] == '.' && str[1] == 'L')
>                 return true;
> diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c
> index f23126d804b2..a52942fd0e07 100644
> --- a/kernel/module/kallsyms.c
> +++ b/kernel/module/kallsyms.c
> @@ -294,7 +294,7 @@ static const char *find_kallsyms_symbol(struct module 
> *mod,
>                  * and inserted at a whim.
>                  */
>                 if (*kallsyms_symbol_name(kallsyms, i) == '\0' ||
> -                   is_mapping_symbol(kallsyms_symbol_name(kallsyms, i)))
> +                   is_ignored_kernel_symbol(kallsyms_symbol_name(kallsyms, 
> i)))
>                         continue;
>
>                 if (thisval <= addr && thisval > bestval) {
> diff --git a/scripts/faddr2line b/scripts/faddr2line
> index 622875396bcf..3aca197d513f 100755
> --- a/scripts/faddr2line
> +++ b/scripts/faddr2line
> @@ -243,7 +243,7 @@ __faddr2line() {
>                         local cur_sym_elf_size=${fields[2]}
>                         local cur_sym_name=${fields[7]:-}
>
> -                       # is_mapping_symbol(cur_sym_name)
> +                       # is_ignored_kernel_symbol(cur_sym_name)
>                         if [[ ${cur_sym_name} =~ ^(\.L|L0|\$) ]]; then
>                                 continue
>                         fi
> diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
> index 2aecb8f25c87..d9c21d479dd8 100644
> --- a/scripts/mod/modpost.h
> +++ b/scripts/mod/modpost.h
> @@ -198,7 +198,7 @@ static inline bool is_valid_name(struct elf_info *elf, 
> Elf_Sym *sym)
>
>         if (!name || !strlen(name))
>                 return false;
> -       return !is_mapping_symbol(name);
> +       return !is_ignored_kernel_symbol(name);
>  }
>
>  /* symsearch.c */
> diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
> index a71525335703..8b0780046938 100644
> --- a/tools/perf/util/symbol.h
> +++ b/tools/perf/util/symbol.h
> @@ -31,9 +31,7 @@ struct build_id;
>  struct perf_env;
>
>  /*
> - * Ignore kernel mapping symbols, matching kernel is_mapping_symbol() logic.
> - * This checks for '$' prefix (used by ARM, AArch64, RISC-V) and
> - * x86 local symbol prefixes (.L* and L0*).
> + * Ignore local labels and mapping symbols, matching kernel 
> is_ignored_kernel_symbol() logic.
>   * Only use this for kernel symbols (kallsyms, ksymbol events, kernel ELF 
> DSOs).
>   */
>  static inline bool is_ignored_kernel_symbol(const char *str)
> --
> 2.42.0
>
>

Reply via email to