Re: [RFC PATCH 6/8] preempt/dynamic: Provide preempt_schedule[_notrace]() static calls

From: Peter Zijlstra
Date: Wed Jan 27 2021 - 04:17:54 EST


On Tue, Jan 26, 2021 at 05:57:30PM -0600, Josh Poimboeuf wrote:
> 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!

Oh right, let me see if I can make that work.

> Also I do have some naming suggestions ;-)

Nah, we need a little more fun back in the code :-)