diff --git a/arch/arm64/kvm/sys_regs.h b/arch/arm64/kvm/sys_regs.h index c65c129b35001049ed4b14c02ec6fcfb8e37b1fa..e221838548475b8fe75469d038878f66141e957c 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/arch/x86/configs/i386_defconfig b/arch/x86/configs/i386_defconfig index 1b411bbf3cb0b808e81c9d55c929813654bad3ba..6a505b3b4b4d7cdf21d003620544bcb06e83f12d 100644 --- a/arch/x86/configs/i386_defconfig +++ b/arch/x86/configs/i386_defconfig @@ -280,5 +280,6 @@ CONFIG_BLK_DEV_IO_TRACE=y CONFIG_PROVIDE_OHCI1394_DMA_INIT=y CONFIG_EARLY_PRINTK_DBGP=y CONFIG_DEBUG_BOOT_PARAMS=y +CONFIG_OPTIMIZE_INLINING=y CONFIG_UNWINDER_FRAME_POINTER=y # CONFIG_64BIT is not set diff --git a/arch/x86/configs/x86_64_defconfig b/arch/x86/configs/x86_64_defconfig index 409e9182bd29b441d261fa8e1f9de1d1d2e3379d..5bd1fcabbe7dafcb2824e3d65d7c99edc267280e 100644 --- a/arch/x86/configs/x86_64_defconfig +++ b/arch/x86/configs/x86_64_defconfig @@ -276,3 +276,4 @@ CONFIG_BLK_DEV_IO_TRACE=y CONFIG_PROVIDE_OHCI1394_DMA_INIT=y CONFIG_EARLY_PRINTK_DBGP=y CONFIG_DEBUG_BOOT_PARAMS=y +CONFIG_OPTIMIZE_INLINING=y diff --git a/drivers/net/ethernet/mellanox/mlx5/core/health.c b/drivers/net/ethernet/mellanox/mlx5/core/health.c index 2fb2598b775efd60be6f436f9c144daf4f5d9d91..b18107a3a598969da0188fa652f64d4223d41764 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 124352459c23d9924dc17f5135816dee3c388b20..ca6736987fb64d302b3e1e63c3e903e33aeac61d 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 a3c7f3de6d173409df0e4a6b07baeeea2955005a..b39a52dbf1832f0d1ccf90ecef94c1e35a422564 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 c523c6683789d89d941a8dcd18c495f504d4e660..5aafd7a9de75b342df6c8e5a07e8b285955c7fa3 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -206,13 +206,32 @@ struct ftrace_likely_data { #define __naked __attribute__((__naked__)) notrace /* + * Force always-inline if the user requests it so via the .config. * Prefer gnu_inline, so that extern inline functions do not emit an * externally visible function. This makes extern inline behave as per gnu89 * semantics rather than c99. This prevents multiple symbol definition errors * of extern inline functions at link time. * A lot of inline functions can cause havoc with function tracing. + * Do not use __always_inline here, since currently it expands to inline again + * (which would break users of __always_inline). */ +#if !defined(CONFIG_OPTIMIZE_INLINING) +#define inline inline __attribute__((__always_inline__)) __gnu_inline \ + __inline_maybe_unused notrace +#else #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 diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h index c2f9cabf154d11d27b7944f7cc14a02812249d5c..d2f99532ee0229e5f4efe6e400dc5f2f5a74bac5 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/kernel/configs/tiny.config b/kernel/configs/tiny.config index 00009f7d083567e092549d8937569d5259c3281b..d0655ba4df4c020bb65f822fad3e68570189f52a 100644 --- a/kernel/configs/tiny.config +++ b/kernel/configs/tiny.config @@ -6,5 +6,6 @@ CONFIG_CC_OPTIMIZE_FOR_SIZE=y CONFIG_KERNEL_XZ=y # CONFIG_KERNEL_LZO is not set # CONFIG_KERNEL_LZ4 is not set +CONFIG_OPTIMIZE_INLINING=y CONFIG_SLUB=y CONFIG_SLUB_TINY=y diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 7241c304cb5c7e4463a60195e172e2a8660c3467..b0cecd03ceba2ef00a550b5227729804d3e048d7 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -474,6 +474,19 @@ config HEADERS_INSTALL user-space program samples. It is also needed by some features such as uapi header sanity checks. +config OPTIMIZE_INLINING + 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 + do what it thinks is best, which is desirable for the gcc 3.x series of + compilers. The gcc 4.x series have a rewritten inlining algorithm and + enabling this option will generate a smaller kernel there. Hopefully + this algorithm is so good that allowing gcc 4.x and above to make the + decision will become the default in the future. Until then this option + is there to test gcc for this. + config DEBUG_SECTION_MISMATCH bool "Enable full Section mismatch analysis" depends on CC_IS_GCC