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 439043F58E9 for ; Mon, 13 Jul 2026 11:55:25 +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=1783943726; cv=none; b=CTxwHIfwHcZ//wCZRLF8j/7YaE/nn9rLjzf23ktxCVJp5bM6v/N7bhtJ8+B2vfK3njjbY31SVIingBJr7/FYj9HzJkEvrQly62tRs653oFhJamoxH5Os/WasroS9GlijDkuRX7EEJRGcRrg/pgDyTQ8l1OM+QaQiwTFVxyepEuM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783943726; c=relaxed/simple; bh=9famA7iYMgV1szWsgpchH0LLweh9Zetp9tpUFUGJj6o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=chmZxZvd0zdo8xCurb6h3ly0taKqjiHNya81k0o+n426x6e2zVsSkFa+AHIZx+/zufeZdPVYpqSvm/ktW+do8jQj2VWMSTUO7oEM8MWy7mJnK+FZhBhD1uLfgIx1TjDQOGdltImb+BRVrrZ3+XUoCKWGxr564SSZjep4vkaQbM8= 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=XuEA7eg+; 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="XuEA7eg+" 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 66D6fYdU1740140; Mon, 13 Jul 2026 11:55:07 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=ZNwHp1WLvUb5u+QxI V8sWET71/YQVNBNKDMDCrQyGDM=; b=XuEA7eg+dRNi4AomCSmXRMxlQjKyPolhP o/utX/Cq/cBQHlUxBJvcAtbxX6jzBK3u6VY/LLl0eDUkCOIhsHEdEYaluBQUf2b8 KYI5TOsPDqE8LAcgiV01OtkM5BswJS5VhTjZ/AwzleOWRES34gJD8ivvk8AgLC/m diFyzuAvBNsJH92yGGQyeKU1Rr3KCVm2mw6EKHSplV7vUNSFLxKUT2yvgXjREYb6 qZMDuLRVe5F5ojwHUDoRCorl0ssRqkWUvnkIlO6sWg9OdZYeUnBUxbcztuIVR/5c sf2ie3dBAI2+z8ZJfgy4ZGOiKNBf+lTZ8lK26ySOpyUlLomsCjhlw== 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 4fbegt0f9e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Jul 2026 11:55:06 +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 66DBndB9006908; Mon, 13 Jul 2026 11:55:05 GMT Received: from smtprelay05.fra02v.mail.ibm.com ([9.218.2.225]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4fc05pwnvu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 13 Jul 2026 11:55:05 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay05.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 66DBt1Y842991982 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Jul 2026 11:55:01 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B7EF42004B; Mon, 13 Jul 2026 11:55:01 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B1B2920040; Mon, 13 Jul 2026 11:54:59 +0000 (GMT) Received: from li-a84c74cc-2b13-11b2-a85c-acdd023f0674.bl1-in.ibm.com (unknown [9.123.7.57]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 13 Jul 2026 11:54:59 +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 v4 02/20] list: Permit context-unguarded access with list_empty_careful() Date: Mon, 13 Jul 2026 17:24:03 +0530 Message-ID: <20260713115444.465704-3-nilay@linux.ibm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260713115444.465704-1-nilay@linux.ibm.com> References: <20260713115444.465704-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-Proofpoint-ORIG-GUID: pBXu_KgKEnzESMAVMVi0knc0nyS4Hqn5 X-Proofpoint-Spam-Info: AW1haW4tMjYwNzEzMDEyMiBTYWx0ZWRfX0PJWpUfvdfx2 uIlnjfkKrVsicG6eqGstkmC8oQb97wqyMO/G6WB9qqZtjdAIP60obgKZsfouqKx+B/If27wYne3 mmzX8EIrm2ZSJrc8JymMZMOf6oeJPPg= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzEzMDEyMiBTYWx0ZWRfX6l3+y5MTFnws AZXkW19M3LTmTvC+OGFFaqeNOmpxh/B2pNy3FagzsR1PgKQecDKjWbvqwjN88xOonohBjUQCRxL zqrmPXTMT7qBgVUM+ILNaleCN9AFSnnxBXXyUJwlaEn5XnVctJ/A0wYNEXuUjc1VWbfowVYztYU W3ROqLpMidafFM+T5/VNi/oISfuzqX+QPz++2LuZcuVIBnWmQ8gBM/36TUeP2/Flh1HhIR7OL/d POgFSFqPM2nd2xgv1F2ChmYEXqx82gjxaGvWtp3p5nzC0VScn7yNHCO9eomc2SOpTWpz6ngTPJ0 dlzo7d+NJHr+R/gBEf7C0zkgaIQDCAFIheKMqollnL5gYOxwgz0fjaOEYhWuMS7izc85uytt3X4 n/RK0ZXT5K5A46UIkiYMpHHx0Pr8MaR49KAOpUlkNEzbEKtck8ayAOB/A6gvb4P2dvXjOxCH6Kb V2c+bqiRywdZQ9afI1Q== X-Authority-Analysis: v=2.4 cv=IqMutr/g c=1 sm=1 tr=0 ts=6a54d21b cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=RAioF0-LDSMA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=1XWaLZrsAAAA:8 a=VnNF1IyMAAAA:8 a=4at8UNLr3tDfbFC0C8MA:9 X-Proofpoint-GUID: oR7CKBTJwnTWHzyfnKAHwgeyasazEjKA 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-13_02,2026-07-10_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 impostorscore=0 malwarescore=0 adultscore=0 phishscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607130122 From: Marco Elver With Context Analysis (viz. Clang's Thread Safety Analysis), list_heads that are __guarded_by(..) require holding the appropriate context lock when accessing and manipulating them via the list API. Because Clang's warning diagnostics do not perform inter-procedural analysis, this is enforced by Clang with -Wthread-safety-pointer in the caller at the call boundary; a warning is produced when passing a pointer to a guarded variable without holding the appropriate context locks: warning: passing pointer to variable 'list' requires holding [...] [-Wthread-safety-pointer] if (list_empty(&ctrl->list)) An exception is list_empty_careful(), which is like list_empty(), except that it is permitted to use without holding any context lock (carefully). Mark list_empty_careful() __context_unsafe, which disables context analysis within list_empty_careful(), but also suppresses warnings generated in callers related to its pointer arguments. Signed-off-by: Marco Elver Signed-off-by: Nilay Shroff --- include/linux/list.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/list.h b/include/linux/list.h index f6f22c8b06f7..19212bfc3f6d 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -444,6 +444,7 @@ static inline void list_del_init_careful(struct list_head *entry) * if another CPU could re-list_add() it. */ static inline int list_empty_careful(const struct list_head *head) + __context_unsafe(/* intentional lockless access to @head */) { struct list_head *next = smp_load_acquire(&head->next); return list_is_head(next, head) && (next == READ_ONCE(head->prev)); -- 2.53.0