[PATCHv2 09/17] nvme: add Clang context annotations for nvme_subsystems_lock

Christoph Hellwig hch at lst.de
Thu Jun 25 23:45:28 PDT 2026


> -static LIST_HEAD(nvme_subsystems);
> +static __guarded_by(&nvme_subsystems_lock) LIST_HEAD(nvme_subsystems);

Having the guard_by before the LIST_HEAD makes this a real mess to
read.

Can we add a

#define LIST_HEAD_GUARDED(_list, _lock) \
	__guarded_by(_lock) LIST_HEAD(_list)

and use that instead?  And maybe do these after the lock declaration.
While the compiler doesn't care, that's much easier to follow for
humans.

> +	/*
> +	 * Initializing subsys->ctrls list doesn't need to be protected
> +	 * using @nvme_subsystems_lock. So suppress the Clang's warning
> +	 * declaring context_unsafe.
> +	 */
> +	context_unsafe(INIT_LIST_HEAD(&subsys->ctrls));

This could also use a helper.




More information about the Linux-nvme mailing list