Home Home > GIT Browse > SLE12-SP4-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Kubecek <mkubecek@suse.cz>2019-06-06 10:45:08 +0200
committerMichal Kubecek <mkubecek@suse.cz>2019-06-06 10:45:12 +0200
commit7905c1dda9daaaa7789e77d1ce0d4482af02ac37 (patch)
treebf39b07748c0932dc5f647c9c39e32a98677f178
parentad1a12237d271bd77361c94d61e387e0829df122 (diff)
indirect call wrappers: helpers to speed-up indirect calls of
builtin (bsc#1124503).
-rw-r--r--patches.fixes/indirect-call-wrappers-helpers-to-speed-up-indirect-.patch85
-rw-r--r--series.conf1
2 files changed, 86 insertions, 0 deletions
diff --git a/patches.fixes/indirect-call-wrappers-helpers-to-speed-up-indirect-.patch b/patches.fixes/indirect-call-wrappers-helpers-to-speed-up-indirect-.patch
new file mode 100644
index 0000000000..a152ebecc1
--- /dev/null
+++ b/patches.fixes/indirect-call-wrappers-helpers-to-speed-up-indirect-.patch
@@ -0,0 +1,85 @@
+From: Paolo Abeni <pabeni@redhat.com>
+Date: Fri, 14 Dec 2018 11:51:57 +0100
+Subject: indirect call wrappers: helpers to speed-up indirect calls of builtin
+Patch-mainline: v5.0-rc1
+Git-commit: 283c16a2dfd332bf5610c874f7b9f9c8b601ce53
+References: bsc#1124503
+
+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 macros defined here implement the boilerplate for the above schema
+and will be used by the next patches.
+
+rfc -> v1:
+ - use branch prediction hint, as suggested by Eric
+v1 -> v2:
+ - list explicitly the builtin function names in INDIRECT_CALL_*(),
+ as suggested by Ed Cree
+
+Suggested-by: Eric Dumazet <edumazet@google.com>
+Signed-off-by: Paolo Abeni <pabeni@redhat.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Acked-by: Michal Kubecek <mkubecek@suse.cz>
+
+---
+ include/linux/indirect_call_wrapper.h | 51 +++++++++++++++++++++++++++
+ 1 file changed, 51 insertions(+)
+ create mode 100644 include/linux/indirect_call_wrapper.h
+
+--- /dev/null
++++ b/include/linux/indirect_call_wrapper.h
+@@ -0,0 +1,51 @@
++/* 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
++ * @f$NR: builtin functions names, up to $NR of them
++ * @__VA_ARGS__: arguments for @f
++ *
++ * Avoid retpoline overhead for known builtin, checking @f vs each of them and
++ * eventually invoking directly the builtin function. The functions are check
++ * in the given order. Fallback to the indirect call.
++ */
++#define INDIRECT_CALL_1(f, f1, ...) \
++ ({ \
++ likely(f == f1) ? f1(__VA_ARGS__) : f(__VA_ARGS__); \
++ })
++#define INDIRECT_CALL_2(f, f2, f1, ...) \
++ ({ \
++ likely(f == f2) ? f2(__VA_ARGS__) : \
++ INDIRECT_CALL_1(f, f1, __VA_ARGS__); \
++ })
++
++#define INDIRECT_CALLABLE_DECLARE(f) f
++#define INDIRECT_CALLABLE_SCOPE
++
++#else
++#define INDIRECT_CALL_1(f, name, ...) f(__VA_ARGS__)
++#define INDIRECT_CALL_2(f, name, ...) f(__VA_ARGS__)
++#define INDIRECT_CALLABLE_DECLARE(f)
++#define INDIRECT_CALLABLE_SCOPE static
++#endif
++
++/*
++ * We can use INDIRECT_CALL_$NR for ipv6 related functions only if ipv6 is
++ * builtin, this macro simplify dealing with indirect calls with only ipv4/ipv6
++ * alternatives
++ */
++#if IS_BUILTIN(CONFIG_IPV6)
++#define INDIRECT_CALL_INET(f, f2, f1, ...) \
++ INDIRECT_CALL_2(f, f2, f1, __VA_ARGS__)
++#elif IS_ENABLED(CONFIG_INET)
++#define INDIRECT_CALL_INET(f, f2, f1, ...) INDIRECT_CALL_1(f, f1, __VA_ARGS__)
++#else
++#define INDIRECT_CALL_INET(f, f2, f1, ...) f(__VA_ARGS__)
++#endif
++
++#endif
diff --git a/series.conf b/series.conf
index 1c9c26a43f..43532c26d8 100644
--- a/series.conf
+++ b/series.conf
@@ -20615,6 +20615,7 @@
patches.fixes/0001-net-mlx5-Release-resource-on-error-flow.patch
patches.fixes/0001-net-mlx5-Return-success-for-PAGE_FAULT_RESUME-in-int.patch
patches.fixes/0001-net-mlx5-Use-multi-threaded-workqueue-for-page-fault.patch
+ patches.fixes/indirect-call-wrappers-helpers-to-speed-up-indirect-.patch
patches.fixes/mac80211-fix-radiotap-vendor-presence-bitmap-handlin.patch
patches.drivers/Bluetooth-Fix-unnecessary-error-message-for-HCI-requ.patch
patches.fixes/igb-Fix-an-issue-that-PME-is-not-enabled-during-runt.patch