public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Marco Elver <elver@google.com>, Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, Damien Le Moal <dlemoal@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>
Subject: Re: [PATCH v3 02/12] block/bdev: Annotate the blk_holder_ops callback invocations
Date: Fri, 10 Apr 2026 10:17:37 -0700	[thread overview]
Message-ID: <2e09806a-d5fe-4581-8024-906be7dca4de@acm.org> (raw)
In-Reply-To: <CANpmjNMUv5n2VrWGPBOzGg7-r6gf3hH6ZoJYtRsrntY8+_=fQg@mail.gmail.com>

On 4/9/26 6:27 AM, Marco Elver wrote:
> On Thu, 9 Apr 2026 at 08:42, Christoph Hellwig <hch@lst.de> wrote:
>> On Thu, Apr 02, 2026 at 11:39:34AM -0700, Bart Van Assche wrote:
>>> The four callback functions in blk_holder_ops all release the
>>> bd_holder_lock. Add __release() annotations where appropriate to prepare
>>> for enabling thread-safety analysis. Explicit __release() annotations have
>>> been added since Clang does not support adding a __releases() annotation
>>> to a function pointer.
>>
>> I have to say I still hate this with passion.  If we can't propagate
>> the lock context over function pointers it isn't ready for prime time
>> unfortunately, as much as I'm looking forward to it.
> 
> Let's see if we can land this: https://github.com/llvm/llvm-project/pull/191187
> 
> I think we'll be bumping min Clang version to 23 for context analysis,
> so hopefully it'll be included in Clang 23 and should solve the
> function pointer false positives.

That LLVM patch does not seem sufficient to address Christoph's concern.
If I apply that LLVM patch on my local LLVM tree, and if I apply the
following patch to the Linux kernel source tree:

diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index e354b771a8ad..81b8064b4612 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -1741,22 +1741,26 @@ void blkdev_show(struct seq_file *seqf, off_t 
offset);
  #endif

  struct blk_holder_ops {
-       void (*mark_dead)(struct block_device *bdev, bool surprise);
+       void (*mark_dead)(struct block_device *bdev, bool surprise)
+               __releases(&bdev->bd_holder_lock);

         /*
          * Sync the file system mounted on the block device.
          */
-       void (*sync)(struct block_device *bdev);
+       void (*sync)(struct block_device *bdev)
+               __releases(&bdev->bd_holder_lock);

         /*
          * Freeze the file system mounted on the block device.
          */
-       int (*freeze)(struct block_device *bdev);
+       int (*freeze)(struct block_device *bdev)
+               __releases(&bdev->bd_holder_lock);

         /*
          * Thaw the file system mounted on the block device.
          */
-       int (*thaw)(struct block_device *bdev);
+       int (*thaw)(struct block_device *bdev)
+               __releases(&bdev->bd_holder_lock);
  };

  /*

then the following errors appear while building the Linux kernel tree
with Clang:

In file included from block/blk-core.c:18:
./include/linux/blkdev.h:1745:15: error: use of undeclared identifier 'bdev'
  1745 |                 __releases(&bdev->bd_holder_lock);
       |                             ^~~~
./include/linux/blkdev.h:1751:15: error: use of undeclared identifier 'bdev'
  1751 |                 __releases(&bdev->bd_holder_lock);
       |                             ^~~~
./include/linux/blkdev.h:1757:15: error: use of undeclared identifier 'bdev'
  1757 |                 __releases(&bdev->bd_holder_lock);
       |                             ^~~~
./include/linux/blkdev.h:1763:15: error: use of undeclared identifier 'bdev'
  1763 |                 __releases(&bdev->bd_holder_lock);
       |                             ^~~~


Thanks,

Bart.

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

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-02 18:39 [PATCH v3 00/12] Enable lock context analysis Bart Van Assche
2026-04-02 18:39 ` [PATCH v3 01/12] block: Annotate the queue limits functions Bart Van Assche
2026-04-02 18:39 ` [PATCH v3 02/12] block/bdev: Annotate the blk_holder_ops callback invocations Bart Van Assche
2026-04-09  6:42   ` Christoph Hellwig
2026-04-09 13:27     ` Marco Elver
2026-04-10 17:17       ` Bart Van Assche [this message]
2026-04-10 22:43         ` Marco Elver
2026-04-10 23:44           ` Bart Van Assche
2026-04-02 18:39 ` [PATCH v3 03/12] block/cgroup: Split blkg_conf_prep() Bart Van Assche
2026-04-02 18:39 ` [PATCH v3 04/12] block/cgroup: Split blkg_conf_exit() Bart Van Assche
2026-04-02 18:39 ` [PATCH v3 05/12] block/cgroup: Inline blkg_conf_{open,close}_bdev_frozen() Bart Van Assche
2026-04-02 18:39 ` [PATCH v3 06/12] block/crypto: Annotate the crypto functions Bart Van Assche
2026-04-02 18:39 ` [PATCH v3 07/12] block/blk-iocost: Add lock context annotations Bart Van Assche
2026-04-02 18:39 ` [PATCH v3 08/12] block/blk-mq-debugfs: Improve " Bart Van Assche
2026-04-02 18:39 ` [PATCH v3 09/12] block/blk-zoned: Refactor blkdev_zone_mgmt_ioctl() Bart Van Assche
2026-04-02 18:39 ` [PATCH v3 10/12] block/kyber: Make the lock context annotations compatible with Clang Bart Van Assche
2026-04-02 18:39 ` [PATCH v3 11/12] block/mq-deadline: " Bart Van Assche
2026-04-02 18:39 ` [PATCH v3 12/12] block: Enable lock context analysis Bart Van Assche
2026-04-03  0:19 ` [PATCH v3 00/12] " Chaitanya Kulkarni

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=2e09806a-d5fe-4581-8024-906be7dca4de@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=dlemoal@kernel.org \
    --cc=elver@google.com \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=nathan@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