Re: [PATCH v1 1/1] locking/rwsem: Mark inline helpers with __maybe_unused

From: Peter Zijlstra
Date: Mon Sep 09 2024 - 09:30:03 EST


On Mon, Sep 09, 2024 at 02:58:39PM +0300, Andy Shevchenko wrote:
> When one or more inline heplers are unused, it prevents kernel builds
> with clang, `make W=1` and CONFIG_WERROR=y:
>
> kernel/locking/rwsem.c:187:20: error: unused function 'is_rwsem_reader_owned' [-Werror,-Wunused-function]
> 187 | static inline bool is_rwsem_reader_owned(struct rw_semaphore *sem)
> | ^~~~~~~~~~~~~~~~~~~~~
> kernel/locking/rwsem.c:271:35: error: unused function 'rwsem_owner' [-Werror,-Wunused-function]
> 271 | static inline struct task_struct *rwsem_owner(struct rw_semaphore *sem)
> | ^~~~~~~~~~~
>
> Fix this by marking inline helpers with __maybe_unused.
>
> See also commit 6863f5643dd7 ("kbuild: allow Clang to find unused static
> inline functions for W=1 build").

:-(

And now you're back to the exact situation that people tried to avoid.
The moment one of these functions goes unused it will no longer scream
about it.

I'm for reverting the above commit, that gets all static inline on the
same footing, it should not matter if code is from a header file or not.