Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ftrace: Export some of hash related functions

We are going to use these functions in following changes.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Link: https://lore.kernel.org/bpf/20251230145010.103439-4-jolsa@kernel.org

authored by

Jiri Olsa and committed by
Andrii Nakryiko
0e860d07 676bfeae

+15 -7
+9
include/linux/ftrace.h
··· 82 82 83 83 struct module; 84 84 struct ftrace_hash; 85 + struct ftrace_func_entry; 85 86 86 87 #if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_MODULES) && \ 87 88 defined(CONFIG_DYNAMIC_FTRACE) ··· 406 405 typedef int (*ftrace_ops_func_t)(struct ftrace_ops *op, enum ftrace_ops_cmd cmd); 407 406 408 407 #ifdef CONFIG_DYNAMIC_FTRACE 408 + 409 + #define FTRACE_HASH_DEFAULT_BITS 10 410 + 411 + struct ftrace_hash *alloc_ftrace_hash(int size_bits); 412 + void free_ftrace_hash(struct ftrace_hash *hash); 413 + struct ftrace_func_entry *add_ftrace_hash_entry_direct(struct ftrace_hash *hash, 414 + unsigned long ip, unsigned long direct); 415 + 409 416 /* The hash used to know what functions callbacks trace */ 410 417 struct ftrace_ops_hash { 411 418 struct ftrace_hash __rcu *notrace_hash;
+6 -7
kernel/trace/ftrace.c
··· 68 68 }) 69 69 70 70 /* hash bits for specific function selection */ 71 - #define FTRACE_HASH_DEFAULT_BITS 10 72 71 #define FTRACE_HASH_MAX_BITS 12 73 72 74 73 #ifdef CONFIG_DYNAMIC_FTRACE ··· 1210 1211 hash->count++; 1211 1212 } 1212 1213 1213 - static struct ftrace_func_entry * 1214 - add_hash_entry_direct(struct ftrace_hash *hash, unsigned long ip, unsigned long direct) 1214 + struct ftrace_func_entry * 1215 + add_ftrace_hash_entry_direct(struct ftrace_hash *hash, unsigned long ip, unsigned long direct) 1215 1216 { 1216 1217 struct ftrace_func_entry *entry; 1217 1218 ··· 1229 1230 static struct ftrace_func_entry * 1230 1231 add_hash_entry(struct ftrace_hash *hash, unsigned long ip) 1231 1232 { 1232 - return add_hash_entry_direct(hash, ip, 0); 1233 + return add_ftrace_hash_entry_direct(hash, ip, 0); 1233 1234 } 1234 1235 1235 1236 static void ··· 1290 1291 mutex_unlock(&ftrace_lock); 1291 1292 } 1292 1293 1293 - static void free_ftrace_hash(struct ftrace_hash *hash) 1294 + void free_ftrace_hash(struct ftrace_hash *hash) 1294 1295 { 1295 1296 if (!hash || hash == EMPTY_HASH) 1296 1297 return; ··· 1330 1331 } 1331 1332 EXPORT_SYMBOL_GPL(ftrace_free_filter); 1332 1333 1333 - static struct ftrace_hash *alloc_ftrace_hash(int size_bits) 1334 + struct ftrace_hash *alloc_ftrace_hash(int size_bits) 1334 1335 { 1335 1336 struct ftrace_hash *hash; 1336 1337 int size; ··· 1404 1405 size = 1 << hash->size_bits; 1405 1406 for (i = 0; i < size; i++) { 1406 1407 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { 1407 - if (add_hash_entry_direct(new_hash, entry->ip, entry->direct) == NULL) 1408 + if (add_ftrace_hash_entry_direct(new_hash, entry->ip, entry->direct) == NULL) 1408 1409 goto free_hash; 1409 1410 } 1410 1411 }