From: sashiko-bot@kernel.org
To: "Yaxiong Tian" <tianyaxiong@kylinos.cn>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v2] ftrace: speed up module enable by binary searching module symbols
Date: Thu, 05 Nov 2026 03:24:47 +0000 [thread overview]
Message-ID: <sashiko-outbox-198512@kernel.org> (raw)
In-Reply-To: <20261105031530.280442-1-tianyaxiong@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] ftrace: undeclared function is_ignored_kernel_symbol() breaks build
--
commit 4bde25e1c49a34cddab8dbd106c29413a3f1f699
Author: Yaxiong Tian <tianyaxiong@kylinos.cn>
ftrace: speed up module enable by binary searching module symbols
This commit speeds up ftrace_module_enable() by collecting and sorting a
module's symbol addresses once and binary searching them to validate
ftrace records instead of linearly scanning the module symbol table for
each record.
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index c7d74b33d36de..255e813fe70e1 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -26,6 +26,7 @@
> #include <linux/uaccess.h>
> #include <linux/bsearch.h>
> #include <linux/module.h>
> +#include <linux/module_symbol.h>
> #include <linux/ftrace.h>
> #include <linux/sysctl.h>
> #include <linux/slab.h>
> @@ -8034,8 +8035,129 @@ void ftrace_release_mod(struct module *mod)
> }
> }
>
> +#ifdef FTRACE_MCOUNT_MAX_OFFSET
[ ... ]
> +static struct ftrace_mod_syms *ftrace_mod_syms_alloc(struct module *mod)
> +{
> + struct mod_kallsyms *kallsyms;
> + struct ftrace_mod_syms *syms;
> + unsigned int i, nr = 0;
> +
> + /*
> + * mod->kallsyms stays valid until do_init_module() replaces it later
> + * in this thread, so no RCU read-side section is needed.
> + */
> + kallsyms = rcu_dereference_raw(mod->kallsyms);
> +
> + if (!kallsyms || kallsyms->num_symtab < 2)
> + return NULL;
> +
> + syms = kvmalloc(struct_size(syms, addr, kallsyms->num_symtab),
> + GFP_KERNEL);
> + if (!syms)
> + return NULL;
> +
> + /* The symbols find_kallsyms_symbol() would consider. */
> + for (i = 1; i < kallsyms->num_symtab; i++) {
> + const Elf_Sym *sym = &kallsyms->symtab[i];
> + const char *name = kallsyms->strtab + sym->st_name;
> +
> + if (sym->st_shndx == SHN_UNDEF || !*name ||
> + is_ignored_kernel_symbol(name))
> + continue;
[Severity: Low]
Does this break the build on architectures defining FTRACE_MCOUNT_MAX_OFFSET
(such as x86 with CONFIG_HAVE_FENTRY or powerpc)?
ftrace_mod_syms_alloc() calls is_ignored_kernel_symbol(), which is not
declared or defined in any kernel header in this tree. In
include/linux/module_symbol.h, the helper is still named is_mapping_symbol():
include/linux/module_symbol.h:
static inline bool is_mapping_symbol(const char *str)
{
if (str[0] == '.' && str[1] == 'L')
return true;
if (str[0] == 'L' && str[1] == '0')
return true;
return str[0] == '$';
}
and find_kallsyms_symbol() in kernel/module/kallsyms.c calls
is_mapping_symbol():
kernel/module/kallsyms.c:find_kallsyms_symbol() {
...
if (*kallsyms_symbol_name(kallsyms, i) == '\0' ||
is_mapping_symbol(kallsyms_symbol_name(kallsyms, i)))
continue;
...
}
Should ftrace_mod_syms_alloc() call is_mapping_symbol(name) here instead?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105031530.280442-1-tianyaxiong@kylinos.cn?part=1
next prev parent reply other threads:[~2026-11-05 3:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 3:15 [PATCH v2] ftrace: speed up module enable by binary searching module symbols Yaxiong Tian
2026-11-05 3:24 ` sashiko-bot [this message]
2026-11-05 5:44 ` Yaxiong Tian
2026-11-05 14:32 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-198512@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tianyaxiong@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.