Lines Matching +full:ftrace +full:- +full:size
1 // SPDX-License-Identifier: GPL-2.0
3 * fprobe - Simple ftrace probe wrapper for function entry.
35 if (fp->exit_handler) { in __fprobe_handler()
36 rh = rethook_try_get(fp->rethook); in __fprobe_handler()
38 fp->nmissed++; in __fprobe_handler()
42 fpr->entry_ip = ip; in __fprobe_handler()
43 fpr->entry_parent_ip = parent_ip; in __fprobe_handler()
44 if (fp->entry_data_size) in __fprobe_handler()
45 entry_data = fpr->data; in __fprobe_handler()
48 if (fp->entry_handler) in __fprobe_handler()
49 ret = fp->entry_handler(fp, ip, parent_ip, ftrace_get_regs(fregs), entry_data); in __fprobe_handler()
75 fp->nmissed++; in fprobe_handler()
99 fp->nmissed++; in fprobe_kprobe_handler()
110 fp->nmissed++; in fprobe_kprobe_handler()
135 * we need to assure no calls to traceable functions in-between the in fprobe_exit_handler()
138 bit = ftrace_test_recursion_trylock(fpr->entry_ip, fpr->entry_parent_ip); in fprobe_exit_handler()
140 fp->nmissed++; in fprobe_exit_handler()
144 fp->exit_handler(fp, fpr->entry_ip, ret_ip, regs, in fprobe_exit_handler()
145 fp->entry_data_size ? (void *)fpr->data : NULL); in fprobe_exit_handler()
158 /* Convert ftrace location address from symbols */
166 return ERR_PTR(-ENOMEM); in get_ftrace_locations()
175 return ERR_PTR(-ENOENT); in get_ftrace_locations()
180 fp->nmissed = 0; in fprobe_init()
182 fp->ops.func = fprobe_kprobe_handler; in fprobe_init()
184 fp->ops.func = fprobe_handler; in fprobe_init()
185 fp->ops.flags |= FTRACE_OPS_FL_SAVE_REGS; in fprobe_init()
190 int size; in fprobe_init_rethook() local
192 if (!fp->exit_handler) { in fprobe_init_rethook()
193 fp->rethook = NULL; in fprobe_init_rethook()
198 if (fp->nr_maxactive) in fprobe_init_rethook()
199 num = fp->nr_maxactive; in fprobe_init_rethook()
203 return -EINVAL; in fprobe_init_rethook()
205 size = sizeof(struct fprobe_rethook_node) + fp->entry_data_size; in fprobe_init_rethook()
208 fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler, size, num); in fprobe_init_rethook()
209 if (IS_ERR(fp->rethook)) in fprobe_init_rethook()
210 return PTR_ERR(fp->rethook); in fprobe_init_rethook()
217 if (!IS_ERR_OR_NULL(fp->rethook)) { in fprobe_fail_cleanup()
218 /* Don't need to cleanup rethook->handler because this is not used. */ in fprobe_fail_cleanup()
219 rethook_free(fp->rethook); in fprobe_fail_cleanup()
220 fp->rethook = NULL; in fprobe_fail_cleanup()
222 ftrace_free_filter(&fp->ops); in fprobe_fail_cleanup()
226 * register_fprobe() - Register fprobe to ftrace by pattern.
231 * Register @fp to ftrace for enabling the probe on the symbols matched to @filter.
234 * Return 0 if @fp is registered successfully, -errno if not.
243 return -EINVAL; in register_fprobe()
249 ret = ftrace_set_filter(&fp->ops, str, len, 0); in register_fprobe()
257 ret = ftrace_set_notrace(&fp->ops, str, len, 0); in register_fprobe()
267 hash = rcu_access_pointer(fp->ops.local_hash.filter_hash); in register_fprobe()
271 ret = fprobe_init_rethook(fp, (int)hash->count); in register_fprobe()
273 ret = register_ftrace_function(&fp->ops); in register_fprobe()
283 * register_fprobe_ips() - Register fprobe to ftrace by address.
285 * @addrs: An array of target ftrace location addresses.
288 * Register @fp to ftrace for enabling the probe on the address given by @addrs.
289 * The @addrs must be the addresses of ftrace location address, which may be
290 * the symbol address + arch-dependent offset.
293 * Return 0 if @fp is registered successfully, -errno if not.
300 return -EINVAL; in register_fprobe_ips()
304 ret = ftrace_set_filter_ips(&fp->ops, addrs, num, 0, 0); in register_fprobe_ips()
310 ret = register_ftrace_function(&fp->ops); in register_fprobe_ips()
319 * register_fprobe_syms() - Register fprobe to ftrace by symbols.
327 * Return 0 if @fp is registered successfully, -errno if not.
335 return -EINVAL; in register_fprobe_syms()
351 if (!fp || (fp->ops.saved_func != fprobe_handler && in fprobe_is_registered()
352 fp->ops.saved_func != fprobe_kprobe_handler)) in fprobe_is_registered()
358 * unregister_fprobe() - Unregister fprobe from ftrace
361 * Unregister fprobe (and remove ftrace hooks from the function entries).
363 * Return 0 if @fp is unregistered successfully, -errno if not.
370 return -EINVAL; in unregister_fprobe()
372 if (!IS_ERR_OR_NULL(fp->rethook)) in unregister_fprobe()
373 rethook_stop(fp->rethook); in unregister_fprobe()
375 ret = unregister_ftrace_function(&fp->ops); in unregister_fprobe()
379 if (!IS_ERR_OR_NULL(fp->rethook)) in unregister_fprobe()
380 rethook_free(fp->rethook); in unregister_fprobe()
382 ftrace_free_filter(&fp->ops); in unregister_fprobe()