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 A451A3EB0F7 for ; Tue, 30 Jun 2026 09:54:20 +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=1782813261; cv=none; b=AGhHeXyA1m3i6V3mQYlBUiLEsbcT76z6UQF2otlpDjrpswzbvb+26CMO1tjs24VclBCH7oonlutGbpN7gcb8IceRtqzaQcjNC7KwhOhzfSoKuk8e/DOspBI+ctjf04fFhNgkxOG0InbOkJ2dIbQh/ejcJ88PMjzt//XbvGSd7MA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782813261; c=relaxed/simple; bh=xMqrxiuMYWdzUpsMW3yHsSSF25GTOWwTF0IM4bZLvrI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=i3utTkxru/tjMT5Ep5mWx9Lyi29SLBLS42LamL1n2SVC1GDvMTNnN8e+w79KP0rPbmpQdiXzwvy4gGpCqdOMrv35njRFxGne3hqHAB6Vshgv7CQNjNkrWhMqF4dl6hZUVCwHuwaaQ1W0aYuUgSwMje62eAMgK/NlEzUSMpLl6rA= 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=HnsTWr8k; 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="HnsTWr8k" 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 65U9mu051843054; Tue, 30 Jun 2026 09:54:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=q1fDHd ni7BTZ74wL5TnS6E4zTb6vQ0gQiXc2ZDs+4cI=; b=HnsTWr8k407G47hZtG1zFm 2CVFYwyNfMHZUXweC7R1ETh2f9G4vemZ1mBVorgwB8aVnHyynt4unZ1kg1oKTEO8 G87NCs/WPmxA4dPnFF8KRBUKaW6Dw7fDakbLW9rJR2VGb+9Eav6ZK+xosP5EDtWk HwRWNkiWTmM25GiQuaUQoMfMbpUwwC26AdL4BC48xHbQkRYyvTQ8DQqQU7pNH/Vz mJfVNvu9udQ0la6hgaEiPxqprANYtvVsmkmMg/0ZDv91dM62rfis4g7fZs3AUHEu ragDvwny+unfwJqpHsUtFjTo5YfJ/4uWizpyd8pwL0IfhKXzyYlLnYDg84/Ku7mA == 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 4f26qfx02r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 Jun 2026 09:54:01 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 65U9ogS8026725; Tue, 30 Jun 2026 09:54:00 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4f2tbh9fj2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 30 Jun 2026 09:54:00 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 65U9rxMQ27984624 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Jun 2026 09:53:59 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9B44F58065; Tue, 30 Jun 2026 09:53:59 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49A255804B; Tue, 30 Jun 2026 09:53:56 +0000 (GMT) Received: from [9.43.78.19] (unknown [9.43.78.19]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Tue, 30 Jun 2026 09:53:55 +0000 (GMT) Message-ID: <3d7fd5f4-26b1-42a6-89c5-961ca53c51b1@linux.ibm.com> Date: Tue, 30 Jun 2026 15:23:54 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCHv2 07/17] nvme: add Clang context annotations for nvme_subsystem::lock To: Marco Elver , Christoph Hellwig Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, kbusch@kernel.org, sagi@grimberg.me, axboe@fb.com, bvanassche@acm.org, gjoyce@linux.ibm.com References: <20260614131541.2017845-1-nilay@linux.ibm.com> <20260614131541.2017845-8-nilay@linux.ibm.com> <20260626064335.GG10731@lst.de> <0f3add6e-4e2c-4656-ad82-e86e18f6fcb7@linux.ibm.com> <20260629124703.GB23417@lst.de> Content-Language: en-US From: Nilay Shroff In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Reinject: loops=2 maxloops=12 X-Authority-Analysis: v=2.4 cv=RYqgzVtv c=1 sm=1 tr=0 ts=6a439239 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=0mtnGOBys8VYx1yaTfMA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-Spam-Info: AW1haW4tMjYwNjMwMDA4OCBTYWx0ZWRfXy6gKIfsqYYx0 Bl4l8paTI+DPgvSLiOqPRi8GNPbTId9I3OoSaU1HyCcPBKQhHFhp1piFHqX66rGilAbmMs2toyI cDs5EfyD0uAjbpQ125FvSwqOfiKQJzM= X-Proofpoint-GUID: rYl_u7GcU5mW_8CCbmW5DLUVtqO4tRng X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjMwMDA4OCBTYWx0ZWRfX4jpJFrbUTxGi s6wnSvCk/wFJk2QSIvZAbi77bFksvLeyZnDfRSoH3yo7GiKSigq3OvDBXMxaOFDo7wiFWj7Hus9 lt/rqdycKGdfkGYyk+J7xpa09L7qtmRjikk8mNrxccqmImx5r9hmCJy9oeC77EUbogU72d+UNjp S+q4VBsJdMQfm7UEEfiHbSB094JK39oOwizL6M2UiI4khDgGwMBlZwSvkMpDgSMUo9SIh+cRGUt 8UFaYZiPB32FwHHkAQjepavkkIg0m23c0REC5x+2ivygVgntLyCYtlkuecDDkMv4a3B8xy3bIO9 E2J9F7691AsdumfXnYOEarK/NC4xKTslwpiiXo6JgKDr1zTMtU2yoyRcygsnUiKC5rU3kbznLq7 8Wi+yCh4eOXFff6/yiIFrXk6sLtdk5GEbMWVoHhXXQNoM+yBAPXtEGjdiPtXmcCjG7xNTc6woLM YKnRFrTRs12A261EkvA== X-Proofpoint-ORIG-GUID: w-eRV6Q1DuxrWGYutyz3Wr6v7mFJXoDU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-30_03,2026-06-26_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 impostorscore=0 malwarescore=0 spamscore=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606300088 On 6/30/26 4:42 AM, Marco Elver wrote: > On Mon, 29 Jun 2026 at 14:47, Christoph Hellwig wrote: >> >> On Fri, Jun 26, 2026 at 08:09:52PM +0530, Nilay Shroff wrote: >>>> >>> yes correct, but this one is tricky as the list has to be inited >>> with non-zero value. Another way to fix this is by adding >>> context_unsafe wrapper around INIT_LIST_HEAD(). Again overuse of >>> those unsafe wrappers hinders readability. >>> >>> Would it make sense to introduce a helper, e.g. INIT_LIST_HEAD_UNSAFE(), >>> that simply wraps INIT_LIST_HEAD() with context_unsafe()? It would document >>> that this should only be used in cases where the caller knows the object >>> has not yet been published and therefore no concurrent access is possible, >>> such as during object initialization. >> >> I'll leave that to Marco and other core people, but I think this >> would be a lot better than the current version. > > Initialization of guarded objects has gone through a few iterations, > so I don't want to open that can of worms again. I think the > infrastructure we have now provides various options (the scoped guard > machinery isn't the only way). You could just write: > > /* Initializes unpublished lock-guarded variables. */ > context_unsafe( > INIT_LIST_HEAD(&subsys->nsheads); > // ... other guarded var init in same block ... > ); > > context_unsafe() has a statement expression inside, so you can have > multiple statements in one context_unsafe() block. > And leave the mutex_init() where it was if you don't like the scoped_guard(). > > Although here you just have 1 INIT_LIST_HEAD() that needs that > treatment, so "context_unsafe(INIT_LIST_HEAD(...))" would do -- it's > just 9 chars more vs INIT_LIST_HEAD_UNSAFE(). And as soon as you have > several guarded variable initializations in a block, you can group > them as above. > > If you introduce INIT_LIST_HEAD_UNSAFE(), that'll create more ways to > initialize guarded variables. I'm not against it if none of the other > ways work for you, but expanding the API surface also incurs a > complexity cost. > > The simplest option is just adding __context_unsafe(init) as an > attribute to these init functions, although I see they do more than > just trivial initialization, so keeping context analysis enabled might > catch real bugs. Makes sense. I think grouping all unpublished guarded variable initializations under a single context_unsafe(...) block is a better approach than wrapping each initialization separately, which can quickly clutter the code. In fact, there are a few initialization functions in the NVMe driver where I annotated the entire function with __context_unsafe(). I agree it would be better to narrow the scope and annotate only the unpublished guarded variable initializations using a single context_unsafe(...) block. I'll update the next revision of the patchset accordingly and gather feedback on that approach. Let's see what others think. Thanks, --Nilay