From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 03312409613 for ; Mon, 6 Jul 2026 14:16:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783347375; cv=none; b=JEOQ+QYYNkL5JgWUDo6LSXKnFXf9KM8tCMa/fgSG+rZUFWp2gTnKiCRIGcEw81CWqad4pA7FSpHsZNS9L1YY6INfBGuuR5vuJwDoUby8WqQMWyI0mi9kk3wzMDlXkgamDhLi9jB4N585LkZEjElDyOwl8cqHiRf4hgKtalt0nBQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783347375; c=relaxed/simple; bh=HRlOxMV+beYyRSkIL3V7cr+bkZAVJOjtWwkkDcLSmZ4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lP7A9I3sLnrpXXr47WmCx2rLGYhorzv614ix576OLP2JRNtKPssm+MwIgGrBWi6yg/wnYwsxDFq+xs9CwvD4SpldPUoF/2RORxFFKO9jkdNk/FhcIyYNja01BpJfDdD3Tz3X8z2zKT1xK22QJYaJIx/el7m8yG5hxc2/+6TxKqU= 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=msyUxuW3; arc=none smtp.client-ip=148.163.158.5 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="msyUxuW3" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 666BIRRr041311; Mon, 6 Jul 2026 14:16:03 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=3J85hvmz2E9i8XDjg Z5G474hTVS6CIbxarQmENkbdAE=; b=msyUxuW3BUrYoy82miov/k/76U018xkDP c64ENbT6NvQGnaCGnxYQULHrMCPqqm+tOxLxYelMNrbxJUQT6sxp1+DpqSXFnsAF pTn17xNtExytNymZD8vel5RufTwp6eR/rQoZjw/O51sGeyYel8Xzuc022BLlR72j 9t44WQu1K0CTrKBx3rq33FSM/l2rcaVhGmsvfFt8CPokF4lS2yH+r4AxAu8dCSTA rgRusVyEqqncByWiOslpk3DQojUh3h6NtFDLd2AnMKfvw8Rr1OQ8lgfT1CMYitpT 6mG0IFjrx3lCOD7y2a01u3pj+uGe9jLytO6Rk4Qwf2ysny1LW8yew== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4f6qkn9x2c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Jul 2026 14:16:02 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.7/8.18.1.7) with ESMTP id 666E4dlV015309; Mon, 6 Jul 2026 14:16:02 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4f7eqfwp9p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Jul 2026 14:16:02 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 666EFwax46531006 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 6 Jul 2026 14:15:58 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6ED9720043; Mon, 6 Jul 2026 14:15:58 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B6DC20040; Mon, 6 Jul 2026 14:15:56 +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:56 +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 09/18] list: introduce LIST_HEAD_GUARDED Date: Mon, 6 Jul 2026 19:44:11 +0530 Message-ID: <20260706141452.3008233-10-nilay@linux.ibm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260706141452.3008233-1-nilay@linux.ibm.com> References: <20260706141452.3008233-1-nilay@linux.ibm.com> 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-Authority-Analysis: v=2.4 cv=Q/XiJY2a c=1 sm=1 tr=0 ts=6a4bb8a3 cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=RAioF0-LDSMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=yEdB1FNURbGifd-vTGUA:9 X-Proofpoint-GUID: eZ5ptmhWKkxdJpQLwFUMWjw-EJY4FLG6 X-Proofpoint-ORIG-GUID: NnJjfAx78N0ig--vMUQxXrBcx_aCD_le X-Proofpoint-Spam-Info: AW1haW4tMjYwNzA2MDE0MSBTYWx0ZWRfX0DdfheCFAAZC wrePBjcdpXMLL0+ilkmAEdfNjG2rXyFlgiyPbXkFgLYcHu3L/U9abY3J1FgxwzE6MzJfmR4ZPsC XNWuryaff2S/TqTuuB0e6vbE6ZsqGO8= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzA2MDE0MSBTYWx0ZWRfX8rpIPUJw0vIo gj+4f17dJgR2mIZcq+rnUXh/CDyojx0LKpMOiCHC8NgXs8VW5LRVFegeNLL6tTXc07Y9iZCKIuv uhcrxahyMgYSIM0WemzIwcaYZC+BDRaT/RYAFc+l5sATbieRTtyp9MNzWaN98YQAJtSj9YzStTd BnS248ZCWLZ15zYTkHrAtPKiGcY7GcSajm9KwQKNvaRjsLepwu3BcNPyJtVB3+TzJeetssp0NJz d5SFze7sjlN8afv1bJIcrJCHlhT9BfhMLyJ3io/a4lxLo1TWVWFJQXQvdq4IrpEjanvBhbP5zFZ LCfmGPcwoINezqreZG36HbDbllO0F6Nr0Q6c2aBIr9aKSiwiLl0D5M5sZ2pzmrBZE4bN1RtIAHC tNkDs5Hl5DwOC0JepUQmQatpDrRBm0Ay6u6q+QngVBHP/u5H3NLMvkTJ9vaK3BuEmlFyIPtO1Uk U+XLqHcNdrK34bTvlKg== 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 adultscore=0 impostorscore=0 spamscore=0 phishscore=0 priorityscore=1501 bulkscore=0 clxscore=1015 lowpriorityscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607060141 Introduce LIST_HEAD_GUARDED(name, lock) to define a struct list_head annotated with __guarded_by(lock). This provides a convenient shorthand for defining lock-protected list heads and allows compiler context analysis to validate accesses to the list against the associated lock. The new helper also reduces boilerplate and improves consistency across callers that annotate struct list_head objects with __guarded_by(). Suggested-by: Christoph Hellwig Signed-off-by: Nilay Shroff --- include/linux/list.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/list.h b/include/linux/list.h index 09d979976b3b..f6f22c8b06f7 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -33,6 +33,14 @@ #define LIST_HEAD(name) \ struct list_head name = LIST_HEAD_INIT(name) +/** + * LIST_HEAD_GUARDED - define a &struct list_head annotated with __guarded_by() + * @name: name of the list_head + * @lock: lock protecting the list + */ +#define LIST_HEAD_GUARDED(name, lock) \ + __guarded_by(&(lock)) LIST_HEAD(name) + /** * INIT_LIST_HEAD - Initialize a list_head structure * @list: list_head structure to be initialized. -- 2.53.0