Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7826791rdb; Thu, 4 Jan 2024 08:51:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEAu9B0JwaI8ioRt8Ll18pofALhm0AgUOQO8r4Q/hs1jwDyPLIOFdpmnmihbr7pRUCOtuD X-Received: by 2002:a05:600c:34d6:b0:40d:5821:516b with SMTP id d22-20020a05600c34d600b0040d5821516bmr493580wmq.54.1704387061612; Thu, 04 Jan 2024 08:51:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704387061; cv=none; d=google.com; s=arc-20160816; b=ntC75izmaoGYzv6n7L/usVsRIfRHzW3g4mo1BOZciKB3FZSHwXealqFDzErh7ZKRGW 4Eei+SbK+1O/JB5kRZIi3I4RR2srvvsFXEEo+MsJrXLUPTH4LdfraRUTatxExvFaqZQ7 d2TDxsiNV3gip/eGvs9uNWrQJd0Kf4T39bRNqqk825ysa8mOj86SReNsi+NYqtCsPMJX /+P6+pmQWUbs2tQ/rduJtA3gPVFQh5ZcVqeg53rEEtgFRP1cPtaovB5BGlZVK7SKClS7 jT/e7npTrubP70Uly8Vu9emr0bcMtJ7R4hPecnD4Mdn4jAMY9hDd9cHbDLwtEAZ1kOfh AZXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=+zJD+pmcDLNgDoMTbJTKA3R+P8xsbJwkatlPFtJv6qA=; fh=VMxFuUi7p6esAnQThBIU5g+fGbO/9oZ7NkGCoxrEu4w=; b=fyC5Xv6o2hQlTaLOySrWLU+AomqG44OfTgHc9fCg/3yj1UbIoN1xGrPMT6fkgTTRsP v2+uWwpOgHYy0pRTiquVyi4FYUXtrmmGcCWi13hBE528lbBUM9xkpn0b/M85Ub+C8fcg WiCXZanrJuqJocTscAdwBTKQVHdvp5X7UaQP4zqRslsG+JYfLOUJCdBqpNiGLS1NuIz4 mU/zgJLKmToq2UY9wFAjDX4l1rQUYWQWY3dAmG9ggSf5bb984NQos7WU3lkU6WM8ufQl 5iX7N2qB/dzdqZA/1mYyFvptIqeUnTkfdLbLACbEse2l9B7aN3LQJlPqfFcR4zIe/UrS a+LQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-16969-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id an14-20020a17090656ce00b00a2825fc959esi2868503ejc.770.2024.01.04.08.51.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 08:51:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16969-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-16969-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16969-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9D1131F21D80 for ; Thu, 4 Jan 2024 16:50:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C95B128699; Thu, 4 Jan 2024 16:50:34 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1786525577; Thu, 4 Jan 2024 16:50:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6A65E1007; Thu, 4 Jan 2024 08:51:18 -0800 (PST) Received: from e126645.arm.com (unknown [10.57.76.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id DBA663F64C; Thu, 4 Jan 2024 08:50:28 -0800 (PST) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Pierre Gondois , Greg Kroah-Hartman , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Carlos Llamas , Suren Baghdasaryan , Coly Li , Kent Overstreet , Marco Elver , Kees Cook , Jani Nikula , Lucas De Marchi , Ingo Molnar , Andy Shevchenko , linux-bcache@vger.kernel.org Subject: [PATCH v2 1/3] list: Add hlist_count_nodes() Date: Thu, 4 Jan 2024 17:49:33 +0100 Message-Id: <20240104164937.424320-2-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240104164937.424320-1-pierre.gondois@arm.com> References: <20240104164937.424320-1-pierre.gondois@arm.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 Add a function to count nodes in a hlist. hlist_count_nodes() is similar to list_count_nodes(). Signed-off-by: Pierre Gondois --- include/linux/list.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/list.h b/include/linux/list.h index 1837caedf723..0f1b1d4a2e2e 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -1175,4 +1175,19 @@ static inline void hlist_move_list(struct hlist_head *old, pos && ({ n = pos->member.next; 1; }); \ pos = hlist_entry_safe(n, typeof(*pos), member)) +/** + * hlist_count_nodes - count nodes in the hlist + * @head: the head for your hlist. + */ +static inline size_t hlist_count_nodes(struct hlist_head *head) +{ + struct hlist_node *pos; + size_t count = 0; + + hlist_for_each(pos, head) + count++; + + return count; +} + #endif -- 2.25.1