The patch titled Subject: list: add hlist_count_nodes() has been added to the -mm mm-nonmm-unstable branch. Its filename is list-add-hlist_count_nodes.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/list-add-hlist_count_nodes.patch This patch will later appear in the mm-nonmm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Pierre Gondois <pierre.gondois@xxxxxxx> Subject: list: add hlist_count_nodes() Date: Thu, 4 Jan 2024 17:49:33 +0100 Add a generic hlist_count_nodes() function and use it in two drivers. This patch (of 3): Add a function to count nodes in a hlist. hlist_count_nodes() is similar to list_count_nodes(). Link: https://lkml.kernel.org/r/20240104164937.424320-1-pierre.gondois@xxxxxxx Link: https://lkml.kernel.org/r/20240104164937.424320-2-pierre.gondois@xxxxxxx Signed-off-by: Pierre Gondois <pierre.gondois@xxxxxxx> Reviewed-by: Carlos Llamas <cmllamas@xxxxxxxxxx> Acked-by: Coly Li <colyli@xxxxxxx> Acked-by: Marco Elver <elver@xxxxxxxxxx> Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> Cc: Arve Hjønnevåg <arve@xxxxxxxxxxx> Cc: Christian Brauner <brauner@xxxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Jani Nikula <jani.nikula@xxxxxxxxx> Cc: Joel Fernandes (Google) <joel@xxxxxxxxxxxxxxxxx> Cc: Kees Cook <keescook@xxxxxxxxxxxx> Cc: Kent Overstreet <kent.overstreet@xxxxxxxxx> Cc: Martijn Coenen <maco@xxxxxxxxxxx> Cc: Suren Baghdasaryan <surenb@xxxxxxxxxx> Cc: Todd Kjos <tkjos@xxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/list.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) --- a/include/linux/list.h~list-add-hlist_count_nodes +++ a/include/linux/list.h @@ -1175,4 +1175,19 @@ static inline void hlist_move_list(struc 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 _ Patches currently in -mm which might be from pierre.gondois@xxxxxxx are list-add-hlist_count_nodes.patch binder-use-of-hlist_count_nodes.patch bcache-use-of-hlist_count_nodes.patch