netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>
Subject: Re: [RFC PATCH 1/4] indirect call wrappers: helpers to speed-up indirect calls of builtin
Date: Thu, 29 Nov 2018 15:25:49 -0800	[thread overview]
Message-ID: <2b23817b-909f-360c-2ce4-e3c36186d2ef@gmail.com> (raw)
In-Reply-To: <6a350192de5da125c9922a29526fae9e73c2fe7d.1543530315.git.pabeni@redhat.com>



On 11/29/2018 03:00 PM, Paolo Abeni wrote:
> This header define a bunch of helpers that allow avoiding the
> retpoline overhead when calling builtin functions via function pointers.
> It boils down to explicitly comparing the function pointers to
> known builtin functions and eventually invoke directly the latter.
> 
> The macro defined here implement the boilerplate for the above schema
> and will be used by the next patches.
> 
> Suggested-by: Eric Dumazet <Eric Dumazet <edumazet@google.com>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
>  include/linux/indirect_call_wrapper.h | 77 +++++++++++++++++++++++++++
>  1 file changed, 77 insertions(+)
>  create mode 100644 include/linux/indirect_call_wrapper.h
> 
> diff --git a/include/linux/indirect_call_wrapper.h b/include/linux/indirect_call_wrapper.h
> new file mode 100644
> index 000000000000..57e82b4a166d
> --- /dev/null
> +++ b/include/linux/indirect_call_wrapper.h
> @@ -0,0 +1,77 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef _LINUX_INDIRECT_CALL_WRAPPER_H
> +#define _LINUX_INDIRECT_CALL_WRAPPER_H
> +
> +#ifdef CONFIG_RETPOLINE
> +
> +/*
> + * INDIRECT_CALL_$NR - wrapper for indirect calls with $NR known builtin
> + *  @f: function pointer
> + *  @name: base name for builtin functions, see INDIRECT_CALLABLE_DECLARE_$NR
> + *  @__VA_ARGS__: arguments for @f
> + *
> + * Avoid retpoline overhead for known builtin, checking @f vs each of them and
> + * eventually invoking directly the builtin function. Fallback to the indirect
> + * call
> + */
> +#define INDIRECT_CALL_1(f, name, ...)					\
> +	({								\
> +		f == name ## 1 ? name ## 1(__VA_ARGS__) :		\

              likely(f == name ## 1) ? ...

> +				 f(__VA_ARGS__);			\
> +	})
> +#define INDIRECT_CALL_2(f, name, ...)					\
> +	({								\
> +		f == name ## 2 ? name ## 2(__VA_ARGS__) :		\

             likely(f == name ## 2) ? ...


> +				 INDIRECT_CALL_1(f, name, __VA_ARGS__);	\
> +	})
> +
>

  reply	other threads:[~2018-11-30 10:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-29 23:00 [RFC PATCH 0/4] net: mitigate retpoline overhead Paolo Abeni
2018-11-29 23:00 ` [RFC PATCH 1/4] indirect call wrappers: helpers to speed-up indirect calls of builtin Paolo Abeni
2018-11-29 23:25   ` Eric Dumazet [this message]
2018-11-30  8:29     ` Paolo Abeni
2018-11-29 23:00 ` [RFC PATCH 2/4] net: use indirect call wrappers at GRO network layer Paolo Abeni
2018-11-29 23:00 ` [RFC PATCH 3/4] net: use indirect call wrapper at GRO transport layer Paolo Abeni
2018-11-29 23:00 ` [RFC PATCH 4/4] udp: use indirect call wrapper for GRO socket lookup Paolo Abeni

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=2b23817b-909f-360c-2ce4-e3c36186d2ef@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).