public inbox for linux-trace-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@kernel.org>
To: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	Martin KaFai Lau <kafai@fb.com>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
	Menglong Dong <menglong8.dong@gmail.com>,
	Steven Rostedt <rostedt@kernel.org>
Subject: [RFC bpf-next 01/12] ftrace: Add ftrace_hash_count function
Date: Tue,  3 Feb 2026 10:38:08 +0100	[thread overview]
Message-ID: <20260203093819.2105105-2-jolsa@kernel.org> (raw)
In-Reply-To: <20260203093819.2105105-1-jolsa@kernel.org>

Adding external ftrace_hash_count function that replaces hash_count
function, so we can get hash count outside of ftrace object.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 include/linux/ftrace.h |  1 +
 kernel/trace/ftrace.c  | 14 +++++++-------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 705db0a6d995..6dade0eaee46 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -413,6 +413,7 @@ struct ftrace_hash *alloc_ftrace_hash(int size_bits);
 void free_ftrace_hash(struct ftrace_hash *hash);
 struct ftrace_func_entry *add_ftrace_hash_entry_direct(struct ftrace_hash *hash,
 						       unsigned long ip, unsigned long direct);
+unsigned long ftrace_hash_count(struct ftrace_hash *hash);
 
 /* The hash used to know what functions callbacks trace */
 struct ftrace_ops_hash {
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index b12dbd93ae1c..be9e0ac1fd95 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -6284,7 +6284,7 @@ int modify_ftrace_direct(struct ftrace_ops *ops, unsigned long addr)
 }
 EXPORT_SYMBOL_GPL(modify_ftrace_direct);
 
-static unsigned long hash_count(struct ftrace_hash *hash)
+unsigned long ftrace_hash_count(struct ftrace_hash *hash)
 {
 	return hash ? hash->count : 0;
 }
@@ -6302,7 +6302,7 @@ static struct ftrace_hash *hash_add(struct ftrace_hash *a, struct ftrace_hash *b
 	struct ftrace_hash *add;
 	int size;
 
-	size = hash_count(a) + hash_count(b);
+	size = ftrace_hash_count(a) + ftrace_hash_count(b);
 	if (size > 32)
 		size = 32;
 
@@ -6345,7 +6345,7 @@ int update_ftrace_direct_add(struct ftrace_ops *ops, struct ftrace_hash *hash)
 	int size;
 	bool reg;
 
-	if (!hash_count(hash))
+	if (!ftrace_hash_count(hash))
 		return -EINVAL;
 
 	mutex_lock(&direct_mutex);
@@ -6362,7 +6362,7 @@ int update_ftrace_direct_add(struct ftrace_ops *ops, struct ftrace_hash *hash)
 	old_filter_hash = ops->func_hash ? ops->func_hash->filter_hash : NULL;
 
 	/* If there's nothing in filter_hash we need to register the ops. */
-	reg = hash_count(old_filter_hash) == 0;
+	reg = ftrace_hash_count(old_filter_hash) == 0;
 	if (reg) {
 		if (ops->func || ops->trampoline)
 			goto out_unlock;
@@ -6480,7 +6480,7 @@ int update_ftrace_direct_del(struct ftrace_ops *ops, struct ftrace_hash *hash)
 	unsigned long size;
 	int err = -EINVAL;
 
-	if (!hash_count(hash))
+	if (!ftrace_hash_count(hash))
 		return -EINVAL;
 	if (check_direct_multi(ops))
 		return -EINVAL;
@@ -6493,7 +6493,7 @@ int update_ftrace_direct_del(struct ftrace_ops *ops, struct ftrace_hash *hash)
 
 	old_filter_hash = ops->func_hash ? ops->func_hash->filter_hash : NULL;
 
-	if (!hash_count(old_filter_hash))
+	if (!ftrace_hash_count(old_filter_hash))
 		goto out_unlock;
 
 	/* Make sure requested entries are already registered. */
@@ -6580,7 +6580,7 @@ int update_ftrace_direct_mod(struct ftrace_ops *ops, struct ftrace_hash *hash, b
 	unsigned long size, i;
 	int err = -EINVAL;
 
-	if (!hash_count(hash))
+	if (!ftrace_hash_count(hash))
 		return -EINVAL;
 	if (check_direct_multi(ops))
 		return -EINVAL;
-- 
2.52.0


  reply	other threads:[~2026-02-03  9:38 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-03  9:38 [RFC bpf-next 00/12] bpf: tracing_multi link Jiri Olsa
2026-02-03  9:38 ` Jiri Olsa [this message]
2026-02-03 15:40   ` [RFC bpf-next 01/12] ftrace: Add ftrace_hash_count function Steven Rostedt
2026-02-04 12:06     ` Jiri Olsa
2026-02-03  9:38 ` [RFC bpf-next 02/12] bpf: Add struct bpf_trampoline_ops object Jiri Olsa
2026-02-03  9:38 ` [RFC bpf-next 03/12] bpf: Add struct bpf_struct_ops_tramp_link object Jiri Olsa
2026-02-03  9:38 ` [RFC bpf-next 04/12] bpf: Add struct bpf_tramp_node object Jiri Olsa
2026-02-04 19:00   ` Andrii Nakryiko
2026-02-05  8:57     ` Jiri Olsa
2026-02-05 22:27       ` Andrii Nakryiko
2026-02-06  8:27         ` Jiri Olsa
2026-02-03  9:38 ` [RFC bpf-next 05/12] bpf: Add multi tracing attach types Jiri Olsa
2026-02-03 10:13   ` bot+bpf-ci
2026-02-17 22:05     ` Jiri Olsa
2026-02-04  2:20   ` Leon Hwang
2026-02-04 12:41     ` Jiri Olsa
2026-02-03  9:38 ` [RFC bpf-next 06/12] bpf: Add bpf_trampoline_multi_attach/detach functions Jiri Olsa
2026-02-03 10:14   ` bot+bpf-ci
2026-02-17 22:05     ` Jiri Olsa
2026-02-05  9:16   ` Menglong Dong
2026-02-05 13:45     ` Jiri Olsa
2026-02-11  8:04       ` Menglong Dong
2026-02-03  9:38 ` [RFC bpf-next 07/12] bpf: Add support to create tracing multi link Jiri Olsa
2026-02-03 10:13   ` bot+bpf-ci
2026-02-17 22:05     ` Jiri Olsa
2026-02-04 19:05   ` Andrii Nakryiko
2026-02-05  8:55     ` Jiri Olsa
2026-02-03  9:38 ` [RFC bpf-next 08/12] libbpf: Add btf__find_by_glob_kind function Jiri Olsa
2026-02-03 10:14   ` bot+bpf-ci
2026-02-04 19:04   ` Andrii Nakryiko
2026-02-05  8:57     ` Jiri Olsa
2026-02-05 22:45       ` Andrii Nakryiko
2026-02-06  8:43         ` Jiri Olsa
2026-02-06 16:58           ` Andrii Nakryiko
2026-02-03  9:38 ` [RFC bpf-next 09/12] libbpf: Add support to create tracing multi link Jiri Olsa
2026-02-03 10:14   ` bot+bpf-ci
2026-02-17 22:05     ` Jiri Olsa
2026-02-04 19:05   ` Andrii Nakryiko
2026-02-17 22:06     ` Jiri Olsa
2026-02-03  9:38 ` [RFC bpf-next 10/12] selftests/bpf: Add fentry tracing multi func test Jiri Olsa
2026-02-03 10:13   ` bot+bpf-ci
2026-02-17 22:06     ` Jiri Olsa
2026-02-03  9:38 ` [RFC bpf-next 11/12] selftests/bpf: Add fentry intersected " Jiri Olsa
2026-02-03  9:38 ` [RFC bpf-next 12/12] selftests/bpf: Add tracing multi benchmark test Jiri Olsa
2026-02-03 10:13   ` bot+bpf-ci
2026-02-17 22:06     ` Jiri Olsa
2026-02-03 23:17 ` [RFC bpf-next 00/12] bpf: tracing_multi link Alexei Starovoitov
2026-02-04 12:36   ` Jiri Olsa
2026-02-04 16:06     ` Alexei Starovoitov
2026-02-05  8:55       ` Jiri Olsa
2026-02-05 15:55         ` Alexei Starovoitov
2026-02-06  8:18           ` Jiri Olsa
2026-02-06 17:03             ` Andrii Nakryiko
2026-02-08 20:54               ` Jiri Olsa

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=20260203093819.2105105-2-jolsa@kernel.org \
    --to=jolsa@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=kafai@fb.com \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=menglong8.dong@gmail.com \
    --cc=rostedt@kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /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