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 i, size; in fprobe_init_rethook() local
193 return -EINVAL; in fprobe_init_rethook()
195 if (!fp->exit_handler) { in fprobe_init_rethook()
196 fp->rethook = NULL; in fprobe_init_rethook()
201 if (fp->nr_maxactive) in fprobe_init_rethook()
202 size = fp->nr_maxactive; in fprobe_init_rethook()
204 size = num * num_possible_cpus() * 2; in fprobe_init_rethook()
205 if (size <= 0) in fprobe_init_rethook()
206 return -EINVAL; in fprobe_init_rethook()
208 fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler); in fprobe_init_rethook()
209 if (!fp->rethook) in fprobe_init_rethook()
210 return -ENOMEM; in fprobe_init_rethook()
211 for (i = 0; i < size; i++) { in fprobe_init_rethook()
214 node = kzalloc(sizeof(*node) + fp->entry_data_size, GFP_KERNEL); in fprobe_init_rethook()
216 rethook_free(fp->rethook); in fprobe_init_rethook()
217 fp->rethook = NULL; in fprobe_init_rethook()
218 return -ENOMEM; in fprobe_init_rethook()
220 rethook_add_node(fp->rethook, &node->node); in fprobe_init_rethook()
227 if (fp->rethook) { in fprobe_fail_cleanup()
228 /* Don't need to cleanup rethook->handler because this is not used. */ in fprobe_fail_cleanup()
229 rethook_free(fp->rethook); in fprobe_fail_cleanup()
230 fp->rethook = NULL; in fprobe_fail_cleanup()
232 ftrace_free_filter(&fp->ops); in fprobe_fail_cleanup()
236 * register_fprobe() - Register fprobe to ftrace by pattern.
241 * Register @fp to ftrace for enabling the probe on the symbols matched to @filter.
244 * Return 0 if @fp is registered successfully, -errno if not.
253 return -EINVAL; in register_fprobe()
259 ret = ftrace_set_filter(&fp->ops, str, len, 0); in register_fprobe()
267 ret = ftrace_set_notrace(&fp->ops, str, len, 0); in register_fprobe()
277 hash = rcu_access_pointer(fp->ops.local_hash.filter_hash); in register_fprobe()
281 ret = fprobe_init_rethook(fp, (int)hash->count); in register_fprobe()
283 ret = register_ftrace_function(&fp->ops); in register_fprobe()
293 * register_fprobe_ips() - Register fprobe to ftrace by address.
295 * @addrs: An array of target ftrace location addresses.
298 * Register @fp to ftrace for enabling the probe on the address given by @addrs.
299 * The @addrs must be the addresses of ftrace location address, which may be
300 * the symbol address + arch-dependent offset.
303 * Return 0 if @fp is registered successfully, -errno if not.
310 return -EINVAL; in register_fprobe_ips()
314 ret = ftrace_set_filter_ips(&fp->ops, addrs, num, 0, 0); in register_fprobe_ips()
320 ret = register_ftrace_function(&fp->ops); in register_fprobe_ips()
329 * register_fprobe_syms() - Register fprobe to ftrace by symbols.
337 * Return 0 if @fp is registered successfully, -errno if not.
345 return -EINVAL; in register_fprobe_syms()
361 if (!fp || (fp->ops.saved_func != fprobe_handler && in fprobe_is_registered()
362 fp->ops.saved_func != fprobe_kprobe_handler)) in fprobe_is_registered()
368 * unregister_fprobe() - Unregister fprobe from ftrace
371 * Unregister fprobe (and remove ftrace hooks from the function entries).
373 * Return 0 if @fp is unregistered successfully, -errno if not.
380 return -EINVAL; in unregister_fprobe()
382 if (fp->rethook) in unregister_fprobe()
383 rethook_stop(fp->rethook); in unregister_fprobe()
385 ret = unregister_ftrace_function(&fp->ops); in unregister_fprobe()
389 if (fp->rethook) in unregister_fprobe()
390 rethook_free(fp->rethook); in unregister_fprobe()
392 ftrace_free_filter(&fp->ops); in unregister_fprobe()