On Fri, Jan 22, 2021 at 05:52:26PM +0100, Peter Zijlstra wrote:
>  static int static_call_add_module(struct module *mod)
>  {
> -     return __static_call_init(mod, mod->static_call_sites,
> -                               mod->static_call_sites + 
> mod->num_static_call_sites);
> +     struct static_call_site *start = mod->static_call_sites;
> +     struct static_call_site *stop = start + mod->num_static_call_sites;
> +     struct static_call_site *site;
> +
> +     for (site = start; site != stop; site++) {
> +             unsigned long addr = (unsigned long)static_call_key(site);
> +             struct static_call_ass *ass;
> +
> +             /*
> +              * Gotta fix up the keys that point to the trampoline.
> +              */
> +             if (!kernel_text_address(addr))
> +                     continue;
> +
> +             ass = static_call_find_ass(addr);
> +             if (!ass) {
> +                     pr_warn("Failed to fixup __raw_static_call() usage at: 
> %ps\n",
> +                             static_call_addr(site));
> +                     return -EINVAL;
> +             }
> +             site->key = ((unsigned long)ass->key - (unsigned 
> long)&site->key) |
> +                         (site->key & STATIC_CALL_SITE_FLAGS);

Well, I hate it, but I'm not sure I have any better ideas.  It should be
possible to use kallsyms, instead of the rb-tree/register nonsense.  Not
sure about the performance impact though.  Might be a good reason to
speed up kallsyms!

Also I do have some naming suggestions ;-)

-- 
Josh

Reply via email to