]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
cleanup: Always inline everything
authorPeter Zijlstra <peterz@infradead.org>
Fri, 31 Oct 2025 11:02:12 +0000 (12:02 +0100)
committerIngo Molnar <mingo@kernel.org>
Tue, 4 Nov 2025 07:35:58 +0000 (08:35 +0100)
KASAN bloat caused cleanup helper functions to not get inlined:

  vmlinux.o: error: objtool: irqentry_exit+0x323: call to class_user_rw_access_destructor() with UACCESS enabled

Force inline all the cleanup helpers like they already are on normal
builds.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://patch.msgid.link/20251031105435.GU4068168@noisy.programming.kicks-ass.net
include/linux/cleanup.h

index 2573585b7f068abe992af1ac05f478fef7b34306..d1806ac5342c653b711cbf2d382f93e9eb200263 100644 (file)
  */
 
 #define DEFINE_FREE(_name, _type, _free) \
-       static inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; }
+       static __always_inline void __free_##_name(void *p) { _type _T = *(_type *)p; _free; }
 
 #define __free(_name)  __cleanup(__free_##_name)
 
                __val;                      \
        })
 
-static inline __must_check
+static __always_inline __must_check
 const volatile void * __must_check_fn(const volatile void *val)
 { return val; }
 
@@ -274,16 +274,16 @@ const volatile void * __must_check_fn(const volatile void *val)
 
 #define DEFINE_CLASS(_name, _type, _exit, _init, _init_args...)                \
 typedef _type class_##_name##_t;                                       \
-static inline void class_##_name##_destructor(_type *p)                        \
+static __always_inline void class_##_name##_destructor(_type *p)       \
 { _type _T = *p; _exit; }                                              \
-static inline _type class_##_name##_constructor(_init_args)            \
+static __always_inline _type class_##_name##_constructor(_init_args)   \
 { _type t = _init; return t; }
 
 #define EXTEND_CLASS(_name, ext, _init, _init_args...)                 \
 typedef class_##_name##_t class_##_name##ext##_t;                      \
-static inline void class_##_name##ext##_destructor(class_##_name##_t *p)\
+static __always_inline void class_##_name##ext##_destructor(class_##_name##_t *p) \
 { class_##_name##_destructor(p); }                                     \
-static inline class_##_name##_t class_##_name##ext##_constructor(_init_args) \
+static __always_inline class_##_name##_t class_##_name##ext##_constructor(_init_args) \
 { class_##_name##_t t = _init; return t; }
 
 #define CLASS(_name, var)                                              \
@@ -347,7 +347,7 @@ static __maybe_unused const bool class_##_name##_is_conditional = _is_cond
        })
 
 #define __DEFINE_GUARD_LOCK_PTR(_name, _exp)                                \
-       static inline void *class_##_name##_lock_ptr(class_##_name##_t *_T) \
+       static __always_inline void *class_##_name##_lock_ptr(class_##_name##_t *_T) \
        {                                                                   \
                void *_ptr = (void *)(__force unsigned long)*(_exp);        \
                if (IS_ERR(_ptr)) {                                         \
@@ -355,7 +355,7 @@ static __maybe_unused const bool class_##_name##_is_conditional = _is_cond
                }                                                           \
                return _ptr;                                                \
        }                                                                   \
-       static inline int class_##_name##_lock_err(class_##_name##_t *_T)   \
+       static __always_inline int class_##_name##_lock_err(class_##_name##_t *_T) \
        {                                                                   \
                long _rc = (__force unsigned long)*(_exp);                  \
                if (!_rc) {                                                 \
@@ -384,9 +384,9 @@ static __maybe_unused const bool class_##_name##_is_conditional = _is_cond
        EXTEND_CLASS(_name, _ext, \
                     ({ void *_t = _T; int _RET = (_lock); if (_T && !(_cond)) _t = ERR_PTR(_RET); _t; }), \
                     class_##_name##_t _T) \
-       static inline void * class_##_name##_ext##_lock_ptr(class_##_name##_t *_T) \
+       static __always_inline void * class_##_name##_ext##_lock_ptr(class_##_name##_t *_T) \
        { return class_##_name##_lock_ptr(_T); } \
-       static inline int class_##_name##_ext##_lock_err(class_##_name##_t *_T) \
+       static __always_inline int class_##_name##_ext##_lock_err(class_##_name##_t *_T) \
        { return class_##_name##_lock_err(_T); }
 
 /*
@@ -466,7 +466,7 @@ typedef struct {                                                    \
        __VA_ARGS__;                                                    \
 } class_##_name##_t;                                                   \
                                                                        \
-static inline void class_##_name##_destructor(class_##_name##_t *_T)   \
+static __always_inline void class_##_name##_destructor(class_##_name##_t *_T) \
 {                                                                      \
        if (!__GUARD_IS_ERR(_T->lock)) { _unlock; }                     \
 }                                                                      \
@@ -474,7 +474,7 @@ static inline void class_##_name##_destructor(class_##_name##_t *_T)        \
 __DEFINE_GUARD_LOCK_PTR(_name, &_T->lock)
 
 #define __DEFINE_LOCK_GUARD_1(_name, _type, _lock)                     \
-static inline class_##_name##_t class_##_name##_constructor(_type *l)  \
+static __always_inline class_##_name##_t class_##_name##_constructor(_type *l) \
 {                                                                      \
        class_##_name##_t _t = { .lock = l }, *_T = &_t;                \
        _lock;                                                          \
@@ -482,7 +482,7 @@ static inline class_##_name##_t class_##_name##_constructor(_type *l)       \
 }
 
 #define __DEFINE_LOCK_GUARD_0(_name, _lock)                            \
-static inline class_##_name##_t class_##_name##_constructor(void)      \
+static __always_inline class_##_name##_t class_##_name##_constructor(void) \
 {                                                                      \
        class_##_name##_t _t = { .lock = (void*)1 },                    \
                         *_T __maybe_unused = &_t;                      \
@@ -508,9 +508,9 @@ __DEFINE_LOCK_GUARD_0(_name, _lock)
                        if (_T->lock && !(_cond)) _T->lock = ERR_PTR(_RET);\
                        _t; }),                                         \
                     typeof_member(class_##_name##_t, lock) l)          \
-       static inline void * class_##_name##_ext##_lock_ptr(class_##_name##_t *_T) \
+       static __always_inline void * class_##_name##_ext##_lock_ptr(class_##_name##_t *_T) \
        { return class_##_name##_lock_ptr(_T); } \
-       static inline int class_##_name##_ext##_lock_err(class_##_name##_t *_T) \
+       static __always_inline int class_##_name##_ext##_lock_err(class_##_name##_t *_T) \
        { return class_##_name##_lock_err(_T); }
 
 #define DEFINE_LOCK_GUARD_1_COND_3(_name, _ext, _lock) \