From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx.ssi.bg (mx.ssi.bg [193.238.174.39]) (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 8CDE536494F; Thu, 26 Feb 2026 19:55:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.238.174.39 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772135710; cv=none; b=QzztPkTKJjJ/DpkD7rKx0fHZ6L1Uz67HucyX5IoWWlPUIdAW0IPlsBpsZUL1/xTzSqM7t5lmNjJzDeMq5uTcVpi+mnxZlSH0p1QiYpu7leZKMWUlV++byg3CUvX/wf61nx1UdpR3nan0SOexE/CtV+soALuCiBD1U9VwKuhS5C8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772135710; c=relaxed/simple; bh=YpQVzMNQYwubgAblRHLy5reB5gle/I0QeomSycZdkAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rg1R3Gf9uaPrK1RU2clqThI2qSRrlLnigP6vjv+IYAg6TkQcp2LLTN7e4APHLaHzptw9JYKzF2sKhQHfWlRaWlZCCs6BiZHMVolpsgZiLQ3kXEXaisNkYialqkNxTOiWhaG6E3twnwD8M0/CHDXCb+xKhfNqw1BTYyF7z9fgyeU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ssi.bg; spf=pass smtp.mailfrom=ssi.bg; dkim=pass (4096-bit key) header.d=ssi.bg header.i=@ssi.bg header.b=HqdgHSV4; arc=none smtp.client-ip=193.238.174.39 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ssi.bg Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ssi.bg Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=ssi.bg header.i=@ssi.bg header.b="HqdgHSV4" Received: from mx.ssi.bg (localhost [127.0.0.1]) by mx.ssi.bg (Potsfix) with ESMTP id CD0EF21D54; Thu, 26 Feb 2026 21:55:06 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ssi.bg; h=cc:cc :content-transfer-encoding:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=ssi; bh=luGPi+clXTffMVgstG1zKlKX62vMfhcFqk6l1hfDpoU=; b=HqdgHSV4nqFz TKYLD9FvkacysFwgzNjIjzp0/6IzDN4clKvd9yxBCeL7dJQH8q+A1T4ByI+1TQLe 95/AKKp3GByDiiRhWVXMLPzzPg0RQ1vF6QDClvZ4IYzLhYKqX6OKLlM7MRs7EVdu 2o3eKLMXzX3YKaD8b5c27na6cUvsAbvPqJ7Pwc+r+8f20LRYYaS6h0Myo1ceKkau ubJBJ6nAaXtC9U/WcmFO7VWt3zW9D1CI8Y+nU8WT5yqChponDPMMyUqBbSzfBV3Q VgOk4tGh3E+vlp5G1xLkGLVTGwJMxEX+qPrZnQsLGTl1OxwVTpD6t68EhViYWUv0 QjL2qzPVFfI4tZIBXkeevlZyHPjbZOC8ZRJrQyDn9lcowt6RXvyDslGL3O4veyFG 7usLKx9YjdCVK1RZqNHxPBafffAhX0TDgwim/GYBeemvnfzXpNhZn0/Z5PsacYVq W8kQa838xyd7XLDICvTqtOx28cpk16zCLwOmJjN+/VrypAQYoiOMOYG9qAh/DbJx Sv5S3yqmV+2yn6wsm/YtAgALDzy0DEYXDiWTem3gK5hDettvHjTXBYcVW20MNHQh H8Z5vepzld6DGrLbPnv/lR2s+1G1COvIasl5slRR8ViVosBVVg/zr0ZJdrv1d6X0 o9l0UStuklc7hoV1W6WflV/ljMqZcw8= Received: from box.ssi.bg (box.ssi.bg [193.238.174.46]) by mx.ssi.bg (Potsfix) with ESMTPS; Thu, 26 Feb 2026 21:55:05 +0200 (EET) Received: from ja.ssi.bg (unknown [213.16.62.126]) by box.ssi.bg (Potsfix) with ESMTPSA id 10D50609BF; Thu, 26 Feb 2026 21:55:05 +0200 (EET) Received: from ja.home.ssi.bg (localhost.localdomain [127.0.0.1]) by ja.ssi.bg (8.18.1/8.18.1) with ESMTP id 61QJph59064978; Thu, 26 Feb 2026 21:51:43 +0200 Received: (from root@localhost) by ja.home.ssi.bg (8.18.1/8.18.1/Submit) id 61QJphap064977; Thu, 26 Feb 2026 21:51:43 +0200 From: Julian Anastasov To: Simon Horman Cc: Pablo Neira Ayuso , lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org, Dust Li , Jiejian Wu , rcu@vger.kernel.org Subject: [PATCH nf-next 1/5] rculist_bl: add hlist_bl_for_each_entry_continue_rcu Date: Thu, 26 Feb 2026 21:50:17 +0200 Message-ID: <20260226195021.64943-2-ja@ssi.bg> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260226195021.64943-1-ja@ssi.bg> References: <20260226195021.64943-1-ja@ssi.bg> Precedence: bulk X-Mailing-List: rcu@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Change the old hlist_bl_first_rcu to hlist_bl_first_rcu_dereference to indicate that it is a RCU dereference. Add hlist_bl_next_rcu and hlist_bl_first_rcu to use RCU pointers and use them to fix sparse warnings. Add hlist_bl_for_each_entry_continue_rcu. Signed-off-by: Julian Anastasov --- include/linux/rculist_bl.h | 49 +++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/include/linux/rculist_bl.h b/include/linux/rculist_bl.h index 0b952d06eb0b..36363b876e53 100644 --- a/include/linux/rculist_bl.h +++ b/include/linux/rculist_bl.h @@ -8,21 +8,31 @@ #include #include +/* return the first ptr or next element in an RCU protected list */ +#define hlist_bl_first_rcu(head) \ + (*((struct hlist_bl_node __rcu **)(&(head)->first))) +#define hlist_bl_next_rcu(node) \ + (*((struct hlist_bl_node __rcu **)(&(node)->next))) + static inline void hlist_bl_set_first_rcu(struct hlist_bl_head *h, struct hlist_bl_node *n) { LIST_BL_BUG_ON((unsigned long)n & LIST_BL_LOCKMASK); LIST_BL_BUG_ON(((unsigned long)h->first & LIST_BL_LOCKMASK) != LIST_BL_LOCKMASK); - rcu_assign_pointer(h->first, + rcu_assign_pointer(hlist_bl_first_rcu(h), (struct hlist_bl_node *)((unsigned long)n | LIST_BL_LOCKMASK)); } -static inline struct hlist_bl_node *hlist_bl_first_rcu(struct hlist_bl_head *h) -{ - return (struct hlist_bl_node *) - ((unsigned long)rcu_dereference_check(h->first, hlist_bl_is_locked(h)) & ~LIST_BL_LOCKMASK); -} +#define hlist_bl_first_rcu_dereference(head) \ +({ \ + struct hlist_bl_head *__head = (head); \ + \ + (struct hlist_bl_node *) \ + ((unsigned long)rcu_dereference_check(hlist_bl_first_rcu(__head), \ + hlist_bl_is_locked(__head)) & \ + ~LIST_BL_LOCKMASK); \ +}) /** * hlist_bl_del_rcu - deletes entry from hash list without re-initialization @@ -73,7 +83,7 @@ static inline void hlist_bl_add_head_rcu(struct hlist_bl_node *n, { struct hlist_bl_node *first; - /* don't need hlist_bl_first_rcu because we're under lock */ + /* don't need hlist_bl_first_rcu* because we're under lock */ first = hlist_bl_first(h); n->next = first; @@ -93,9 +103,30 @@ static inline void hlist_bl_add_head_rcu(struct hlist_bl_node *n, * */ #define hlist_bl_for_each_entry_rcu(tpos, pos, head, member) \ - for (pos = hlist_bl_first_rcu(head); \ + for (pos = hlist_bl_first_rcu_dereference(head); \ pos && \ ({ tpos = hlist_bl_entry(pos, typeof(*tpos), member); 1; }); \ - pos = rcu_dereference_raw(pos->next)) + pos = rcu_dereference_raw(hlist_bl_next_rcu(pos))) + +/** + * hlist_bl_for_each_entry_continue_rcu - continue iteration over list of given + * type + * @tpos: the type * to use as a loop cursor. + * @pos: the &struct hlist_bl_node to use as a loop cursor. + * @member: the name of the hlist_bl_node within the struct. + * + * Continue to iterate over list of given type, continuing after + * the current position which must have been in the list when the RCU read + * lock was taken. + * This would typically require either that you obtained the node from a + * previous walk of the list in the same RCU read-side critical section, or + * that you held some sort of non-RCU reference (such as a reference count) + * to keep the node alive *and* in the list. + */ +#define hlist_bl_for_each_entry_continue_rcu(tpos, pos, member) \ + for (pos = rcu_dereference_raw(hlist_bl_next_rcu(&(tpos)->member)); \ + pos && \ + ({ tpos = hlist_bl_entry(pos, typeof(*tpos), member); 1; }); \ + pos = rcu_dereference_raw(hlist_bl_next_rcu(pos))) #endif -- 2.53.0