public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Damien Le Moal <dlemoal@kernel.org>, Tejun Heo <tj@kernel.org>,
	Josef Bacik <josef@toxicpanda.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Christian Brauner <brauner@kernel.org>,
	Joanne Koong <joannelkoong@gmail.com>,
	David Hildenbrand <david@kernel.org>,
	Andreas Gruenbacher <agruenba@redhat.com>,
	Mateusz Guzik <mjguzik@gmail.com>
Subject: Re: [PATCH v2 02/12] block: Make the lock context annotations compatible with Clang
Date: Tue, 17 Mar 2026 15:04:48 +0100	[thread overview]
Message-ID: <20260317140448.GB2670@lst.de> (raw)
In-Reply-To: <20260316200901.4111651-4-bvanassche@acm.org>

On Mon, Mar 16, 2026 at 01:08:39PM -0700, Bart Van Assche wrote:
> Clang is more strict than sparse with regard to lock context annotation
> checking. Hence this patch that makes the lock context annotations
> compatible with Clang.

Does it break sparse in the way?  If so we'll need to find out a way
to disable the sparse lock annotations conditionally as there are
other warnings we only get from spare.  Most importantly the __bitwise
warnings for endianess and the address spaces for user/mmio pointers.
All these are arguably more important than the lock annotations.
(If only the compilers could pick these up natively...)

> __release() annotations have been added below
> invocations of indirect calls that unlock a mutex because Clang does not
> support annotating function pointers with __releases().

Please split this up into a patch per area and document what you're
doing in each area in the commit log.

>  	if (bdev->bd_holder_ops && bdev->bd_holder_ops->freeze) {
>  		error = bdev->bd_holder_ops->freeze(bdev);
>  		lockdep_assert_not_held(&bdev->bd_holder_lock);
> +		__release(&bdev->bd_holder_lock); /* blk_holder_ops::freeze() */

I have no idea what this comment is supposed to mean.

>  	} else {
>  		mutex_unlock(&bdev->bd_holder_lock);
>  		error = sync_blockdev(bdev);
> @@ -356,6 +357,7 @@ int bdev_thaw(struct block_device *bdev)
>  	if (bdev->bd_holder_ops && bdev->bd_holder_ops->thaw) {
>  		error = bdev->bd_holder_ops->thaw(bdev);
>  		lockdep_assert_not_held(&bdev->bd_holder_lock);
> +		__release(&bdev->bd_holder_lock); /* blk_holder_ops::freeze() */

Same.

> -	if (bdev->bd_holder_ops && bdev->bd_holder_ops->mark_dead)
> +	if (bdev->bd_holder_ops && bdev->bd_holder_ops->mark_dead) {
>  		bdev->bd_holder_ops->mark_dead(bdev, surprise);
> -	else {
> +		/* blk_holder_ops::mark_dead() */

Same.

>  int blkg_conf_open_bdev(struct blkg_conf_ctx *ctx)
> +	__no_context_analysis /* conditional locking */

Please always try to refactor code to avoid the conditional locking
first, and only if that doesn't work it go for this, explaining why
you had to do that in the commit message.

>  static void *kyber_##name##_rqs_start(struct seq_file *m, loff_t *pos)	\
> -	__acquires(&khd->lock)						\
> +	__acquires(((struct kyber_hctx_data *)((struct blk_mq_hw_ctx *)m->private)->sched_data)->lock) \
>  {									\

Urrg.  Is there some way to make this less ugly?  A macro?

Same for all the other crazy cast+dereference instances.

> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h

This isn't block layer code at all.


  reply	other threads:[~2026-03-17 14:04 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-16 20:08 [PATCH v2 00/12] Enable lock context analysis Bart Van Assche
2026-03-16 20:08 ` [PATCH v2 01/12] drbd: Balance RCU calls in drbd_adm_dump_devices() Bart Van Assche
2026-03-16 20:08 ` [PATCH v2] powerpc/powermac: Remove pmac_low_i2c_{lock,unlock}() Bart Van Assche
2026-03-16 20:12   ` Bart Van Assche
2026-03-16 20:08 ` [PATCH v2 02/12] block: Make the lock context annotations compatible with Clang Bart Van Assche
2026-03-17 14:04   ` Christoph Hellwig [this message]
2026-03-17 16:36     ` Bart Van Assche
2026-03-16 20:08 ` [PATCH v2 03/12] aoe: Add a lock context annotation Bart Van Assche
2026-03-16 20:08 ` [PATCH v2 04/12] drbd: Make the lock context annotations compatible with Clang Bart Van Assche
2026-03-16 20:08 ` [PATCH v2 05/12] loop: Add lock context annotations Bart Van Assche
2026-03-17 14:05   ` Christoph Hellwig
2026-03-16 20:08 ` [PATCH v2 06/12] nbd: " Bart Van Assche
2026-03-16 20:08 ` [PATCH v2 07/12] null_blk: Add more " Bart Van Assche
2026-03-16 20:08 ` [PATCH v2 08/12] rbd: Add " Bart Van Assche
2026-03-16 20:08 ` [PATCH v2 09/12] ublk: Fix the " Bart Van Assche
2026-03-16 20:08 ` [PATCH v2 10/12] zloop: Add a " Bart Van Assche
2026-03-17 14:07   ` Christoph Hellwig
2026-03-16 20:08 ` [PATCH v2 11/12] zram: Add " Bart Van Assche
2026-03-17 14:08   ` Christoph Hellwig
2026-03-17 16:24     ` Bart Van Assche
2026-03-16 20:08 ` [PATCH v2 12/12] block: Enable lock context analysis for all block drivers Bart Van Assche
2026-03-17 14:08   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260317140448.GB2670@lst.de \
    --to=hch@lst.de \
    --cc=agruenba@redhat.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=bvanassche@acm.org \
    --cc=daniel@iogearbox.net \
    --cc=david@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=joannelkoong@gmail.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=mjguzik@gmail.com \
    --cc=nathan@kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox