Re: [PATCH v3 02/12] block/bdev: Annotate the blk_holder_ops callback invocations

Bart Van Assche
2026-04-13T16:06:16Z

On 4/12/26 11:00 PM, Marco Elver wrote:
> For now, that's intended - focus is on getting rid of false positives.
> Doing what you suggest above would require abusing the attributes to
> effectively become type qualifiers; that's generally questionable,
> because that's not what attributes are meant to do (and reworking TSA
> to provide real type-qualifiers is an intrusion into the type system
> that's also a hard sell). So for now, I'll try to do the simpler
> change, and later may look into adding -Wthread-safety specific
> warnings that points out such mismatches.

Is there agreement that the Linux kernel Clang build shouldn't break, no
matter what version of Clang is used to build the kernel (ignoring Clang
bugs)? If so, I think we either need a new macro to annotate function
pointers or thread-safety checking has to be disabled for Clang versions
that do not support annotating function pointers.

If I annotate function pointers with __releases() then the following
error message is reported with a Clang compiler built from the LLVM main
branch:

In file included from block/blk-core.c:16:
In file included from ./include/linux/module.h:20:
In file included from ./include/linux/elf.h:6:
In file included from ./arch/x86/include/asm/elf.h:10:
In file included from ./arch/x86/include/asm/ia32.h:7:
In file included from ./include/linux/compat.h:17:
./include/linux/fs.h:2309:55: error: use of undeclared identifier 'sb'
2309 | void (*kill_sb) (struct super_block *sb)
__releases(&sb->s_umount);
|

How to prevent such error messages? Is adding the capability to the
Linux kernel to detect whether or not annotating function pointers is
supported and introducing a new macro for annotating function pointers
the only solution?

Additionally, the __release() annotations introduced by this patch will
have to be surrounded by an #ifdef/#endif pair or thread-safety checking
in the Linux kernel will have to be disabled for Clang versions that do
not support adding attributes to function pointers.

Thanks,

Bart.