lockdep: Move lockdep_assert_locked() under #ifdef CONFIG_PROVE_LOCKING
PATCH 1/1 lockdep: Move lockdep_assert_locked() under #ifdef CONFIG_PROVE_LOCKING
When lockdep_assert_locked() is unused, it prevents kernel builds with clang, make W=1 and CONFIG_WERROR=y:
kernel/locking/lockdep.c:160:20: error: unused function 'lockdep_assert_locked' [-Werror,-Wunused-function]
Fix this by moving it under the respective ifdeffery.
See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static inline functions for W=1 build").
--- kernel/locking/lockdep.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/locking/lockdep.c +2 -0
@@ -157,10 +157,12 @@ static inline void lockdep_unlock(void)__this_cpu_dec (lockdep_recursion); } +#ifdef CONFIG_PROVE_LOCKING static inline bool lockdep_assert_locked (void ) {return DEBUG_LOCKS_WARN_ON (__owner != current); } +#endif static struct task_struct *lockdep_selftest_task_struct;
Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
Quoted 11 lines · Andy Shevchenko
When
lockdep_assert_locked()is unused, it prevents kernel builds with clang,make W=1andCONFIG_WERROR=y:
kernel/locking/lockdep.c:160:20: error: unused function 'lockdep_assert_locked' [-Werror,-Wunused-function]Fix this by moving it under the respective ifdeffery.
See also commit
6863f5643dd7("kbuild: allow Clang to find unused static inline functions for W=1 build").Signed-off-by Andy Shevchenko <[email protected]>
Queued for more testing, thanks!
Regards,
Boqun
Quoted 24 lines
--- kernel/locking/lockdep.c | 2 ++ 1 file changed, 2 insertions(+)kernel/locking/lockdep.c +2
-0@@ -157,10 +157,12 @@ static inline void lockdep_unlock(void)__this_cpu_dec (lockdep_recursion); } +#ifdef CONFIG_PROVE_LOCKING static inline bool lockdep_assert_locked (void ) {return DEBUG_LOCKS_WARN_ON (__owner != current); } +#endif static struct task_struct *lockdep_selftest_task_struct;Signature · 1 line
2.43.0.rc1.1336.g36b5255a03ac
The following commit has been merged into the locking/core branch of tip:
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 3430600925859be3c8588b8220173758c7860e8c Gitweb: https://git.kernel.org/tip/3430600925859be3c8588b8220173758c7860e8c Author: Andy Shevchenko <[email protected]> AuthorDate: Mon, 02 Dec 2024 21:34:45 +02:00 Committer: Boqun Feng <[email protected]> CommitterDate: Thu, 19 Dec 2024 14:04:03 -08:00
lockdep: Move lockdep_assert_locked() under #ifdef CONFIG_PROVE_LOCKING
When lockdep_assert_locked() is unused, it prevents kernel builds with clang, make W=1 and CONFIG_WERROR=y, CONFIG_LOCKDEP=y and CONFIG_PROVE_LOCKING=n:
kernel/locking/lockdep.c:160:20: error: unused function 'lockdep_assert_locked' [-Werror,-Wunused-function]
Fix this by moving it under the respective ifdeffery.
See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static inline functions for W=1 build").
[Boqun: add more config information of the error]
--- kernel/locking/lockdep.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/locking/lockdep.c +2 -0
@@ -157,10 +157,12 @@ static inline void lockdep_unlock(void)__this_cpu_dec (lockdep_recursion); } +#ifdef CONFIG_PROVE_LOCKING static inline bool lockdep_assert_locked (void ) {return DEBUG_LOCKS_WARN_ON (__owner != current); } +#endif static struct task_struct *lockdep_selftest_task_struct;