lkml.org 
[lkml]   [2019]   [Jun]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH 11/15] static_call: Add inline static call infrastructure
Date
> On Jun 5, 2019, at 6:08 AM, Peter Zijlstra <peterz@infradead.org> wrote:
>
> From: Josh Poimboeuf <jpoimboe@redhat.com>
>
> Add infrastructure for an arch-specific CONFIG_HAVE_STATIC_CALL_INLINE
> option, which is a faster version of CONFIG_HAVE_STATIC_CALL. At
> runtime, the static call sites are patched directly, rather than using
> the out-of-line trampolines.
>
> Compared to out-of-line static calls, the performance benefits are more
> modest, but still measurable. Steven Rostedt did some tracepoint
> measurements:

[ snip ]

> +static void static_call_del_module(struct module *mod)
> +{
> + struct static_call_site *start = mod->static_call_sites;
> + struct static_call_site *stop = mod->static_call_sites +
> + mod->num_static_call_sites;
> + struct static_call_site *site;
> + struct static_call_key *key, *prev_key = NULL;
> + struct static_call_mod *site_mod;
> +
> + for (site = start; site < stop; site++) {
> + key = static_call_key(site);
> + if (key == prev_key)
> + continue;
> + prev_key = key;
> +
> + list_for_each_entry(site_mod, &key->site_mods, list) {
> + if (site_mod->mod == mod) {
> + list_del(&site_mod->list);
> + kfree(site_mod);
> + break;
> + }
> + }
> + }

I think that for safety, when a module is removed, all the static-calls
should be traversed to check that none of them calls any function in the
removed module. If that happens, perhaps it should be poisoned.

> +}
> +
> +static int static_call_module_notify(struct notifier_block *nb,
> + unsigned long val, void *data)
> +{
> + struct module *mod = data;
> + int ret = 0;
> +
> + cpus_read_lock();
> + static_call_lock();
> +
> + switch (val) {
> + case MODULE_STATE_COMING:
> + module_disable_ro(mod);
> + ret = static_call_add_module(mod);
> + module_enable_ro(mod, false);

Doesn’t it cause some pages to be W+X ? Can it be avoided?

> + if (ret) {
> + WARN(1, "Failed to allocate memory for static calls");
> + static_call_del_module(mod);

If static_call_add_module() succeeded in changing some of the calls, but not
all, I don’t think that static_call_del_module() will correctly undo
static_call_add_module(). The code transformations, I think, will remain.

\
 
 \ /
  Last update: 2019-06-07 00:24    [W:0.401 / U:2.612 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site