-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'net-mitigate-retpoline-overhead'
Paolo Abeni says: ==================== net: mitigate retpoline overhead The spectre v2 counter-measures, aka retpolines, are a source of measurable overhead[1]. We can partially address that when the function pointer refers to a builtin symbol resorting to a list of tests vs well-known builtin function and direct calls. Experimental results show that replacing a single indirect call via retpoline with several branches and a direct call gives performance gains even when multiple branches are added - 5 or more, as reported in [2]. This may lead to some uglification around the indirect calls. In netconf 2018 Eric Dumazet described a technique to hide the most relevant part of the needed boilerplate with some macro help. This series is a [re-]implementation of such idea, exposing the introduced helpers in a new header file. They are later leveraged to avoid the indirect call overhead in the GRO path, when possible. Overall this gives > 10% performance improvement for UDP GRO benchmark and smaller but measurable for TCP syn flood. The added infra can be used in follow-up patches to cope with retpoline overhead in other points of the networking stack (e.g. at the qdisc layer) and possibly even in other subsystems. v2 -> v3: - fix build error with CONFIG_IPV6=m v1 -> v2: - list explicitly the builtin function names in INDIRECT_CALL_*(), as suggested by Ed Cree - expand the recipients list rfc -> v1: - use branch prediction hints, as suggested by Eric [1] http://vger.kernel.org/netconf2018_files/PaoloAbeni_netconf2018.pdf [2] https://linuxplumbersconf.org/event/2/contributions/99/attachments/98/117/lpc18_paper_af_xdp_perf-v2.pdf ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Showing
9 changed files
with
136 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters