From: Eric Dumazet <edumazet@google.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
Eric Dumazet <eric.dumazet@gmail.com>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Nicolas Pitre <npitre@baylibre.com>
Subject: [PATCH] compiler_types: Introduce inline_for_performance
Date: Sun, 18 Jan 2026 15:24:48 +0000 [thread overview]
Message-ID: <20260118152448.2560414-1-edumazet@google.com> (raw)
inline keyword is often ignored by compilers.
We need something slightly stronger in networking fast paths
but __always_inline is too strong.
Instead, generalize idea Nicolas used in commit d533cb2d2af4
("__arch_xprod64(): make __always_inline when optimizing for performance")
This will help CONFIG_CC_OPTIMIZE_FOR_SIZE=y users keeping
their kernels small.
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/netdev/176847720679.3956289.12601442580224129560.git-patchwork-notify@kernel.org/T/#m2d7e201372a8aae1ce62a0b548e55fd4fe804909
Cc: Nicolas Pitre <npitre@baylibre.com>
---
arch/arm/include/asm/div64.h | 6 +-----
include/asm-generic/div64.h | 6 +-----
include/linux/compiler_types.h | 10 ++++++++++
3 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/arch/arm/include/asm/div64.h b/arch/arm/include/asm/div64.h
index d3ef8e416b27d22d38bf084e091b0e4795f74bd4..877dfc4c4c7344849eec2109b66c2825561719dc 100644
--- a/arch/arm/include/asm/div64.h
+++ b/arch/arm/include/asm/div64.h
@@ -52,11 +52,7 @@ static inline uint32_t __div64_32(uint64_t *n, uint32_t base)
#else
-#ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
-static __always_inline
-#else
-static inline
-#endif
+static inline_for_performance
uint64_t __arch_xprod_64(uint64_t m, uint64_t n, bool bias)
{
unsigned long long res;
diff --git a/include/asm-generic/div64.h b/include/asm-generic/div64.h
index 25e7b4b58dcf55a395b9db72e01f2cd220da58a0..9893356fff55679304f68833c11c8ae9052b9cea 100644
--- a/include/asm-generic/div64.h
+++ b/include/asm-generic/div64.h
@@ -134,11 +134,7 @@
* Hoping for compile-time optimization of conditional code.
* Architectures may provide their own optimized assembly implementation.
*/
-#ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
-static __always_inline
-#else
-static inline
-#endif
+static inline_for_performance
uint64_t __arch_xprod_64(const uint64_t m, uint64_t n, bool bias)
{
uint32_t m_lo = m;
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index d3318a3c257775d4f44e8f2eb7911ac52eefecc5..58b3de1f4c2540b6ffabd916948396ac8df9ba8f 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -248,6 +248,16 @@ struct ftrace_likely_data {
*/
#define inline inline __gnu_inline __inline_maybe_unused notrace
+/*
+ * Compilers might decide to ignore inline hint.
+ * Functions that are performance critical can use inline_for_performance.
+ */
+#ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
+#define inline_for_performance __always_inline
+#else
+#define inline_for_performance
+#endif
+
/*
* gcc provides both __inline__ and __inline as alternate spellings of
* the inline keyword, though the latter is undocumented. New kernel
base-commit: e84d960149e71e8d5e4db69775ce31305898ed0c
--
2.52.0.457.g6b5491de43-goog
next reply other threads:[~2026-01-18 15:24 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-18 15:24 Eric Dumazet [this message]
2026-01-18 15:32 ` [PATCH] compiler_types: Introduce inline_for_performance Florian Westphal
2026-01-18 15:39 ` Eric Dumazet
2026-01-18 18:36 ` kernel test robot
2026-01-18 22:33 ` David Laight
2026-01-18 19:47 ` Andrew Morton
2026-01-18 20:38 ` Eric Dumazet
2026-01-18 22:58 ` David Laight
2026-01-19 0:01 ` Andrew Morton
2026-01-19 9:33 ` David Laight
2026-01-19 10:25 ` Eric Dumazet
2026-01-19 10:33 ` Eric Dumazet
2026-01-19 10:50 ` David Laight
2026-01-19 15:47 ` Nicolas Pitre
2026-01-19 19:03 ` David Laight
2026-01-19 19:44 ` Nicolas Pitre
2026-01-18 21:04 ` kernel test robot
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=20260118152448.2560414-1-edumazet@google.com \
--to=edumazet@google.com \
--cc=akpm@linux-foundation.org \
--cc=eric.dumazet@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=npitre@baylibre.com \
--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