From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 290AF27EFE9 for ; Mon, 6 Jul 2026 14:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783347349; cv=none; b=tr7Fl46wKJJYM8wijt3Pr9QbKsx+nBkmYMYLQ8aY8Cl4929ZhkV0a7IVQ2tXCBbEc1KjBku+Nkuoed9ld88wOhGz1leDTtZhEHlJe7+FYAOprW74Gdo52eGOeCoEvgAKbiDpoXYivEr10n44ynK5il5C4VBmgfjznjsJA2IrJ1Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783347349; c=relaxed/simple; bh=DBBLYUsJNNZnKOVoCglAcdUkLa7uYbTSKpuxzTr9nRc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=N71uwQySxWWeBTXNAHE1UAPQ5BY2n2A2KxkHBpogpDzWGtlirgZS9KIkimkiSVF6Fjltm44ToBoyPU12jf+iDiIuNAWZFMyTFAftrjse9fbiuYtiX6VzQ4P7hFYDJt14DIrDZ/Tc1JnRRoVJReayINz89hJNAdYHNmRObEBOhuM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=OjHCcB6f; arc=none smtp.client-ip=148.163.156.1 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.b="OjHCcB6f" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 666BIEoN318854; Mon, 6 Jul 2026 14:15:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=pp1; bh=x50HAsiA3XtMMUoADGJon8UIxcTtMr1Xv9a2j0LKQ g0=; b=OjHCcB6fZnNf/QOmjdJHoqXm/ymJPUoN3mlxlduc9CTlIItggHf9lyQEK 0N5G4eFaM74lIMPshOX/enlBc56MAjEiCbofjbqiHbQRt70zlKgvVEnxfakKWdcH Zo4p8VShlUOfNu9pKt2Owa+M0+b/zluDlQdZHBh+oNbfu13m3n9kLOzH8SYTJmff tkwP2qMaj+ML/4t74go2oL3M7dHKA9uMRx3dN3WTQOSyhKv+k6yiipur0+UHI8Kc aeWBY44PgNVI4Jq9Ol2QlWYF6JpH4zHBx1DWgCIjsw4TDfoEUO/wCJKpaHVCk4ut gPmU8Lh8gx418byoG6S1Ipj8Jtfhg== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4f6suqhqr6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Jul 2026 14:15:23 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 666E4cIR018959; Mon, 6 Jul 2026 14:15:22 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4f7cgpx41v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Jul 2026 14:15:22 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 666EFInw51380488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 6 Jul 2026 14:15:18 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9379420043; Mon, 6 Jul 2026 14:15:18 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5505920040; Mon, 6 Jul 2026 14:15:16 +0000 (GMT) Received: from li-a84c74cc-2b13-11b2-a85c-acdd023f0674.bl1-in.ibm.com (unknown [9.123.7.57]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 6 Jul 2026 14:15:16 +0000 (GMT) From: Nilay Shroff To: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Cc: hch@lst.de, elver@google.com, kbusch@kernel.org, sagi@grimberg.me, axboe@fb.com, bvanassche@acm.org, gjoyce@linux.ibm.com, Nilay Shroff Subject: [PATCH v3 00/18] Support Clang context analysis for NVMe host drivers Date: Mon, 6 Jul 2026 19:44:02 +0530 Message-ID: <20260706141452.3008233-1-nilay@linux.ibm.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzA2MDE0MSBTYWx0ZWRfX9uoG55BlACUy f8TavTfLKHfJ/H6SIhysW21sOVP6GFl46owPnwUwhog5p/TxlgqxXBYRLRIS8EU7+uplv135BaI jfyiD+xb9Ur8LJRco3UuX6loaPAt/wE= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzA2MDE0MSBTYWx0ZWRfXzwOyAY9K9VW5 QwfKfDdpDNMEYyBZkZplJaofxx4LE7Bm4XnLbUPjqudzIib2+gCHY5YfsZbToauWAh49YVGMNN4 X1GFgG1AOOPug8jzJ9ueVzpZYMRsV5KLxc9iFCR/Jo17hHG1cMIg2Z3aaB+LOM2mxKaaQPDVW/o /3rjzyEcz8bkiHy7229DXGubuufjPPVYjlt8xohaih6HLnoYjbzTW+mWmXT0vCGHKFs25QRo7gs 8b6GtjCehLVwJdH2Ojx3siPhZfApXcn9yiSg+Fh6YtOLgygdT5FFQNI0MFivEVv0D6xkf5xIfy4 0mFJhwFteeuQ4D5mhMKStkmOXfl73qV6v55SsUtao5qI9xrkHp1IA3DKPPZ6z3Xja1JOCiPHxDP 5bY4BuX5V1SBm1vt3cXQLDaasfAQUmTrSinHAq0HDhAQ4krpu73YyNiXbBp9NBWbM2DYpKJSXco vFgN/PABvWevEYGnQ+g== X-Proofpoint-GUID: pmNCK-6tfWLD1uMy1CVuKN9yFJj7r20d X-Authority-Analysis: v=2.4 cv=Oot/DS/t c=1 sm=1 tr=0 ts=6a4bb87b cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=RAioF0-LDSMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VwQbUJbxAAAA:8 a=1XWaLZrsAAAA:8 a=VnNF1IyMAAAA:8 a=yJd4khT4T4pqtWizPYcA:9 X-Proofpoint-ORIG-GUID: 39AYPx1qNkN93-bnQ7GL5iXg24Xv1CJs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-06_01,2026-07-06_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 phishscore=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607060141 This series adds support for Clang's context analysis to the NVMe host drivers. Recent work[1] by Marco Elver introduced infrastructure for lock context analysis in the kernel, allowing Clang to verify locking requirements at compile time through various annotations. This series build on top of that infrastructure by annotating the NVMe host drivers with the appropriate locking requirements and by addressing warnings reported by the analyzer. The series was built and tested with LLVM/Clang 23.x and enables the NVMe host drivers to build cleanly with CONFIG_CONTEXT_ANALYSIS enabled. Support for the NVMe target drivers will be addressed separately. As usual, comments/feedback/suggestions are most welcome! Thanks! [1] https://lore.kernel.org/lkml/20251219154418.3592607-1-elver@google.com/ Changes from v2: - removed "Clang" from each commit subject line (hch) - for zero-initialized struct bio_list_init() is redundant and also to suppress false-positive context analysis warning for a list variable guarded by lock, remove bio_list_init(&head->requeue_list) from nvme_mpath_alloc_disk() (hch) - get rid off wrapping rcu_access_pointer() using context_unsafe() as the access to __rcu_guarded pointer using helper rcu_access_pointer() should be implicitly safe (hch, Marco, Paul) - wrap INIT_LIST_HEAD() under context_unsafe(...) instead of interleaving it under scoped_guard(...) to suppress context analysis warning while initializing subsys->nsheads (hch) - initializing head->delayed_removal_secs from nvme_mpath_alloc_disk() is redudnamt as struct nvme_ns_head is zero allocated. This also helps avoid false positive conext analysis warning (hch) - introduce LIST_HEAD_GUARDED(_name, _lock) and use it for guarding a list (hch) - dropped context annotations for nvme_queue::cq_poll_lock as this requires a annotation which could support guarding multiple valid synchronization mechanisms for a single object, which is ,as of today, not yet avalilable (hch) - new patch in the series from Marco Elver , which annotates list_empty_careful() using __context_unsafe - context_unsafe() has a statement expression inside so group multiple scope guarded variables before those are publsihed under context_unsafe(...) where possible (Marco) Link to v2: https://lore.kernel.org/all/20260614131541.2017845-1-nilay@linux.ibm.com/ Changes from v1: - replace guard() with scoped_guard() for guarding request_list (Bart) - annotate nvme_alloc_ns_head() using __must_hold(&ctrl->subsys->lock) (Sashiko) - guard nvme_queue::sq_cmds using nvme_queue::sq_lock - annotate nvme_cqe_pending() using context_unsafe in nvme_poll() (Keith) - Split patch #13 and #14 to separate the context annotation change from functionality change (Bart) Marco Elver (1): list: Permit context-unguarded access with list_empty_careful() Nilay Shroff (17): nvme: update nvme_passthru_end() signature nvme: add context annotations for nvme_passthru_{start|stop} nvme: add context annotations for nvme_ns_head::srcu nvme: add context annotations for nvme_ns_head::requeue_list nvme: add context annotations for nvme_ns_head::current_path nvme: add context annotations for nvme_dev::shutdown_lock nvme: add context annotations for nvme_subsystem::lock nvme: add context annotations for nvme_ctrl::ana_lock list: introduce LIST_HEAD_GUARDED nvme: add context annotations for nvme_subsystems_lock nvme: add context annotations in fabric.c nvme: add context annotations for nvme_queue::sq_lock nvme: add context annotations in rdma.c nvme: fix context analysis warning in rdma.c nvme: add context annotations in tcp.c nvme: fix context analysis warning in tcp.c nvme: enable context analysis support for nvme host driver drivers/nvme/host/Makefile | 1 + drivers/nvme/host/core.c | 20 ++++++++++++---- drivers/nvme/host/fabrics.c | 4 ++-- drivers/nvme/host/ioctl.c | 2 +- drivers/nvme/host/multipath.c | 7 ++++-- drivers/nvme/host/nvme.h | 44 ++++++++++++++++++++++++----------- drivers/nvme/host/pci.c | 28 +++++++++++++++++----- drivers/nvme/host/rdma.c | 25 ++++++++++++-------- drivers/nvme/host/tcp.c | 15 ++++++++---- include/linux/list.h | 9 +++++++ 10 files changed, 110 insertions(+), 45 deletions(-) -- 2.53.0