Re: [PATCH v4 07/18] static_call: Add inline static call infrastructure

Peter Zijlstra
2020-05-06T16:15:58Z

On Tue, May 05, 2020 at 05:10:51PM -0500, Josh Poimboeuf wrote:
> On Fri, May 01, 2020 at 10:28:56PM +0200, Peter Zijlstra wrote:
> > +#ifdef CONFIG_HAVE_STATIC_CALL_INLINE
> > +
> > +struct static_call_mod {
> > + struct static_call_mod *next;
> > + struct module *mod; /* for vmlinux, mod == NULL */
> > + struct static_call_site *sites;
> > +};
> > +
> > +struct static_call_key {
> > + void *func;
> > + struct static_call_mod *next;
> > +};
>
> "next" implies it links to another key. How about "mods" or
> "site_mods"?
>
> > +++ b/include/linux/static_call_types.h
> > @@ -2,14 +2,27 @@
> > #ifndef _STATIC_CALL_TYPES_H
> > #define _STATIC_CALL_TYPES_H
> >
> > +#include <linux/types.h>
> > #include <linux/stringify.h>
> >
> > #define STATIC_CALL_PREFIX __SC__
> > +#define STATIC_CALL_PREFIX_STR __stringify(STATIC_CALL_PREFIX)
> > +#define STATIC_CALL_PREFIX_LEN (sizeof(STATIC_CALL_PREFIX_STR) - 1)
>
> STATIC_CALL_KEY_PREFIX_STR
> STATIC_CALL_KEY_PREFIX_LEN
>

> > +#ifdef CONFIG_MODULES
> > + if (site_mod->mod) {
> > + stop = site_mod->mod->static_call_sites +
> > + site_mod->mod->num_static_call_sites;
> > + }
> > +#endif
>
> Instead of defining 'mod' in the inner loop below, it can be set at the
> top of the outer loop above. Then the above 'stop' calculation can
> be a little less verbose.

All done!