Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7850555rdb; Thu, 4 Jan 2024 09:30:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IF9vcgIvK6h25LG7t60a9GK9V1KblXb/WsC4UYQSB64jztoLtWYsDEzEOlb6Zl/z7czsZdv X-Received: by 2002:a05:6102:3e82:b0:467:ae34:5774 with SMTP id m2-20020a0561023e8200b00467ae345774mr552549vsv.33.1704389423559; Thu, 04 Jan 2024 09:30:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704389423; cv=none; d=google.com; s=arc-20160816; b=GuPaoU7NZ+lzL0IR31aQ1wbrCV3Jyya9hxAhXNrc9unUIvPQ25VNMh8YCUbgEdd3WN x3bKOCxgUnuDVuW8CBWUQgdBbU+TGHBTvkt3r+e37jv6MX0APHhE4W9swQqhDrd2Cpqi iboePcjywK9X8u/bs7oDpExFqLS4AkrRJv7MptVRTgTs4M97nrmPtEj5UXHtnWODE6TL yHxelNJOVpddgd9e1Sk5c2CMPFXI8l0ycqOpTe3THzIVFdMwlEyPDznsKkgXbhn6PS7q P6bI13QOgmjU/ixmlv/wbjp29uN6JPLLb852A7RcqMtWpwL72R2FtnyDH8M/CPCHV4DD 55Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3M5Xkeyb638fQDRDYiWI7VQRLopuLK94f8Vxf8hYN/8=; fh=/L6SQlQRqIfhbcblyH7Kui2HJ65RaIgqPXmApjScbCU=; b=K+7OqEvb85ezp4bsizyhJCeFkXEw5hhiX4/MCQdNbJxnzu8r/dBYC7R6CJYI59A93D PYthxbMV9TSN494Nt17kdTqBwQwlhcqtaSEsuwmFNZ9doSLHsIs0AiHsrghbt6IczvWy 3guUdIsk9Yvx1q77GGDtG+9vFCuLDGWSJsGc1VR5hFvvj+otT5UC1NtxlfYQRNI0VdjK rvYSXJ47sbdPdJNrD0C3EaPw64ISAMMD+cIPZMRLwNrkMRDVv96MTgk4NqjDiPZxJuhZ PomrxUkfwPrSxsS4ZWABwOBG9MANYWBRYrGGNZNtkbA/f1Qzxa2tAvyu+6zS+FF482I9 rGsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HleWbOhz; spf=pass (google.com: domain of linux-kernel+bounces-17038-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17038-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id jj20-20020a05610218d400b004670124064esi2423887vsb.733.2024.01.04.09.30.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 09:30:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17038-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=HleWbOhz; spf=pass (google.com: domain of linux-kernel+bounces-17038-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17038-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 48E901C220E1 for ; Thu, 4 Jan 2024 17:30:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B208625549; Thu, 4 Jan 2024 17:30:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="HleWbOhz" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 93BC725553 for ; Thu, 4 Jan 2024 17:30:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6d9b13fe9e9so524747b3a.2 for ; Thu, 04 Jan 2024 09:30:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704389413; x=1704994213; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=3M5Xkeyb638fQDRDYiWI7VQRLopuLK94f8Vxf8hYN/8=; b=HleWbOhz679e76GSytykBuxvGYSYUNIFt893R+7EhNIb8QOcGEnf0O3CJan8OOSpib yibOJ/MpLopGKj/AJMVd5JcgWMTW3ApHEkgsrbV7fzX938naXfWTbxwd4oLH84VupuBF /HwtLAJa2debzra/sbFRxiYF3DR9URln+Hxu7DBv3iQ2Fb11Sd9bzUpQGGL6PyRHGXi1 FM/lBbW5/KeHvUr/RBhTZNE2LhjNatF6nQLiU3gepyggjGgRmmzDQYljtaY5k9p7tZv5 hcbnsRRGtBQR/6a+eU9pSF1G49rrotAMTFBvSk7aIr0hN2OO4hzO2AEu4CItExOMNiPj u/kA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704389413; x=1704994213; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=3M5Xkeyb638fQDRDYiWI7VQRLopuLK94f8Vxf8hYN/8=; b=Jrsrhykh8l+gopBvZIcgv8rqHYA9FFNsRhZ1E/ZxnPsS12CXudpRYZ6Kp06nChO+y9 HWi91/3jI0APEKxaSMymAWsa7qJlPLs3wXJHWop85aFTvOJBZ5mABv2r8qIa4kyr0zia IWdXkivTf2ub2P4crMvQ5E3wrGimWK0IBUcAH6NCjTRU4eMu1lmddn6dcrZfV7cO8LAE J8wAbQamLHHyTKVIEtiIenxJ+QKmVBCr2neiAMsi2CwQLUzcUjjXkdY3mxUsH4+0k6s4 9luYMhqvdCukJZs3vWeVOcP3X4dJChcop9QkiS1nJWEy0zN7RJ02o2wVp+4+rr2HMlWa 9Ofw== X-Gm-Message-State: AOJu0YyxYknm2xma+kJvhGUJ4gS3KdxsOlaVVj8fIAQP52jGhuXnX2rU lOJGgsiwVqO7HK/botaAZo4u7EtN6LX4 X-Received: by 2002:a05:6a00:2d1e:b0:6d9:b54e:9d45 with SMTP id fa30-20020a056a002d1e00b006d9b54e9d45mr960660pfb.15.1704389412771; Thu, 04 Jan 2024 09:30:12 -0800 (PST) Received: from google.com (77.62.105.34.bc.googleusercontent.com. [34.105.62.77]) by smtp.gmail.com with ESMTPSA id s34-20020a056a0017a200b006d9bcf301ffsm18248878pfg.194.2024.01.04.09.30.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 09:30:12 -0800 (PST) Date: Thu, 4 Jan 2024 17:30:08 +0000 From: Carlos Llamas To: Pierre Gondois Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , 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: Re: [PATCH v2 1/3] list: Add hlist_count_nodes() Message-ID: References: <20240104164937.424320-1-pierre.gondois@arm.com> <20240104164937.424320-2-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240104164937.424320-2-pierre.gondois@arm.com> On Thu, Jan 04, 2024 at 05:49:33PM +0100, Pierre Gondois wrote: > 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 > Looks good. Reviewed-by: Carlos Llamas