Skip to content

Commit 1444ee8

Browse files
mykyta5Alexei Starovoitov
authored andcommitted
rhashtable: Fix rhashtable_next_key() build warnings
rhashtable.o builds with warnings as rhashtable_next_key() kdoc from lib/rhashtable.c does not have the arguments descriptions. Move rhashtable_next_key() kdoc from header to c file, matching other functions. Move rhashtable_next_key() next to the other forward declarations in the header file. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202606061925.WI4bYI8k-lkp@intel.com/ Fixes: 8f4fa9f ("rhashtable: Add rhashtable_next_key() API") Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com> Link: https://lore.kernel.org/r/20260606-rhash_fixes_1-v1-1-932ab036e6bc@meta.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent c49f336 commit 1444ee8

2 files changed

Lines changed: 36 additions & 41 deletions

File tree

include/linux/rhashtable.h

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ struct rhash_lock_head __rcu **__rht_bucket_nested(
263263
struct rhash_lock_head __rcu **rht_bucket_nested_insert(
264264
struct rhashtable *ht, struct bucket_table *tbl, unsigned int hash);
265265

266+
void *rhashtable_next_key(struct rhashtable *ht, const void *prev_key);
267+
266268
#define rht_dereference(p, ht) \
267269
rcu_dereference_protected(p, lockdep_rht_mutex_is_held(ht))
268270

@@ -650,46 +652,6 @@ static __always_inline struct rhash_head *__rhashtable_lookup(
650652
return NULL;
651653
}
652654

653-
/**
654-
* rhashtable_next_key - return next element after a given key
655-
* @ht: hash table
656-
* @prev_key: pointer to previous key, or NULL for the first element
657-
*
658-
* WARNING: this walk is highly unstable. Unlike rhashtable_walk_*(),
659-
* it cannot detect a concurrent resize or rehash, so a full iteration
660-
* is NOT guaranteed to terminate under adversarial or sustained
661-
* rehashing. Callers MUST tolerate skipped and duplicated elements and
662-
* SHOULD bound their loop externally.
663-
*
664-
* Returns the next element in best-effort iteration order, walking the
665-
* @tbl chain (including any future_tbl in flight). Caller must hold RCU.
666-
*
667-
* Pass @prev_key == NULL to obtain the first element. To iterate, set
668-
* @prev_key to the key of the previously returned element on each call,
669-
* and stop when NULL is returned.
670-
*
671-
* Best-effort semantics:
672-
* - Across the tbl->future_tbl chain, an element being migrated may
673-
* transiently appear in both tables and be observed twice.
674-
* - Concurrent inserts may or may not be observed.
675-
* - Termination of a full iteration loop is NOT guaranteed under
676-
* adversarial continuous rehash; callers MUST tolerate skips and
677-
* repeats and SHOULD bound their loop externally.
678-
* - Behavior on tables that contain duplicate keys is undefined:
679-
* duplicates may be skipped, repeated, or trap the walk in a
680-
* cycle. Callers requiring duplicate-key iteration must use
681-
* rhashtable_walk_*() instead.
682-
* - rhltable instances are not supported and return
683-
* ERR_PTR(-EOPNOTSUPP).
684-
* - If prev_key was concurrently deleted and is not present in any
685-
* in-flight table, returns ERR_PTR(-ENOENT).
686-
*
687-
* Returns entry of the next element, or NULL when iteration is exhausted,
688-
* or ERR_PTR(-ENOENT) if prev_key is not found, or
689-
* ERR_PTR(-EOPNOTSUPP) if @ht is an rhltable.
690-
*/
691-
void *rhashtable_next_key(struct rhashtable *ht, const void *prev_key);
692-
693655
/**
694656
* rhashtable_lookup - search hash table
695657
* @ht: hash table

lib/rhashtable.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,41 @@ static struct rhash_head *__rhashtable_next_in_table(
730730

731731
/**
732732
* rhashtable_next_key - return next element after a given key
733+
* @ht: hash table
734+
* @prev_key: pointer to previous key, or NULL for the first element
733735
*
734-
* See include/linux/rhashtable.h for the full contract.
736+
* WARNING: this walk is highly unstable. Unlike rhashtable_walk_*(),
737+
* it cannot detect a concurrent resize or rehash, so a full iteration
738+
* is NOT guaranteed to terminate under adversarial or sustained
739+
* rehashing. Callers MUST tolerate skipped and duplicated elements and
740+
* SHOULD bound their loop externally.
741+
*
742+
* Returns the next element in best-effort iteration order, walking the
743+
* @tbl chain (including any future_tbl in flight). Caller must hold RCU.
744+
*
745+
* Pass @prev_key == NULL to obtain the first element. To iterate, set
746+
* @prev_key to the key of the previously returned element on each call,
747+
* and stop when NULL is returned.
748+
*
749+
* Best-effort semantics:
750+
* - Across the tbl->future_tbl chain, an element being migrated may
751+
* transiently appear in both tables and be observed twice.
752+
* - Concurrent inserts may or may not be observed.
753+
* - Termination of a full iteration loop is NOT guaranteed under
754+
* adversarial continuous rehash; callers MUST tolerate skips and
755+
* repeats and SHOULD bound their loop externally.
756+
* - Behavior on tables that contain duplicate keys is undefined:
757+
* duplicates may be skipped, repeated, or trap the walk in a
758+
* cycle. Callers requiring duplicate-key iteration must use
759+
* rhashtable_walk_*() instead.
760+
* - rhltable instances are not supported and return
761+
* ERR_PTR(-EOPNOTSUPP).
762+
* - If prev_key was concurrently deleted and is not present in any
763+
* in-flight table, returns ERR_PTR(-ENOENT).
764+
*
765+
* Returns entry of the next element, or NULL when iteration is exhausted,
766+
* or ERR_PTR(-ENOENT) if prev_key is not found, or
767+
* ERR_PTR(-EOPNOTSUPP) if @ht is an rhltable.
735768
*/
736769
void *rhashtable_next_key(struct rhashtable *ht, const void *prev_key)
737770
{

0 commit comments

Comments
 (0)