On Mon, Jul 28, 2025 at 12:12:48PM +0800, Menglong Dong wrote:

SNIP

> +static const struct rhashtable_params fprobe_rht_params = {
> +     .head_offset            = offsetof(struct fprobe_hlist_node, hlist),
> +     .key_offset             = offsetof(struct fprobe_hlist_node, addr),
> +     .key_len                = sizeof_field(struct fprobe_hlist_node, addr),
> +     .hashfn                 = fprobe_node_hashfn,
> +     .obj_hashfn             = fprobe_node_obj_hashfn,
> +     .obj_cmpfn              = fprobe_node_cmp,
> +     .automatic_shrinking    = true,
> +};
>  
>  /* Node insertion and deletion requires the fprobe_mutex */
>  static void insert_fprobe_node(struct fprobe_hlist_node *node)
>  {
> -     unsigned long ip = node->addr;
> -     struct fprobe_hlist_node *next;
> -     struct hlist_head *head;
> -
>       lockdep_assert_held(&fprobe_mutex);
>  
> -     next = find_first_fprobe_node(ip);
> -     if (next) {
> -             hlist_add_before_rcu(&node->hlist, &next->hlist);
> -             return;
> -     }
> -     head = &fprobe_ip_table[hash_ptr((void *)ip, FPROBE_IP_HASH_BITS)];
> -     hlist_add_head_rcu(&node->hlist, head);
> +     rhashtable_insert_fast(&fprobe_ip_table, &node->hlist,
> +                            fprobe_rht_params);

onw that rhashtable_insert_fast can fail, I think insert_fprobe_node
needs to be able to fail as well

>  }
>  
>  /* Return true if there are synonims */
> @@ -92,9 +93,11 @@ static bool delete_fprobe_node(struct fprobe_hlist_node 
> *node)
>       /* Avoid double deleting */
>       if (READ_ONCE(node->fp) != NULL) {
>               WRITE_ONCE(node->fp, NULL);
> -             hlist_del_rcu(&node->hlist);
> +             rhashtable_remove_fast(&fprobe_ip_table, &node->hlist,
> +                                    fprobe_rht_params);

I guess this one can't fail in here.. ?

jirka

>       }
> -     return !!find_first_fprobe_node(node->addr);
> +     return !!rhashtable_lookup_fast(&fprobe_ip_table, &node->addr,
> +                                     fprobe_rht_params);
>  }
>  

SNIP

Reply via email to