[PATCH] arm64/fpsimd: Avoid warning when sve_to_fpsimd() is unused

Mark Rutland mark.rutland at arm.com
Sat May 3 07:52:18 PDT 2025


On Sat, May 03, 2025 at 04:10:43PM +0200, Arnd Bergmann wrote:
> On Wed, Apr 30, 2025, at 19:32, Mark Rutland wrote:
> >
> > diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
> > index b0874402f7ecc..422b9d43b1e64 100644
> > --- a/arch/arm64/kernel/fpsimd.c
> > +++ b/arch/arm64/kernel/fpsimd.c
> > @@ -649,7 +649,7 @@ static void __fpsimd_to_sve(void *sst, struct 
> > user_fpsimd_state const *fst,
> >   * task->thread.uw.fpsimd_state must be up to date before calling this
> >   * function.
> >   */
> > -static void fpsimd_to_sve(struct task_struct *task)
> > +static inline void fpsimd_to_sve(struct task_struct *task)
> >  {
> >  	unsigned int vq;
> >  	void *sst = task->thread.sve_state;
> 
> I just sent a different patch (adding an #ifdef) before I
> saw this one is already applied.
> 
> Avoiding the #ifdef does make your version nicer, though this
> may come back later, since I think this would still be a warning
> at W=1 level, see this bit in linux/compiler.h:
> 
> /*
>  * GCC does not warn about unused static inline functions for -Wunused-function.
>  * Suppress the warning in clang as well by using __maybe_unused, but enable it
>  * for W=1 build. This will allow clang to find unused functions. Remove the
>  * __inline_maybe_unused entirely after fixing most of -Wunused-function warnings.
>  */
> #ifdef KBUILD_EXTRA_WARN1
> #define __inline_maybe_unused
> #else
> #define __inline_maybe_unused __maybe_unused
> #endif
> #define inline inline __gnu_inline __inline_maybe_unused notrace
> 
> IIRC, gcc never warns for unused inline functions, but clang warns
> about them when they are defined in a .c file rather than a header.

Fair, though with W=1 there's an existing issue with sme_free() that no-one has
complained about:

| [mark at lakrids:~/src/linux]% git clean -qfdx
| [mark at lakrids:~/src/linux]% usekorg-llvm 19.1.0 make ARCH=arm64 LLVM=1 -s defconfig             
| [mark at lakrids:~/src/linux]% ./scripts/config -d ARM64_SVE                          
| [mark at lakrids:~/src/linux]% usekorg-llvm 19.1.0 make ARCH=arm64 LLVM=1 -s W=1 arch/arm64/kernel/fpsimd.o
| arch/arm64/kernel/fpsimd.c:208:20: warning: unused function 'sme_free' [-Wunused-function]
|   208 | static inline void sme_free(struct task_struct *t) { }
|       |                    ^~~~~~~~
| arch/arm64/kernel/fpsimd.c:676:20: warning: unused function 'sve_to_fpsimd' [-Wunused-function]
|   676 | static inline void sve_to_fpsimd(struct task_struct *task)
|       |                    ^~~~~~~~~~~~~
| 2 warnings generated.

... so we'd want to do something consistent there (and probably for a
few related functions).

How important is fixing W=1? I note we have a *tonne* of warnings today;
so I assume we can punt that to a future cleanup?

Mark.



More information about the linux-arm-kernel mailing list