From: Guo Xuenan guoxuenan@huawei.com
hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8PGC4
--------------------------------
for performance reasons, hulk 6.6 do not use OPTIMIZE_INLINING. it using gnu_inline attribute causing inline functions not really inline, which introducing performance issues,so we make it editable(default disable) and adapt some link conflicting functions.
Signed-off-by: Guo Xuenan guoxuenan@huawei.com Signed-off-by: Yuntao Liu liuyuntao12@huawei.com --- arch/arm64/kvm/sys_regs.h | 4 +-- .../net/ethernet/mellanox/mlx5/core/health.c | 25 +++++++++++++++++++ .../ethernet/mellanox/mlx5/core/mlx5_core.h | 24 ------------------ .../pci/hive_isp_css_include/print_support.h | 2 +- include/linux/compiler_types.h | 11 ++++++++ include/trace/trace_events.h | 2 +- lib/Kconfig.debug | 3 ++- 7 files changed, 42 insertions(+), 29 deletions(-)
diff --git a/arch/arm64/kvm/sys_regs.h b/arch/arm64/kvm/sys_regs.h index c65c129b3500..e22183854847 100644 --- a/arch/arm64/kvm/sys_regs.h +++ b/arch/arm64/kvm/sys_regs.h @@ -100,8 +100,8 @@ struct sys_reg_desc { #define REG_USER_WI (1 << 3) /* WI from userspace only */
static __printf(2, 3) -inline void print_sys_reg_msg(const struct sys_reg_params *p, - char *fmt, ...) +INLINE_ATTR void print_sys_reg_msg(const struct sys_reg_params *p, + char *fmt, ...) { va_list va;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c index 2fb2598b775e..b18107a3a598 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/health.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/health.c @@ -45,6 +45,31 @@ #include "diag/fw_tracer.h" #include "diag/reporter_vnic.h"
+static INLINE_ATTR void mlx5_printk(struct mlx5_core_dev *dev, int level, + const char *format, ...) +{ + struct device *device = dev->device; + struct va_format vaf; + va_list args; + + if (WARN_ONCE(level < LOGLEVEL_EMERG || level > LOGLEVEL_DEBUG, + "Level %d is out of range, set to default level\n", level)) + level = LOGLEVEL_DEFAULT; + + va_start(args, format); + vaf.fmt = format; + vaf.va = &args; + + dev_printk_emit(level, device, "%s %s: %pV", dev_driver_string(device), dev_name(device), + &vaf); + va_end(args); +} + +#define mlx5_log(__dev, level, format, ...) \ + mlx5_printk(__dev, level, "%s:%d:(pid %d): " format, \ + __func__, __LINE__, current->pid, \ + ##__VA_ARGS__) + enum { MAX_MISSES = 3, }; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h index 124352459c23..ca6736987fb6 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h @@ -97,30 +97,6 @@ do { \ __func__, __LINE__, current->pid, \ ##__VA_ARGS__)
-static inline void mlx5_printk(struct mlx5_core_dev *dev, int level, const char *format, ...) -{ - struct device *device = dev->device; - struct va_format vaf; - va_list args; - - if (WARN_ONCE(level < LOGLEVEL_EMERG || level > LOGLEVEL_DEBUG, - "Level %d is out of range, set to default level\n", level)) - level = LOGLEVEL_DEFAULT; - - va_start(args, format); - vaf.fmt = format; - vaf.va = &args; - - dev_printk_emit(level, device, "%s %s: %pV", dev_driver_string(device), dev_name(device), - &vaf); - va_end(args); -} - -#define mlx5_log(__dev, level, format, ...) \ - mlx5_printk(__dev, level, "%s:%d:(pid %d): " format, \ - __func__, __LINE__, current->pid, \ - ##__VA_ARGS__) - static inline struct device *mlx5_core_dma_dev(struct mlx5_core_dev *dev) { return &dev->pdev->dev; diff --git a/drivers/staging/media/atomisp/pci/hive_isp_css_include/print_support.h b/drivers/staging/media/atomisp/pci/hive_isp_css_include/print_support.h index a3c7f3de6d17..b39a52dbf183 100644 --- a/drivers/staging/media/atomisp/pci/hive_isp_css_include/print_support.h +++ b/drivers/staging/media/atomisp/pci/hive_isp_css_include/print_support.h @@ -20,7 +20,7 @@
extern int (*sh_css_printf)(const char *fmt, va_list args); /* depends on host supplied print function in ia_css_init() */ -static inline __printf(1, 2) void ia_css_print(const char *fmt, ...) +static INLINE_ATTR __printf(1, 2) void ia_css_print(const char *fmt, ...) { va_list ap;
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index 476c54a6fb12..5aafd7a9de75 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -222,6 +222,17 @@ struct ftrace_likely_data { #define inline inline __gnu_inline __inline_maybe_unused notrace #endif
+/* + * Some functions cannot be compiled correctly when the inline attribute is set + * and CONFIG_OPTIMIZE_INLINING=n. In such cases, use the INLINE_ATTR instead + * of inline. + */ +#if defined(CONFIG_OPTIMIZE_INLINING) +#define INLINE_ATTR inline +#else +#define INLINE_ATTR +#endif + /* * gcc provides both __inline__ and __inline as alternate spellings of * the inline keyword, though the latter is undocumented. New kernel diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h index c2f9cabf154d..d2f99532ee02 100644 --- a/include/trace/trace_events.h +++ b/include/trace/trace_events.h @@ -253,7 +253,7 @@ static struct trace_event_fields trace_event_fields_##call[] = { \
#undef DECLARE_EVENT_CLASS #define DECLARE_EVENT_CLASS(call, proto, args, tstruct, assign, print) \ -static inline notrace int trace_event_get_offsets_##call( \ +static INLINE_ATTR notrace int trace_event_get_offsets_##call( \ struct trace_event_data_offsets_##call *__data_offsets, proto) \ { \ int __data_size = 0; \ diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 89582a93257a..b0cecd03ceba 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -475,7 +475,8 @@ config HEADERS_INSTALL as uapi header sanity checks.
config OPTIMIZE_INLINING - def_bool y + bool "Optimize inlining" + def_bool n help This option determines if the kernel forces gcc to inline the functions developers have marked 'inline'. Doing so takes away freedom from gcc to