Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=199.89.1.16 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796263257; b=dZBKv+Go+es2yQy7uvAKQx6JmRwuWXelqSmSXyaRQSEPlBnaaMqwWhqGLsO09LMz3Gbn iK8B+0wcddk4/s3ovkqk2eOLr/OPRuDKy+kOUG631ELZkfAszTNU2/XK01/vtTraNh6bB lLNBeo+0qyHvRrg9HI0JWVRInXdyk2w12bCsr0vTLceNIE1av9guSi+rBWWqSuoEAMXFu PPsTCmtC2HKr88L7XCSZ9RvQNPmxm+T14QTfvhi7ptAiZNRjgJqu6zobcm1ygpdIcKTVE aHaINpZJqUT1bYpczVlQpdjiXPxCaIW9JhMbF5PwuuLNlG7sePdgsvUciIRNo1vduFA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796263257; h=DMARC-Filter:Received:DKIM-Signature:X-Virus-Scanned:Received: Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=V13ytAtGeI7tSPJN0+gfc1005ZoaqoLzQwLAvMfXlhI=; b=1MhufBXlEndJ7B0Xeh+8i0o1v7D6rLMbzAlQx9Uuh38phwAK1SoeHX4v+PjVFjMbLkqX i56ml01BQmXI4QScVkU/hnShRrjBCAu5jN89Qf1Nfi5hcCA1toe1Xyz2IrUGRXuZSDo60 BVu8qRV5cizeBjGFZ26yO4p523R5fcfXIxG2BuBPWon9KkhEEpJLhT0TWQHRyi+aJNtiy cdLUQbXGv43pplsm83nRHyLeXmpJH6/ma4abwkat/5iY1HCVrkEaDBieUJzvCoBbfucIN q/ShF5yFuLB1ueW4q2UwSeDNK0Ev0syERcrP23sM6k7JPUPANroesy8az9ArubTHdxA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=acm.org; spf=pass smtp.mailfrom=acm.org; dkim=pass header.d=acm.org header.i=@acm.org header.a=rsa-sha256 header.s=mr01 header.b=A3kV8gEH; arc=none smtp.remote-ip=199.89.1.16 Received: from 013.lax.mailroute.net (013.lax.mailroute.net [199.89.1.16]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44183606A332 for ; Thu, 3 Dec 2026 02:00:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 44183606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=acm.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=acm.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=acm.org header.i=@acm.org header.a=rsa-sha256 header.s=mr01 header.b=A3kV8gEH Received: from localhost (localhost [127.0.0.1]) by 013.lax.mailroute.net (Postfix) with ESMTP id 4jfyX86NDWzlfwHP; Thu, 3 Dec 2026 02:00:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=acm.org; h= content-transfer-encoding:mime-version:x-mailer:message-id:date :date:subject:subject:from:from:received:received; s=mr01; t= 1796263252; x=1798855253; bh=V13ytAtGeI7tSPJN0+gfc1005ZoaqoLzQwL AvMfXlhI=; b=A3kV8gEHl0ZMVjE95kU3d+//NGSNfh7i+yOiEoAqLtAf1nU1+nT EkZTwto1cCsBC4SW55qcYo73AV/vU4RuibqkE3XFMQRKTL84avD5GvhzT4k1pKMs lBX/vYSjrT3T2XY98MQa7tsCluZDDnWv+HcH1i8HcEIARCrMud96LUu1tM3bx6xU mHELvNW9HVi/Yjo7bzhWKxfOj9BwEIUiheyn8RidFKlv60JZU2wl12sjBvGrAoRl T3iebqZybXJypVFZDBlFmY1o3OxjUL5UwLHP6bDhQ3W1r8ZNi1Q5gPj6fycGt+xF HdIG+zA5TzQxqYr6Lv3n9qUBBa26GGgaOEQ== X-Virus-Scanned: by MailRoute Received: from 013.lax.mailroute.net ([127.0.0.1]) by localhost (013.lax [127.0.0.1]) (mroute_mailscanner, port 10029) with LMTP id h7S4ON07Xmst; Thu, 3 Dec 2026 02:00:52 +0000 (UTC) Received: from bvanassche.c.googlers.com.com (57.237.82.34.bc.googleusercontent.com [34.82.237.57]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bvanassche@acm.org) by 013.lax.mailroute.net (Postfix) with ESMTPSA id 4jfyX3722Vzlfvpx; Thu, 3 Dec 2026 02:00:51 +0000 (UTC) From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Damien Le Moal , Bart Van Assche Subject: [PATCH 00/52] block: Add lock context annotations Date: Wed, 2 Dec 2026 17:59:23 -0800 Message-ID: X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Jens, Deriving from the block layer source code which synchronization object protects which member variable and which functions is nontrivial. This pa= tch series documents this in such a way that the documentation can be verifie= d by the Clang compiler. This patch series adds __must_hold(), __guarded_by= () and related annotations to the block layer core, the blk-cgroup policies, the I/O schedulers, sed-opal, the partition code and the loop driver. Wi= th these annotations and with CONFIG_WARN_CONTEXT_ANALYSIS=3Dy, Clang verifi= es at compile time that the annotated functions are only called and that the annotated variables and structure members are only accessed with the appropriate lock held. See also Documentation/dev-tools/context-analysis.rst. This series is organized as follows: - Patch 1 fixes a bug that was found while adding annotations: deadline_##name##_next_rq_show() walks an RB-tree and prints a request without holding dd->lock. This patch does not depend on any other patch in this series. - Patch 8 replaces an unreachable branch in bfq_exit_icq() with WARN_ON_ONCE(). - Patches 2-4, 9, 10, 12, 19, 22, 26, 31, 45 and 47 prepare for adding annotations. Most of these patches pass a pointer explicitly to a function instead of deriving it from another argument because Clang cannot determine that e.g. q->debugfs_mutex and hctx->queue->debugfs_mutex are the same mutex. No functional change is intended by any of these patches. - Patch 50 enables context analysis for block/partitions/. - The other patches add lock context annotations. Reads that happen on purpose without holding the lock that protects the data, e.g. in debugfs code, have been marked with data_race() or context_unsafe(). This series has been prepared against your for-next branch (commit 51d9c0564bb3) and has been compile-tested as follows on x86_64: - Each patch with Clang 24, CONFIG_WARN_CONTEXT_ANALYSIS=3Dy, CONFIG_WERROR=3Dy and W=3D1 (block/ and drivers/block/loop.o). - The entire series with gcc 15 and W=3D1 to verify that the kernel still builds without warnings if context analysis is not available. - It has been verified that the blktests tests still pass. Please consider this patch series for the next merge window. Thanks, Bart. Bart Van Assche (52): mq-deadline: Hold dd->lock in deadline_##name##_next_rq_show() mq-deadline: Access per_prio state in dd_exit_sched() with dd->lock held mq-deadline: Compute &dd->per_prio[prio] with dd->lock held mq-deadline: Mark the racy debugfs batching and starved reads mq-deadline: Add lock context annotations mq-deadline: Add __guarded_by() annotations badblocks: Add lock context annotations for bb->lock block, bfq: Replace an unreachable branch in bfq_exit_icq() block, bfq: Fold _bfq_exit_icq() into bfq_exit_icq() block, bfq: Pass bfqd to functions that are called with bfqd->lock held block, bfq: Add lock context annotations blk-cgroup: Pass q to blkg_create() and blkg_lookup_create() blk-cgroup: Add lock context annotations blk-cgroup: Annotate all_blkcgs with LIST_HEAD_GUARDED() blk-crypto: Add lock context annotations block: Add __must_hold() annotations for fq->mq_flush_lock block: Annotate struct blk_flush_queue members with __guarded_by() blk-iocost: Add lock context annotations blk-iocost: Pass the ioc pointer to hweight_after_donation() blk-iocost: Annotate struct ioc fields protected by ioc->lock blk-iolatency: Add a __must_hold() annotation for lat_info->lock blk-iolatency: Use WRITE_ONCE() in iolatency_clear_scaling() blk-iolatency: Annotate child_latency_info with __guarded_by() blk-mq: Add lock context annotations blk-mq: Annotate blk_mq_ctx::rq_lists with __guarded_by() blk-mq-debugfs: Pass q to blk_mq_debugfs_unregister_sched_hctx() blk-mq-debugfs: Add __must_hold() annotations for q->debugfs_mutex blk-mq-sched: Add lock context annotations blk-zoned: Add lock context annotations blk-zoned: Annotate struct blk_zone_wplug members with __guarded_by() block: Pass the gendisk pointer explicitly to several bdev.c functions block: Add __must_hold() annotations in block/bdev.c block: Annotate the block_device_operations open and release callbacks block: Add __must_hold() annotations for bdev_lock block: Add lock context annotations in block/elevator.c block: Annotate elv_list with LIST_HEAD_GUARDED() block: Annotate the queue_limits_*() definitions in blk-settings.c block: Add __must_hold() annotations for the IA ranges sysfs functions block: Add a __must_hold() annotation for blk_holder_mutex block: Add a __must_hold() annotation for bio_slab_lock block: Annotate bio_slabs and slab_ref with __guarded_by() sed-opal: Add __must_hold() annotations for dev->dev_lock block: Annotate the disk_events list with LIST_HEAD_GUARDED() block: Annotate struct disk_events members with __guarded_by() block: Simplify the major_names[] traversal in blk_probe_dev() block: Annotate major_names with __guarded_by() loop: Pass disk instead of lo to __loop_clr_fd() loop: Annotate lo_release() and __loop_clr_fd() with __must_hold() block: partitions: Add __must_hold() annotations block: partitions: Enable lock context analysis kyber: Add __must_hold() annotations for khd->lock kyber: Add __guarded_by() annotations to struct kyber_hctx_data block/badblocks.c | 16 +++++++ block/bdev.c | 87 +++++++++++++++++++++++-------------- block/bfq-cgroup.c | 23 +++++++--- block/bfq-iosched.c | 73 +++++++++++++------------------ block/bfq-iosched.h | 17 +++++--- block/bio.c | 9 ++-- block/blk-cgroup.c | 32 ++++++++------ block/blk-crypto-fallback.c | 1 + block/blk-crypto-profile.c | 2 + block/blk-flush.c | 13 +++--- block/blk-ia-ranges.c | 2 + block/blk-iocost.c | 68 +++++++++++++++++++---------- block/blk-iolatency.c | 20 ++++++--- block/blk-mq-debugfs.c | 25 ++++++++--- block/blk-mq-debugfs.h | 40 ++++++++++++----- block/blk-mq-sched.c | 6 ++- block/blk-mq-sched.h | 12 +++-- block/blk-mq.c | 22 ++++++++-- block/blk-mq.h | 5 ++- block/blk-settings.c | 3 ++ block/blk-zoned.c | 62 ++++++++++++++++++-------- block/blk.h | 24 ++++++---- block/disk-events.c | 36 ++++++++++----- block/elevator.c | 5 ++- block/genhd.c | 15 ++++--- block/holder.c | 1 + block/kyber-iosched.c | 30 ++++++++----- block/mq-deadline.c | 87 ++++++++++++++++++++++++------------- block/partitions/Makefile | 2 + block/partitions/core.c | 8 ++-- block/sed-opal.c | 17 +++++++- drivers/block/loop.c | 17 +++++--- include/linux/blkdev.h | 9 ++-- 33 files changed, 523 insertions(+), 266 deletions(-)