From: Jiri Olsa <olsajiri@gmail.com>
To: Menglong Dong <menglong8.dong@gmail.com>
Cc: alexei.starovoitov@gmail.com, mhiramat@kernel.org,
rostedt@goodmis.org, mathieu.desnoyers@efficios.com,
hca@linux.ibm.com, revest@chromium.org,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 1/4] fprobe: use rhashtable
Date: Mon, 28 Jul 2025 15:13:09 +0200 [thread overview]
Message-ID: <aId3ZSnlZRzoDUHC@krava> (raw)
In-Reply-To: <20250728041252.441040-2-dongml2@chinatelecom.cn>
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
next prev parent reply other threads:[~2025-07-28 13:13 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-28 4:12 [PATCH bpf-next 0/4] fprobe: use rhashtable for fprobe_ip_table Menglong Dong
2025-07-28 4:12 ` [PATCH bpf-next 1/4] fprobe: use rhashtable Menglong Dong
2025-07-28 13:13 ` Jiri Olsa [this message]
2025-07-28 14:44 ` Menglong Dong
2025-07-29 3:43 ` kernel test robot
2025-07-28 4:12 ` [PATCH bpf-next 2/4] selftests/bpf: move get_ksyms and get_addrs to trace_helpers.c Menglong Dong
2025-07-28 4:12 ` [PATCH bpf-next 3/4] selftests/bpf: skip recursive functions for kprobe_multi Menglong Dong
2025-07-28 4:12 ` [PATCH bpf-next 4/4] selftests/bpf: add benchmark testing for kprobe-multi-all Menglong Dong
2025-07-28 7:28 ` [PATCH bpf-next 0/4] fprobe: use rhashtable for fprobe_ip_table Masami Hiramatsu
2025-07-28 13:14 ` Jiri Olsa
2025-07-28 14:36 ` Menglong Dong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aId3ZSnlZRzoDUHC@krava \
--to=olsajiri@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=hca@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=menglong8.dong@gmail.com \
--cc=mhiramat@kernel.org \
--cc=revest@chromium.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox