From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796311447; b=BBIIo/x6HPlH2wPqC6/pEcNjaqiIuSGLGg5gnZgxd1b1DgjlIA3+kirRQqzvMi1fqPQR ZfVBxwJ0y3mKHEyIUo7P9My8FXzW+rl2eZB7W4UZmGnx5ULIThZF5XqoslGVbZ7+26DAa 8mufQcOyJhHllXQaGNyme9+QuWOfc0Umd181bdeqb4wkzDGH/Ki9ytf95uHZv01PbxOqP +XP0ohrIyZsShShn0aXLoNhD2IQ8POkWPXi3G1XMos4D2ACr3mcs9ZaT8gLaIyLQyjjpL rYhIBjECzthWzUlPMbT4lhKoEUR8Jmx7qG/cYvXasCoRH+nhIHTWMmMip/EOGP1fNUQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796311447; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-TM-AS-GCONF:X-Proofpoint-Reinject: X-Proofpoint-GUID:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Authority-Analysis: X-Proofpoint-ORIG-GUID:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=xoSx2HkH5ZVVV8O3vffNCx6PS6yM+MMYU43pvpV595s=; b=2dVcooZmtFJSJI3tU+69rkHQcoVWPPEJzI8pAOIkjsB6OluEmmNn39PeOrd/1Hqwuqa0 KTz6le6oDdbpSvbqHJ1SPp/wUmZKflsy4Ej6nuLyrPMxqx0R9oUi0W+PA7w29WtSAli8R Rr8hId+4eog+RDwMYSIPwc0m0hN8zr7AMr0bPPWGbj8F2gUhuTiA6qpTv28bvgbKSimxh KAtnERMML7/b35KAAcZamqZruuSHQ7YkTUeMk2t7jjgnAgNU4cRyus4rt10XxTD9mJAAl wRzrIpRYkLfHESxb8sBIOjjrH/jTV4impUpQ8GwXcx0I7CTjyPGND9DaFohp8QCUOPA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=kuFGEYkK; arc=none smtp.remote-ip=148.163.156.1 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 A5568606A322 for ; Thu, 3 Dec 2026 15:24:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A5568606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=kuFGEYkK Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B3F4wnE3722998; Thu, 3 Dec 2026 15:23:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=xoSx2HkH5ZVVV8O3v ffNCx6PS6yM+MMYU43pvpV595s=; b=kuFGEYkKCnE1mlN1Vqvwgs7pmJIt7LXtj Q7Mn0gpto9T6OPRKOF5wCfHDdKh5/WN1cWroS8DJrEz8VUp85plIhmZSp3geny2S oWVhYp9/sNsY+ykphZP93Nu75A09AHV+dLyV1mInZvXUQsGWoS5DcSDU92ZR6Lgv csKuT9Roeq1KVaeZ/8kYy3VHLrEZz2q4lt54HoMyf+OGD7S2oC7LhnIulOWRlxLg YecjlWr/4lGBmjK3rWKTaE/VWhYJlNV7yz5b76Djm7our+R6my295aypoPN82o07 e5WlRESPGCSikRHsjejAFfVlqjEpiji6d17eX5dRar6qp0lxAbrJA== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pp67kkr-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 03 Dec 2026 15:23:47 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B3F4Xk71785196; Thu, 3 Dec 2026 15:23:46 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4ja2uv8e8s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 03 Dec 2026 15:23:46 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B3FNi9M6685208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 3 Dec 2026 15:23:45 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C9A8C58062; Thu, 3 Dec 2026 15:23:44 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CE1F45806B; Thu, 3 Dec 2026 15:23:40 +0000 (GMT) Received: from li-a84c74cc-2b13-11b2-a85c-acdd023f0674.ibm.com.com (unknown [9.61.163.177]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 3 Dec 2026 15:23:40 +0000 (GMT) From: Nilay Shroff To: axboe@kernel.dk, mt4022@columbia.edu, hch@lst.de, mkhalfella@purestorage.com, bvanassche@acm.org, kbusch@kernel.org, josef@toxicpanda.com, tom.leiming@gmail.com, tz2294@columbia.edu, gjoyce@linux.ibm.com Cc: linux-block@vger.kernel.org, Nilay Shroff Subject: [PATCH 3/3] block: add context annotations for tag_list_lock and quiesce_lock Date: Thu, 3 Dec 2026 20:52:39 +0530 Message-ID: <20261203152318.654390-8-nilay@linux.ibm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261203152318.654390-5-nilay@linux.ibm.com> References: <20261203152318.654390-5-nilay@linux.ibm.com> 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: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-GUID: p4IJxb3d-Igvyb4Y5uZIGIGmFRYeFhII X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAzMDA2MCBTYWx0ZWRfX2c9jmHURQjP/ OiHEolMo/82bRce8pSd6F1gXw2O35TKpuwpv1GICduWC+WL8hOq+9Vyxp2kg4gl7HGK6pScGZwa nVBPz64KW72w6alkuyoLxiRYXrxoZzM= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAzMDA2MCBTYWx0ZWRfX9wXfo1r7tpJc /cK5D0pv5t3JfN4RkCQTCnR4aBgynAhesEE0/wx51U/bbC+5WL++CRxOU1GEVC3h4JtPdEo8vkr HH8yK0TMIurVfqr+kExeOUgov2sRPGNm0+b5q0fyC/919Z0UPJzag38U3HyoBbp8xPgRLnDeT+V 1Txk0qUYLtrL8dHJZdf1j8HbjtaYC712LgKh6YWPQsWvj5ShrJVVrQtA0TmntBDVXACXOVU8FGL Uy2fZpAZ58INRgFu2KD3ua3PJoH5MiMf/iFTN5Pnh/MehOwZLpy4dw1SX/lyrgXEiZ5itAbcOro SQW8PXMrdrJ6aqHzUwQdKiQSwKsI0OCsqOnm8vb5q5PSwnGp2a5d0Cn+raUPoCgzqRaLS1n6qaq WQefKpa+EBMckmT0TbTHTRZSVW5tCSfFP3B40UKigRwLiTHtJ5783wlnYYOPaHJO9DfhaTJSb5a sZedR++XuV30KuRJNpA== X-Authority-Analysis: v=2.4 cv=Ae8kjHXG c=1 sm=1 tr=0 ts=6b118983 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=DZJ9PYWjfXMIPRd732cA:9 X-Proofpoint-ORIG-GUID: 2iaHvlXLHVQNE28NtmEV9T8pzhyiBmpT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-03_04,2026-12-03_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612030060 Access to ->tag_list is protected by either tag_list_lock or quiesce_lock for reads, and by both locks for writes. Annotate ->tag_list using __guarded_by(&tag_list_lock, &quiesce_lock) to document this locking requirement. Similarly, all accesses to ->quiesce_depth are protected by quiesce_lock, so annotate it using __guarded_by(&quiesce_lock). Additionally, annotate blk_mq_alloc_sched_ctx_batch(), blk_mq_alloc_sched_res_batch(), blk_mq_update_tag_set_shared(), blk_mq_del_queue_tag_set(), blk_mq_add_queue_tag_set(), and __blk_mq_update_nr_hw_queues() with __must_hold(&tag_list_lock) to document that tag_list_lock must be held when these functions are called. Finally, mark blk_mq_alloc_tag_set() with __context_unsafe() because it initializes lock-guarded variables before they are published and accessed by other contexts. This avoids false positive warnings from the context analyzer during initialization. Signed-off-by: Nilay Shroff --- block/blk-mq-sched.h | 6 ++++-- block/blk-mq.c | 4 ++++ include/linux/blk-mq.h | 9 ++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/block/blk-mq-sched.h b/block/blk-mq-sched.h index 50e19f5ca90a..5f3583fdfd47 100644 --- a/block/blk-mq-sched.h +++ b/block/blk-mq-sched.h @@ -30,9 +30,11 @@ int blk_mq_alloc_sched_res(struct request_queue *q, struct elevator_resources *res, unsigned int nr_hw_queues); int blk_mq_alloc_sched_res_batch(struct xarray *elv_tbl, - struct blk_mq_tag_set *set, unsigned int nr_hw_queues); + struct blk_mq_tag_set *set, unsigned int nr_hw_queues) + __must_hold(&set->tag_list_lock); int blk_mq_alloc_sched_ctx_batch(struct xarray *elv_tbl, - struct blk_mq_tag_set *set); + struct blk_mq_tag_set *set) + __must_hold(&set->tag_list_lock); void blk_mq_free_sched_ctx_batch(struct xarray *elv_tbl); void blk_mq_free_sched_tags(struct elevator_tags *et, struct blk_mq_tag_set *set); diff --git a/block/blk-mq.c b/block/blk-mq.c index b3d26f0ec1a7..cd4fb994cfda 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -4331,6 +4331,7 @@ static void queue_set_hctx_shared(struct request_queue *q, bool shared) static void blk_mq_update_tag_set_shared(struct blk_mq_tag_set *set, bool shared) + __must_hold(&set->tag_list_lock) { struct request_queue *q; unsigned int memflags; @@ -4345,6 +4346,7 @@ static void blk_mq_update_tag_set_shared(struct blk_mq_tag_set *set, } static void blk_mq_del_queue_tag_set(struct request_queue *q) + __must_hold(&q->tag_set->tag_list_lock) { struct blk_mq_tag_set *set = q->tag_set; @@ -4363,6 +4365,7 @@ static void blk_mq_del_queue_tag_set(struct request_queue *q) static void blk_mq_add_queue_tag_set(struct blk_mq_tag_set *set, struct request_queue *q) + __must_hold(&set->tag_list_lock) { unsigned int i; @@ -5170,6 +5173,7 @@ static int blk_mq_elv_switch_none(struct request_queue *q, static void __blk_mq_update_nr_hw_queues(struct blk_mq_tag_set *set, int nr_hw_queues) + __must_hold(&set->tag_list_lock) { struct request_queue *q; int prev_nr_hw_queues = set->nr_hw_queues; diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 3c9667854c46..b085328cbc73 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -552,9 +552,11 @@ struct blk_mq_tag_set { struct blk_mq_tags *shared_tags; struct mutex tag_list_lock; - struct list_head tag_list; + struct list_head tag_list + __guarded_by(&tag_list_lock, &quiesce_lock); spinlock_t quiesce_lock; - unsigned int quiesce_depth; + unsigned int quiesce_depth + __guarded_by(&quiesce_lock); struct srcu_struct *srcu; struct rw_semaphore update_nr_hwq_lock; @@ -745,7 +747,8 @@ int blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, struct request_queue *q); void blk_mq_destroy_queue(struct request_queue *); -int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set); +int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set) + __context_unsafe("/* initialize unpublished/lock-guarded variables */"); int blk_mq_alloc_sq_tag_set(struct blk_mq_tag_set *set, const struct blk_mq_ops *ops, unsigned int queue_depth, unsigned int set_flags); -- 2.53.0