Skip to content

Commit d66bb33

Browse files
committed
ftrace: Add comments to ftrace_hash_move() and friends
Describe what ftrace_hash_move() does and add some more comments to some other functions to make it easier to understand. Link: https://lore.kernel.org/linux-trace-kernel/[email protected] Cc: Mathieu Desnoyers <[email protected]> Cc: Andrew Morton <[email protected]> Acked-by: Mark Rutland <[email protected]> Acked-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 1a88c07 commit d66bb33

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

kernel/trace/ftrace.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ static inline void ftrace_ops_init(struct ftrace_ops *ops)
169169
#endif
170170
}
171171

172+
/* Call this function for when a callback filters on set_ftrace_pid */
172173
static void ftrace_pid_func(unsigned long ip, unsigned long parent_ip,
173174
struct ftrace_ops *op, struct ftrace_regs *fregs)
174175
{
@@ -1318,7 +1319,7 @@ static struct ftrace_hash *alloc_ftrace_hash(int size_bits)
13181319
return hash;
13191320
}
13201321

1321-
1322+
/* Used to save filters on functions for modules not loaded yet */
13221323
static int ftrace_add_mod(struct trace_array *tr,
13231324
const char *func, const char *module,
13241325
int enable)
@@ -1430,6 +1431,7 @@ static struct ftrace_hash *__move_hash(struct ftrace_hash *src, int size)
14301431
return new_hash;
14311432
}
14321433

1434+
/* Move the @src entries to a newly allocated hash */
14331435
static struct ftrace_hash *
14341436
__ftrace_hash_move(struct ftrace_hash *src)
14351437
{
@@ -1444,6 +1446,26 @@ __ftrace_hash_move(struct ftrace_hash *src)
14441446
return __move_hash(src, size);
14451447
}
14461448

1449+
/**
1450+
* ftrace_hash_move - move a new hash to a filter and do updates
1451+
* @ops: The ops with the hash that @dst points to
1452+
* @enable: True if for the filter hash, false for the notrace hash
1453+
* @dst: Points to the @ops hash that should be updated
1454+
* @src: The hash to update @dst with
1455+
*
1456+
* This is called when an ftrace_ops hash is being updated and the
1457+
* the kernel needs to reflect this. Note, this only updates the kernel
1458+
* function callbacks if the @ops is enabled (not to be confused with
1459+
* @enable above). If the @ops is enabled, its hash determines what
1460+
* callbacks get called. This function gets called when the @ops hash
1461+
* is updated and it requires new callbacks.
1462+
*
1463+
* On success the elements of @src is moved to @dst, and @dst is updated
1464+
* properly, as well as the functions determined by the @ops hashes
1465+
* are now calling the @ops callback function.
1466+
*
1467+
* Regardless of return type, @src should be freed with free_ftrace_hash().
1468+
*/
14471469
static int
14481470
ftrace_hash_move(struct ftrace_ops *ops, int enable,
14491471
struct ftrace_hash **dst, struct ftrace_hash *src)

0 commit comments

Comments
 (0)