[Devel] [PATCH vz10 1/7] lib/kmapset: annotate the kmapset_lookup rcu-list walk with the held lock
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Tue Jun 30 15:58:42 MSK 2026
On 6/28/26 11:25, Mirian Shilakadze wrote:
> kmapset_lookup() walks map->links with hlist_for_each_entry_rcu() and its
> own comment states the contract: the caller holds kmapset_lock (the set
> mutex) or rcu_read_lock. Its readers take rcu_read_lock and its writers
> (kmapset_set_value, kmapset_del_value) hold kmapset_lock, so callers that
> honour the contract are serialised correctly. The macro carried no lockdep
> condition though, so with CONFIG_PROVE_RCU_LIST the writer path trips:
>
> lib/kmapset.c:236 RCU-list traversed in non-reader section!!
> kmapset_lookup
> kmapset_del_value
> kernfs_perms_set
>
> Pass lockdep_is_held(&map->set->mutex) so the checker accepts both the
> rcu_read_lock readers and the kmapset_lock writers. No functional change.
>
> Fixes: 8e1c907a00e8 ("kmapset: set of key-value mappings with build-in")
> Signed-off-by: Mirian Shilakadze <mirian.shilakadze at virtuozzo.com>
please don't forget to put jira links in each patch
> ---
> lib/kmapset.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/kmapset.c b/lib/kmapset.c
> index c7a1e57ad3a5..a479134b9793 100644
> --- a/lib/kmapset.c
> +++ b/lib/kmapset.c
> @@ -233,7 +233,8 @@ kmapset_lookup(struct kmapset_map *map, struct kmapset_key *key)
> {
> struct kmapset_link *link;
>
> - hlist_for_each_entry_rcu(link, &map->links, map_link) {
> + hlist_for_each_entry_rcu(link, &map->links, map_link,
> + lockdep_is_held(&map->set->mutex)) {
> if (link->key == key)
> return link;
> if (link->key > key)
--
Best regards, Pavel Tikhomirov
Senior Software Developer, Virtuozzo.
More information about the Devel
mailing list