Lines Matching +full:ftrace +full:- +full:size

1 // SPDX-License-Identifier: GPL-2.0
3 * Infrastructure for profiling code inserted by 'gcc -pg'.
5 * Copyright (C) 2007-2008 Steven Rostedt <srostedt@redhat.com>
6 * Copyright (C) 2004-2008 Ingo Molnar <mingo@redhat.com>
8 * Originally ported from the -rt patch by:
13 * Copyright (C) 2004-2006 Ingo Molnar
29 #include <linux/ftrace.h>
93 /* ftrace_enabled is a method to turn ftrace on or off */
106 if (!(ops->flags & FTRACE_OPS_FL_PID) || !ops->private) in ftrace_pids_enabled()
109 tr = ops->private; in ftrace_pids_enabled()
111 return tr->function_pids != NULL || tr->function_no_pids != NULL; in ftrace_pids_enabled()
162 if (!(ops->flags & FTRACE_OPS_FL_INITIALIZED)) { in ftrace_ops_init()
163 mutex_init(&ops->local_hash.regex_lock); in ftrace_ops_init()
164 ops->func_hash = &ops->local_hash; in ftrace_ops_init()
165 ops->flags |= FTRACE_OPS_FL_INITIALIZED; in ftrace_ops_init()
173 struct trace_array *tr = op->private; in ftrace_pid_func()
177 pid = this_cpu_read(tr->array_buffer.data->ftrace_ignore_pid); in ftrace_pid_func()
181 pid != current->pid) in ftrace_pid_func()
185 op->saved_func(ip, parent_ip, op, fregs); in ftrace_pid_func()
200 if (ops->flags & (FTRACE_OPS_FL_DYNAMIC | FTRACE_OPS_FL_RCU) || in ftrace_ops_get_list_func()
228 } else if (rcu_dereference_protected(ftrace_ops_list->next, in update_ftrace_function()
289 rcu_assign_pointer(ops->next, *list); in add_ftrace_ops()
294 * the ops->next pointer is valid before another CPU sees in add_ftrace_ops()
311 rcu_dereference_protected(ops->next, in remove_ftrace_ops()
317 for (p = list; *p != &ftrace_list_end; p = &(*p)->next) in remove_ftrace_ops()
322 return -1; in remove_ftrace_ops()
324 *p = (*p)->next; in remove_ftrace_ops()
332 if (ops->flags & FTRACE_OPS_FL_DELETED) in __register_ftrace_function()
333 return -EINVAL; in __register_ftrace_function()
335 if (WARN_ON(ops->flags & FTRACE_OPS_FL_ENABLED)) in __register_ftrace_function()
336 return -EBUSY; in __register_ftrace_function()
344 if (ops->flags & FTRACE_OPS_FL_SAVE_REGS && in __register_ftrace_function()
345 !(ops->flags & FTRACE_OPS_FL_SAVE_REGS_IF_SUPPORTED)) in __register_ftrace_function()
346 return -EINVAL; in __register_ftrace_function()
348 if (ops->flags & FTRACE_OPS_FL_SAVE_REGS_IF_SUPPORTED) in __register_ftrace_function()
349 ops->flags |= FTRACE_OPS_FL_SAVE_REGS; in __register_ftrace_function()
351 if (!ftrace_enabled && (ops->flags & FTRACE_OPS_FL_PERMANENT)) in __register_ftrace_function()
352 return -EBUSY; in __register_ftrace_function()
355 ops->flags |= FTRACE_OPS_FL_DYNAMIC; in __register_ftrace_function()
360 ops->saved_func = ops->func; in __register_ftrace_function()
363 ops->func = ftrace_pid_func; in __register_ftrace_function()
377 if (WARN_ON(!(ops->flags & FTRACE_OPS_FL_ENABLED))) in __unregister_ftrace_function()
378 return -EBUSY; in __unregister_ftrace_function()
388 ops->func = ops->saved_func; in __unregister_ftrace_function()
402 if (op->flags & FTRACE_OPS_FL_PID) { in ftrace_update_pid_func()
403 op->func = ftrace_pids_enabled(op) ? in ftrace_update_pid_func()
404 ftrace_pid_func : op->saved_func; in ftrace_update_pid_func()
438 (PAGE_SIZE - offsetof(struct ftrace_profile_page, records))
445 /* ftrace_profile_lock - synchronize the enable and disable of the profiler */
465 if ((void *)rec >= (void *)&pg->records[pg->index]) { in function_stat_next()
466 pg = pg->next; in function_stat_next()
469 rec = &pg->records[0]; in function_stat_next()
470 if (!rec->counter) in function_stat_next()
482 if (!stat || !stat->start) in function_stat_start()
485 return function_stat_next(&stat->start->records[0], 0); in function_stat_start()
495 if (a->time < b->time) in function_stat_cmp()
496 return -1; in function_stat_cmp()
497 if (a->time > b->time) in function_stat_cmp()
509 if (a->counter < b->counter) in function_stat_cmp()
510 return -1; in function_stat_cmp()
511 if (a->counter > b->counter) in function_stat_cmp()
523 " -------- " in function_stat_headers()
524 "--- ---- --- ---\n"); in function_stat_headers()
527 " -------- ---\n"); in function_stat_headers()
546 if (unlikely(rec->counter == 0)) { in function_stat_show()
547 ret = -EBUSY; in function_stat_show()
552 avg = div64_ul(rec->time, rec->counter); in function_stat_show()
557 kallsyms_lookup(rec->ip, NULL, NULL, NULL, str); in function_stat_show()
558 seq_printf(m, " %-30.30s %10lu", str, rec->counter); in function_stat_show()
565 * s^2 = 1 / (n * (n-1)) * (n * \Sum (x_i)^2 - (\Sum x_i)^2) in function_stat_show()
567 * Divide only by 1000 for ns^2 -> us^2 conversion. in function_stat_show()
571 stddev_denom = rec->counter * (rec->counter - 1) * 1000; in function_stat_show()
573 stddev = rec->counter * rec->time_squared - in function_stat_show()
574 rec->time * rec->time; in function_stat_show()
579 trace_print_graph_duration(rec->time, &s); in function_stat_show()
597 pg = stat->pages = stat->start; in ftrace_profile_reset()
600 memset(pg->records, 0, PROFILE_RECORDS_SIZE); in ftrace_profile_reset()
601 pg->index = 0; in ftrace_profile_reset()
602 pg = pg->next; in ftrace_profile_reset()
605 memset(stat->hash, 0, in ftrace_profile_reset()
617 if (stat->pages) in ftrace_profile_pages_init()
620 stat->pages = (void *)get_zeroed_page(GFP_KERNEL); in ftrace_profile_pages_init()
621 if (!stat->pages) in ftrace_profile_pages_init()
622 return -ENOMEM; in ftrace_profile_pages_init()
637 pg = stat->start = stat->pages; in ftrace_profile_pages_init()
642 pg->next = (void *)get_zeroed_page(GFP_KERNEL); in ftrace_profile_pages_init()
643 if (!pg->next) in ftrace_profile_pages_init()
645 pg = pg->next; in ftrace_profile_pages_init()
651 pg = stat->start; in ftrace_profile_pages_init()
655 pg = pg->next; in ftrace_profile_pages_init()
659 stat->pages = NULL; in ftrace_profile_pages_init()
660 stat->start = NULL; in ftrace_profile_pages_init()
662 return -ENOMEM; in ftrace_profile_pages_init()
668 int size; in ftrace_profile_init_cpu() local
672 if (stat->hash) { in ftrace_profile_init_cpu()
682 size = FTRACE_PROFILE_HASH_SIZE; in ftrace_profile_init_cpu()
684 stat->hash = kcalloc(size, sizeof(struct hlist_head), GFP_KERNEL); in ftrace_profile_init_cpu()
686 if (!stat->hash) in ftrace_profile_init_cpu()
687 return -ENOMEM; in ftrace_profile_init_cpu()
691 kfree(stat->hash); in ftrace_profile_init_cpu()
692 stat->hash = NULL; in ftrace_profile_init_cpu()
693 return -ENOMEM; in ftrace_profile_init_cpu()
722 hhd = &stat->hash[key]; in ftrace_find_profiled_func()
728 if (rec->ip == ip) in ftrace_find_profiled_func()
740 key = hash_long(rec->ip, FTRACE_PROFILE_HASH_BITS); in ftrace_add_profile()
741 hlist_add_head_rcu(&rec->node, &stat->hash[key]); in ftrace_add_profile()
753 if (atomic_inc_return(&stat->disabled) != 1) in ftrace_profile_alloc()
764 if (stat->pages->index == PROFILES_PER_PAGE) { in ftrace_profile_alloc()
765 if (!stat->pages->next) in ftrace_profile_alloc()
767 stat->pages = stat->pages->next; in ftrace_profile_alloc()
770 rec = &stat->pages->records[stat->pages->index++]; in ftrace_profile_alloc()
771 rec->ip = ip; in ftrace_profile_alloc()
775 atomic_dec(&stat->disabled); in ftrace_profile_alloc()
794 if (!stat->hash || !ftrace_profile_enabled) in function_profile_call()
804 rec->counter++; in function_profile_call()
821 function_profile_call(trace->func, 0, NULL, NULL); in profile_graph_entry()
824 if (!current->ret_stack) in profile_graph_entry()
829 ret_stack->subtime = 0; in profile_graph_entry()
844 if (!stat->hash || !ftrace_profile_enabled) in profile_graph_return()
848 if (!trace->calltime) in profile_graph_return()
851 calltime = trace->rettime - trace->calltime; in profile_graph_return()
858 ret_stack->subtime += calltime; in profile_graph_return()
861 if (ret_stack && ret_stack->subtime < calltime) in profile_graph_return()
862 calltime -= ret_stack->subtime; in profile_graph_return()
867 rec = ftrace_find_profiled_func(stat, trace->func); in profile_graph_return()
869 rec->time += calltime; in profile_graph_return()
870 rec->time_squared += calltime * calltime; in profile_graph_return()
1003 stat->stat = function_stats; in ftrace_profile_tracefs()
1004 stat->stat.name = name; in ftrace_profile_tracefs()
1005 ret = register_stat_tracer(&stat->stat); in ftrace_profile_tracefs()
1037 # error Dynamic ftrace depends on MCOUNT_RECORD
1071 * Used by the stack unwinder to know about dynamic ftrace trampolines.
1089 if (op->trampoline && op->trampoline_size) in ftrace_ops_trampoline()
1090 if (addr >= op->trampoline && in ftrace_ops_trampoline()
1091 addr < op->trampoline + op->trampoline_size) { in ftrace_ops_trampoline()
1128 if (hash->size_bits > 0) in ftrace_hash_key()
1129 return hash_long(ip, hash->size_bits); in ftrace_hash_key()
1143 hhd = &hash->buckets[key]; in __ftrace_lookup_ip()
1146 if (entry->ip == ip) in __ftrace_lookup_ip()
1153 * ftrace_lookup_ip - Test to see if an ip exists in an ftrace_hash
1177 key = ftrace_hash_key(hash, entry->ip); in __add_hash_entry()
1178 hhd = &hash->buckets[key]; in __add_hash_entry()
1179 hlist_add_head(&entry->hlist, hhd); in __add_hash_entry()
1180 hash->count++; in __add_hash_entry()
1192 entry->ip = ip; in add_hash_entry()
1202 hlist_del(&entry->hlist); in free_hash_entry()
1204 hash->count--; in free_hash_entry()
1211 hlist_del_rcu(&entry->hlist); in remove_hash_entry()
1212 hash->count--; in remove_hash_entry()
1220 int size = 1 << hash->size_bits; in ftrace_hash_clear() local
1223 if (!hash->count) in ftrace_hash_clear()
1226 for (i = 0; i < size; i++) { in ftrace_hash_clear()
1227 hhd = &hash->buckets[i]; in ftrace_hash_clear()
1231 FTRACE_WARN_ON(hash->count); in ftrace_hash_clear()
1236 list_del(&ftrace_mod->list); in free_ftrace_mod()
1237 kfree(ftrace_mod->module); in free_ftrace_mod()
1238 kfree(ftrace_mod->func); in free_ftrace_mod()
1261 kfree(hash->buckets); in free_ftrace_hash()
1277 call_rcu(&hash->rcu, __free_ftrace_hash_rcu); in free_ftrace_hash_rcu()
1281 * ftrace_free_filter - remove all filters for an ftrace_ops
1282 * @ops - the ops to remove the filters from
1287 free_ftrace_hash(ops->func_hash->filter_hash); in ftrace_free_filter()
1288 free_ftrace_hash(ops->func_hash->notrace_hash); in ftrace_free_filter()
1295 int size; in alloc_ftrace_hash() local
1301 size = 1 << size_bits; in alloc_ftrace_hash()
1302 hash->buckets = kcalloc(size, sizeof(*hash->buckets), GFP_KERNEL); in alloc_ftrace_hash()
1304 if (!hash->buckets) { in alloc_ftrace_hash()
1309 hash->size_bits = size_bits; in alloc_ftrace_hash()
1320 struct list_head *mod_head = enable ? &tr->mod_trace : &tr->mod_notrace; in ftrace_add_mod()
1324 return -ENOMEM; in ftrace_add_mod()
1326 INIT_LIST_HEAD(&ftrace_mod->list); in ftrace_add_mod()
1327 ftrace_mod->func = kstrdup(func, GFP_KERNEL); in ftrace_add_mod()
1328 ftrace_mod->module = kstrdup(module, GFP_KERNEL); in ftrace_add_mod()
1329 ftrace_mod->enable = enable; in ftrace_add_mod()
1331 if (!ftrace_mod->func || !ftrace_mod->module) in ftrace_add_mod()
1334 list_add(&ftrace_mod->list, mod_head); in ftrace_add_mod()
1341 return -ENOMEM; in ftrace_add_mod()
1349 int size; in alloc_and_copy_ftrace_hash() local
1357 new_hash->flags = hash->flags; in alloc_and_copy_ftrace_hash()
1363 size = 1 << hash->size_bits; in alloc_and_copy_ftrace_hash()
1364 for (i = 0; i < size; i++) { in alloc_and_copy_ftrace_hash()
1365 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in alloc_and_copy_ftrace_hash()
1366 if (add_hash_entry(new_hash, entry->ip) == NULL) in alloc_and_copy_ftrace_hash()
1371 FTRACE_WARN_ON(new_hash->count != hash->count); in alloc_and_copy_ftrace_hash()
1388 static struct ftrace_hash *dup_hash(struct ftrace_hash *src, int size) in dup_hash() argument
1398 * Use around half the size (max bit of it), but in dup_hash()
1399 * a minimum of 2 is fine (as size of 0 or 1 both give 1 for bits). in dup_hash()
1401 bits = fls(size / 2); in dup_hash()
1411 new_hash->flags = src->flags; in dup_hash()
1413 size = 1 << src->size_bits; in dup_hash()
1414 for (i = 0; i < size; i++) { in dup_hash()
1415 hhd = &src->buckets[i]; in dup_hash()
1427 int size = src->count; in __ftrace_hash_move() local
1435 return dup_hash(src, size); in __ftrace_hash_move()
1446 if (ops->flags & FTRACE_OPS_FL_IPMODIFY && !enable) in ftrace_hash_move()
1447 return -EINVAL; in ftrace_hash_move()
1451 return -ENOMEM; in ftrace_hash_move()
1485 return (ftrace_hash_empty(hash->filter_hash) || in hash_contains_ip()
1486 __ftrace_lookup_ip(hash->filter_hash, ip)) && in hash_contains_ip()
1487 (ftrace_hash_empty(hash->notrace_hash) || in hash_contains_ip()
1488 !__ftrace_lookup_ip(hash->notrace_hash, ip)); in hash_contains_ip()
1493 * the ops->func or not.
1495 * It's a match if the ip is in the ops->filter_hash or
1498 * the ip is not in the ops->notrace_hash.
1511 * There's a small race when adding ops that the ftrace handler in ftrace_ops_test()
1515 if (regs == NULL && (ops->flags & FTRACE_OPS_FL_SAVE_REGS)) in ftrace_ops_test()
1519 rcu_assign_pointer(hash.filter_hash, ops->func_hash->filter_hash); in ftrace_ops_test()
1520 rcu_assign_pointer(hash.notrace_hash, ops->func_hash->notrace_hash); in ftrace_ops_test()
1535 for (pg = ftrace_pages_start; pg; pg = pg->next) { \
1537 for (_____i = 0; _____i < pg->index; _____i++) { \
1538 rec = &pg->records[_____i];
1550 if (key->flags < rec->ip) in ftrace_cmp_recs()
1551 return -1; in ftrace_cmp_recs()
1552 if (key->ip >= rec->ip + MCOUNT_INSN_SIZE) in ftrace_cmp_recs()
1566 for (pg = ftrace_pages_start; pg; pg = pg->next) { in lookup_rec()
1567 if (pg->index == 0 || in lookup_rec()
1568 end < pg->records[0].ip || in lookup_rec()
1569 start >= (pg->records[pg->index - 1].ip + MCOUNT_INSN_SIZE)) in lookup_rec()
1571 rec = bsearch(&key, pg->records, pg->index, in lookup_rec()
1581 * ftrace_location_range - return the first address of a traced location
1587 * Returns rec->ip if the related ftrace location is a least partly within
1589 * that is either a NOP or call to the function tracer. It checks the ftrace
1600 ip = rec->ip; in ftrace_location_range()
1607 * ftrace_location - return the ftrace location
1610 * If @ip matches the ftrace location, return @ip.
1611 * If @ip matches sym+0, return sym's ftrace location.
1618 unsigned long size; in ftrace_location() local
1622 if (!kallsyms_lookup_size_offset(ip, &size, &offset)) in ftrace_location()
1627 loc = ftrace_location_range(ip, ip + size - 1); in ftrace_location()
1635 * ftrace_text_reserved - return true if range contains an ftrace location
1639 * Returns 1 if @start and @end contains a ftrace location.
1641 * the function tracer. It checks the ftrace internal tables to
1661 ops != &ftrace_list_end; ops = ops->next) { in test_rec_ops_needs_regs()
1662 /* pass rec in as regs to have non-NULL val */ in test_rec_ops_needs_regs()
1663 if (ftrace_ops_test(ops, rec->ip, rec)) { in test_rec_ops_needs_regs()
1664 if (ops->flags & FTRACE_OPS_FL_SAVE_REGS) { in test_rec_ops_needs_regs()
1689 return rec->flags & FTRACE_FL_DISABLED && in skip_record()
1690 !(rec->flags & FTRACE_FL_ENABLED); in skip_record()
1706 if (!(ops->flags & FTRACE_OPS_FL_ENABLED)) in __ftrace_hash_rec_update()
1721 hash = ops->func_hash->filter_hash; in __ftrace_hash_rec_update()
1722 other_hash = ops->func_hash->notrace_hash; in __ftrace_hash_rec_update()
1727 hash = ops->func_hash->notrace_hash; in __ftrace_hash_rec_update()
1728 other_hash = ops->func_hash->filter_hash; in __ftrace_hash_rec_update()
1750 if (!other_hash || !ftrace_lookup_ip(other_hash, rec->ip)) in __ftrace_hash_rec_update()
1753 in_hash = !!ftrace_lookup_ip(hash, rec->ip); in __ftrace_hash_rec_update()
1754 in_other_hash = !!ftrace_lookup_ip(other_hash, rec->ip); in __ftrace_hash_rec_update()
1776 rec->flags++; in __ftrace_hash_rec_update()
1780 if (ops->flags & FTRACE_OPS_FL_DIRECT) in __ftrace_hash_rec_update()
1781 rec->flags |= FTRACE_FL_DIRECT; in __ftrace_hash_rec_update()
1788 if (ftrace_rec_count(rec) == 1 && ops->trampoline) in __ftrace_hash_rec_update()
1789 rec->flags |= FTRACE_FL_TRAMP; in __ftrace_hash_rec_update()
1797 rec->flags &= ~FTRACE_FL_TRAMP; in __ftrace_hash_rec_update()
1803 if (ops->flags & FTRACE_OPS_FL_SAVE_REGS) in __ftrace_hash_rec_update()
1804 rec->flags |= FTRACE_FL_REGS; in __ftrace_hash_rec_update()
1808 rec->flags--; in __ftrace_hash_rec_update()
1816 if (ops->flags & FTRACE_OPS_FL_DIRECT) in __ftrace_hash_rec_update()
1817 rec->flags &= ~FTRACE_FL_DIRECT; in __ftrace_hash_rec_update()
1826 rec->flags & FTRACE_FL_REGS && in __ftrace_hash_rec_update()
1827 ops->flags & FTRACE_OPS_FL_SAVE_REGS) { in __ftrace_hash_rec_update()
1829 rec->flags &= ~FTRACE_FL_REGS; in __ftrace_hash_rec_update()
1841 rec->flags |= FTRACE_FL_TRAMP; in __ftrace_hash_rec_update()
1843 rec->flags &= ~FTRACE_FL_TRAMP; in __ftrace_hash_rec_update()
1852 * If the rec has a single associated ops, and ops->func can be in __ftrace_hash_rec_update()
1857 ftrace_ops_get_func(ops) == ops->func) in __ftrace_hash_rec_update()
1858 rec->flags |= FTRACE_FL_CALL_OPS; in __ftrace_hash_rec_update()
1860 rec->flags &= ~FTRACE_FL_CALL_OPS; in __ftrace_hash_rec_update()
1868 if (!all && count == hash->count) in __ftrace_hash_rec_update()
1894 if (ops->func_hash != &global_ops.local_hash) in ftrace_hash_rec_update_modify()
1905 if (op->func_hash == &global_ops.local_hash) in ftrace_hash_rec_update_modify()
1924 * or no-needed to update, -EBUSY if it detects a conflict of the flag
1925 * on a ftrace_rec, and -EINVAL if the new_hash tries to trace all recs.
1927 * - If the hash is NULL, it hits all recs (if IPMODIFY is set, this is rejected)
1928 * - If the hash is EMPTY_HASH, it hits nothing
1929 * - Anything else hits the recs which match the hash entries.
1934 * IPMODIFY. If ops_func(SHARE_IPMODIFY_SELF) returns non-zero, propagate
1948 if (!(ops->flags & FTRACE_OPS_FL_ENABLED)) in __ftrace_hash_update_ipmodify()
1951 is_ipmodify = ops->flags & FTRACE_OPS_FL_IPMODIFY; in __ftrace_hash_update_ipmodify()
1952 is_direct = ops->flags & FTRACE_OPS_FL_DIRECT; in __ftrace_hash_update_ipmodify()
1967 return -EINVAL; in __ftrace_hash_update_ipmodify()
1969 /* Update rec->flags */ in __ftrace_hash_update_ipmodify()
1972 if (rec->flags & FTRACE_FL_DISABLED) in __ftrace_hash_update_ipmodify()
1976 in_old = !!ftrace_lookup_ip(old_hash, rec->ip); in __ftrace_hash_update_ipmodify()
1977 in_new = !!ftrace_lookup_ip(new_hash, rec->ip); in __ftrace_hash_update_ipmodify()
1982 if (rec->flags & FTRACE_FL_IPMODIFY) { in __ftrace_hash_update_ipmodify()
1989 FTRACE_WARN_ON(rec->flags & FTRACE_FL_DIRECT); in __ftrace_hash_update_ipmodify()
1997 if (!ops->ops_func) in __ftrace_hash_update_ipmodify()
1998 return -EBUSY; in __ftrace_hash_update_ipmodify()
1999 ret = ops->ops_func(ops, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_SELF); in __ftrace_hash_update_ipmodify()
2003 rec->flags |= FTRACE_FL_IPMODIFY; in __ftrace_hash_update_ipmodify()
2006 rec->flags &= ~FTRACE_FL_IPMODIFY; in __ftrace_hash_update_ipmodify()
2018 if (rec->flags & FTRACE_FL_DISABLED) in __ftrace_hash_update_ipmodify()
2024 in_old = !!ftrace_lookup_ip(old_hash, rec->ip); in __ftrace_hash_update_ipmodify()
2025 in_new = !!ftrace_lookup_ip(new_hash, rec->ip); in __ftrace_hash_update_ipmodify()
2030 rec->flags &= ~FTRACE_FL_IPMODIFY; in __ftrace_hash_update_ipmodify()
2032 rec->flags |= FTRACE_FL_IPMODIFY; in __ftrace_hash_update_ipmodify()
2036 return -EBUSY; in __ftrace_hash_update_ipmodify()
2041 struct ftrace_hash *hash = ops->func_hash->filter_hash; in ftrace_hash_ipmodify_enable()
2052 struct ftrace_hash *hash = ops->func_hash->filter_hash; in ftrace_hash_ipmodify_disable()
2063 struct ftrace_hash *old_hash = ops->func_hash->filter_hash; in ftrace_hash_ipmodify_update()
2096 pr_info("Initializing ftrace call sites\n"); in print_bug_type()
2099 pr_info("Setting ftrace call site to NOP\n"); in print_bug_type()
2102 pr_info("Setting ftrace call site to call ftrace function\n"); in print_bug_type()
2105 pr_info("Updating ftrace call site to call a different ftrace function\n"); in print_bug_type()
2111 * ftrace_bug - report and shutdown function tracer
2118 * EFAULT - if the problem happens on reading the @ip address
2119 * EINVAL - if what is read at @ip is not what was expected
2120 * EPERM - if the problem happens on writing to the @ip address
2124 unsigned long ip = rec ? rec->ip : 0; in ftrace_bug()
2126 pr_info("------------[ ftrace bug ]------------\n"); in ftrace_bug()
2129 case -EFAULT: in ftrace_bug()
2130 pr_info("ftrace faulted on modifying "); in ftrace_bug()
2133 case -EINVAL: in ftrace_bug()
2134 pr_info("ftrace failed to modify "); in ftrace_bug()
2143 case -EPERM: in ftrace_bug()
2144 pr_info("ftrace faulted on writing "); in ftrace_bug()
2148 pr_info("ftrace faulted on unknown error "); in ftrace_bug()
2155 pr_info("ftrace record flags: %lx\n", rec->flags); in ftrace_bug()
2157 rec->flags & FTRACE_FL_REGS ? " R" : " ", in ftrace_bug()
2158 rec->flags & FTRACE_FL_CALL_OPS ? " O" : " "); in ftrace_bug()
2159 if (rec->flags & FTRACE_FL_TRAMP_EN) { in ftrace_bug()
2164 (void *)ops->trampoline, in ftrace_bug()
2165 (void *)ops->func); in ftrace_bug()
2209 if (!(rec->flags & FTRACE_FL_REGS) != in ftrace_check_record()
2210 !(rec->flags & FTRACE_FL_REGS_EN)) in ftrace_check_record()
2213 if (!(rec->flags & FTRACE_FL_TRAMP) != in ftrace_check_record()
2214 !(rec->flags & FTRACE_FL_TRAMP_EN)) in ftrace_check_record()
2229 if (!(rec->flags & FTRACE_FL_DIRECT) != in ftrace_check_record()
2230 !(rec->flags & FTRACE_FL_DIRECT_EN)) in ftrace_check_record()
2232 } else if (rec->flags & FTRACE_FL_DIRECT_EN) { in ftrace_check_record()
2242 if (!(rec->flags & FTRACE_FL_CALL_OPS) != in ftrace_check_record()
2243 !(rec->flags & FTRACE_FL_CALL_OPS_EN)) in ftrace_check_record()
2245 } else if (rec->flags & FTRACE_FL_CALL_OPS_EN) { in ftrace_check_record()
2251 if ((rec->flags & FTRACE_FL_ENABLED) == flag) in ftrace_check_record()
2256 flag ^= rec->flags & FTRACE_FL_ENABLED; in ftrace_check_record()
2259 rec->flags |= FTRACE_FL_ENABLED | FTRACE_FL_TOUCHED; in ftrace_check_record()
2261 if (rec->flags & FTRACE_FL_REGS) in ftrace_check_record()
2262 rec->flags |= FTRACE_FL_REGS_EN; in ftrace_check_record()
2264 rec->flags &= ~FTRACE_FL_REGS_EN; in ftrace_check_record()
2267 if (rec->flags & FTRACE_FL_TRAMP) in ftrace_check_record()
2268 rec->flags |= FTRACE_FL_TRAMP_EN; in ftrace_check_record()
2270 rec->flags &= ~FTRACE_FL_TRAMP_EN; in ftrace_check_record()
2274 if (rec->flags & (FTRACE_FL_DIRECT | FTRACE_FL_IPMODIFY)) in ftrace_check_record()
2275 rec->flags |= FTRACE_FL_MODIFIED; in ftrace_check_record()
2281 * directly (no ftrace trampoline). in ftrace_check_record()
2284 if (rec->flags & FTRACE_FL_DIRECT) in ftrace_check_record()
2285 rec->flags |= FTRACE_FL_DIRECT_EN; in ftrace_check_record()
2287 rec->flags &= ~FTRACE_FL_DIRECT_EN; in ftrace_check_record()
2293 rec->flags &= ~FTRACE_FL_DIRECT_EN; in ftrace_check_record()
2299 if (rec->flags & FTRACE_FL_CALL_OPS) in ftrace_check_record()
2300 rec->flags |= FTRACE_FL_CALL_OPS_EN; in ftrace_check_record()
2302 rec->flags &= ~FTRACE_FL_CALL_OPS_EN; in ftrace_check_record()
2308 rec->flags &= ~FTRACE_FL_CALL_OPS_EN; in ftrace_check_record()
2318 * from the save regs, to a non-save regs function or in ftrace_check_record()
2333 rec->flags &= FTRACE_NOCLEAR_FLAGS; in ftrace_check_record()
2339 rec->flags &= ~(FTRACE_FL_ENABLED | FTRACE_FL_TRAMP_EN | in ftrace_check_record()
2349 * ftrace_update_record - set a record that now is tracing or not
2362 * ftrace_test_record - check if the record has been enabled or not
2379 unsigned long ip = rec->ip; in ftrace_find_tramp_ops_any()
2383 if (!op->trampoline) in ftrace_find_tramp_ops_any()
2386 if (hash_contains_ip(ip, op->func_hash)) in ftrace_find_tramp_ops_any()
2397 unsigned long ip = rec->ip; in ftrace_find_tramp_ops_any_other()
2401 if (op == op_exclude || !op->trampoline) in ftrace_find_tramp_ops_any_other()
2404 if (hash_contains_ip(ip, op->func_hash)) in ftrace_find_tramp_ops_any_other()
2415 unsigned long ip = rec->ip; in ftrace_find_tramp_ops_next()
2419 if (!op->trampoline) in ftrace_find_tramp_ops_next()
2422 if (hash_contains_ip(ip, op->func_hash)) in ftrace_find_tramp_ops_next()
2433 unsigned long ip = rec->ip; in ftrace_find_tramp_ops_curr()
2442 if (hash_contains_ip(ip, &removed_ops->old_hash)) in ftrace_find_tramp_ops_curr()
2466 if (!op->trampoline) in ftrace_find_tramp_ops_curr()
2473 if (op->flags & FTRACE_OPS_FL_ADDING) in ftrace_find_tramp_ops_curr()
2482 if ((op->flags & FTRACE_OPS_FL_MODIFYING) && in ftrace_find_tramp_ops_curr()
2483 hash_contains_ip(ip, &op->old_hash)) in ftrace_find_tramp_ops_curr()
2490 if (!(op->flags & FTRACE_OPS_FL_MODIFYING) && in ftrace_find_tramp_ops_curr()
2491 hash_contains_ip(ip, op->func_hash)) in ftrace_find_tramp_ops_curr()
2503 unsigned long ip = rec->ip; in ftrace_find_tramp_ops_new()
2506 /* pass rec in as regs to have non-NULL val */ in ftrace_find_tramp_ops_new()
2507 if (hash_contains_ip(ip, op->func_hash)) in ftrace_find_tramp_ops_new()
2518 unsigned long ip = rec->ip; in ftrace_find_unique_ops()
2522 if (hash_contains_ip(ip, op->func_hash)) { in ftrace_find_unique_ops()
2551 return entry->direct; in ftrace_find_rec_direct()
2557 unsigned long addr = READ_ONCE(ops->direct_call); in call_direct_funcs()
2567 * ftrace_get_addr_new - Get the call address to set to
2568 * @rec: The ftrace record descriptor
2581 if ((rec->flags & FTRACE_FL_DIRECT) && in ftrace_get_addr_new()
2583 addr = ftrace_find_rec_direct(rec->ip); in ftrace_get_addr_new()
2590 if (rec->flags & FTRACE_FL_TRAMP) { in ftrace_get_addr_new()
2592 if (FTRACE_WARN_ON(!ops || !ops->trampoline)) { in ftrace_get_addr_new()
2594 (void *)rec->ip, (void *)rec->ip, rec->flags); in ftrace_get_addr_new()
2595 /* Ftrace is shutting down, return anything */ in ftrace_get_addr_new()
2598 return ops->trampoline; in ftrace_get_addr_new()
2601 if (rec->flags & FTRACE_FL_REGS) in ftrace_get_addr_new()
2608 * ftrace_get_addr_curr - Get the call address that is already there
2609 * @rec: The ftrace record descriptor
2623 if (rec->flags & FTRACE_FL_DIRECT_EN) { in ftrace_get_addr_curr()
2624 addr = ftrace_find_rec_direct(rec->ip); in ftrace_get_addr_curr()
2631 if (rec->flags & FTRACE_FL_TRAMP_EN) { in ftrace_get_addr_curr()
2635 (void *)rec->ip, (void *)rec->ip); in ftrace_get_addr_curr()
2636 /* Ftrace is shutting down, return anything */ in ftrace_get_addr_curr()
2639 return ops->trampoline; in ftrace_get_addr_curr()
2642 if (rec->flags & FTRACE_FL_REGS_EN) in ftrace_get_addr_curr()
2681 return -1; /* unknown ftrace bug */ in __ftrace_replace_code()
2717 * ftrace_rec_iter_start - start up iterating over traced functions
2734 iter->pg = ftrace_pages_start; in ftrace_rec_iter_start()
2735 iter->index = 0; in ftrace_rec_iter_start()
2738 while (iter->pg && !iter->pg->index) in ftrace_rec_iter_start()
2739 iter->pg = iter->pg->next; in ftrace_rec_iter_start()
2741 if (!iter->pg) in ftrace_rec_iter_start()
2748 * ftrace_rec_iter_next - get the next record to process.
2755 iter->index++; in ftrace_rec_iter_next()
2757 if (iter->index >= iter->pg->index) { in ftrace_rec_iter_next()
2758 iter->pg = iter->pg->next; in ftrace_rec_iter_next()
2759 iter->index = 0; in ftrace_rec_iter_next()
2762 while (iter->pg && !iter->pg->index) in ftrace_rec_iter_next()
2763 iter->pg = iter->pg->next; in ftrace_rec_iter_next()
2766 if (!iter->pg) in ftrace_rec_iter_next()
2773 * ftrace_rec_iter_record - get the record at the iterator location
2780 return &iter->pg->records[iter->index]; in ftrace_rec_iter_record()
2887 * ftrace_run_stop_machine - go back to the stop machine method
2888 * @command: The command to tell ftrace what to do
2899 * arch_ftrace_update_code - modify the code to trace or not trace
2928 ops->flags |= FTRACE_OPS_FL_MODIFYING; in ftrace_run_modify_code()
2929 ops->old_hash.filter_hash = old_hash->filter_hash; in ftrace_run_modify_code()
2930 ops->old_hash.notrace_hash = old_hash->notrace_hash; in ftrace_run_modify_code()
2932 ops->old_hash.filter_hash = NULL; in ftrace_run_modify_code()
2933 ops->old_hash.notrace_hash = NULL; in ftrace_run_modify_code()
2934 ops->flags &= ~FTRACE_OPS_FL_MODIFYING; in ftrace_run_modify_code()
2950 list_add_rcu(&ops->list, &ftrace_ops_trampoline_list); in ftrace_add_trampoline_to_kallsyms()
2956 list_del_rcu(&ops->list); in ftrace_remove_trampoline_from_kallsyms()
2962 * for pages allocated for ftrace purposes, even though "__builtin__ftrace" is
2970 if (ops && (ops->flags & FTRACE_OPS_FL_ALLOC_TRAMP) && in ftrace_trampoline_free()
2971 ops->trampoline) { in ftrace_trampoline_free()
2976 perf_event_text_poke((void *)ops->trampoline, in ftrace_trampoline_free()
2977 (void *)ops->trampoline, in ftrace_trampoline_free()
2978 ops->trampoline_size, NULL, 0); in ftrace_trampoline_free()
2980 ops->trampoline, ops->trampoline_size, in ftrace_trampoline_free()
3014 return -ENODEV; in ftrace_startup()
3023 * Note that ftrace probes uses this to start up in ftrace_startup()
3030 ops->flags |= FTRACE_OPS_FL_ENABLED | FTRACE_OPS_FL_ADDING; in ftrace_startup()
3036 ftrace_start_up--; in ftrace_startup()
3037 ops->flags &= ~FTRACE_OPS_FL_ENABLED; in ftrace_startup()
3038 if (ops->flags & FTRACE_OPS_FL_DYNAMIC) in ftrace_startup()
3049 * If ftrace is in an undefined state, we just remove ops from list in ftrace_startup()
3055 return -ENODEV; in ftrace_startup()
3058 ops->flags &= ~FTRACE_OPS_FL_ADDING; in ftrace_startup()
3068 return -ENODEV; in ftrace_shutdown()
3074 ftrace_start_up--; in ftrace_shutdown()
3076 * Just warn in case of unbalance, no need to kill ftrace, it's not in ftrace_shutdown()
3078 * further ftrace uses. in ftrace_shutdown()
3088 ops->flags &= ~FTRACE_OPS_FL_ENABLED; in ftrace_shutdown()
3102 ops->flags |= FTRACE_OPS_FL_REMOVING; in ftrace_shutdown()
3106 ops->old_hash.filter_hash = ops->func_hash->filter_hash; in ftrace_shutdown()
3107 ops->old_hash.notrace_hash = ops->func_hash->notrace_hash; in ftrace_shutdown()
3112 * If there's no more ops registered with ftrace, run a in ftrace_shutdown()
3121 if (FTRACE_WARN_ON_ONCE(rec->flags & ~FTRACE_NOCLEAR_FLAGS)) in ftrace_shutdown()
3123 (void *)rec->ip, rec->flags); in ftrace_shutdown()
3127 ops->old_hash.filter_hash = NULL; in ftrace_shutdown()
3128 ops->old_hash.notrace_hash = NULL; in ftrace_shutdown()
3131 ops->flags &= ~FTRACE_OPS_FL_REMOVING; in ftrace_shutdown()
3138 if (ops->flags & FTRACE_OPS_FL_DYNAMIC) { in ftrace_shutdown()
3151 * while on a ftrace trampoline. Just scheduling a task on in ftrace_shutdown()
3176 return ftrace_hash_empty(ops->func_hash->filter_hash) && in ops_traces_mod()
3177 ftrace_hash_empty(ops->func_hash->notrace_hash); in ops_traces_mod()
3195 * an entry in the ftrace data. Now, if ftrace is activated in ftrace_update_code()
3197 * read-only, the modification of enabling ftrace can fail if in ftrace_update_code()
3198 * the read-only is done while ftrace is converting the calls. in ftrace_update_code()
3201 * to read-only. in ftrace_update_code()
3206 for (pg = new_pgs; pg; pg = pg->next) { in ftrace_update_code()
3208 for (i = 0; i < pg->index; i++) { in ftrace_update_code()
3212 return -1; in ftrace_update_code()
3214 p = &pg->records[i]; in ftrace_update_code()
3215 p->flags = rec_flags; in ftrace_update_code()
3229 ftrace_update_time = stop - start; in ftrace_update_code()
3242 return -EINVAL; in ftrace_allocate_records()
3246 order = fls(pages) - 1; in ftrace_allocate_records()
3249 pg->records = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, order); in ftrace_allocate_records()
3251 if (!pg->records) { in ftrace_allocate_records()
3252 /* if we can't allocate this size, try something smaller */ in ftrace_allocate_records()
3254 return -ENOMEM; in ftrace_allocate_records()
3255 order--; in ftrace_allocate_records()
3263 pg->order = order; in ftrace_allocate_records()
3276 if (pg->records) { in ftrace_free_pages()
3277 free_pages((unsigned long)pg->records, pg->order); in ftrace_free_pages()
3278 ftrace_number_of_pages -= 1 << pg->order; in ftrace_free_pages()
3280 pages = pg->next; in ftrace_free_pages()
3283 ftrace_number_of_groups--; in ftrace_free_pages()
3311 num_to_init -= cnt; in ftrace_allocate_pages()
3315 pg->next = kzalloc(sizeof(*pg), GFP_KERNEL); in ftrace_allocate_pages()
3316 if (!pg->next) in ftrace_allocate_pages()
3319 pg = pg->next; in ftrace_allocate_pages()
3326 pr_info("ftrace: FAILED to allocate memory for functions\n"); in ftrace_allocate_pages()
3353 struct ftrace_iterator *iter = m->private; in t_probe_next()
3354 struct trace_array *tr = iter->ops->private; in t_probe_next()
3360 int size; in t_probe_next() local
3363 iter->pos = *pos; in t_probe_next()
3368 func_probes = &tr->func_probes; in t_probe_next()
3372 if (!iter->probe) { in t_probe_next()
3373 next = func_probes->next; in t_probe_next()
3374 iter->probe = list_entry(next, struct ftrace_func_probe, list); in t_probe_next()
3377 if (iter->probe_entry) in t_probe_next()
3378 hnd = &iter->probe_entry->hlist; in t_probe_next()
3380 hash = iter->probe->ops.func_hash->filter_hash; in t_probe_next()
3389 size = 1 << hash->size_bits; in t_probe_next()
3392 if (iter->pidx >= size) { in t_probe_next()
3393 if (iter->probe->list.next == func_probes) in t_probe_next()
3395 next = iter->probe->list.next; in t_probe_next()
3396 iter->probe = list_entry(next, struct ftrace_func_probe, list); in t_probe_next()
3397 hash = iter->probe->ops.func_hash->filter_hash; in t_probe_next()
3398 size = 1 << hash->size_bits; in t_probe_next()
3399 iter->pidx = 0; in t_probe_next()
3402 hhd = &hash->buckets[iter->pidx]; in t_probe_next()
3405 iter->pidx++; in t_probe_next()
3411 hnd = hhd->first; in t_probe_next()
3413 hnd = hnd->next; in t_probe_next()
3415 iter->pidx++; in t_probe_next()
3423 iter->probe_entry = hlist_entry(hnd, struct ftrace_func_entry, hlist); in t_probe_next()
3430 struct ftrace_iterator *iter = m->private; in t_probe_start()
3434 if (!(iter->flags & FTRACE_ITER_DO_PROBES)) in t_probe_start()
3437 if (iter->mod_pos > *pos) in t_probe_start()
3440 iter->probe = NULL; in t_probe_start()
3441 iter->probe_entry = NULL; in t_probe_start()
3442 iter->pidx = 0; in t_probe_start()
3443 for (l = 0; l <= (*pos - iter->mod_pos); ) { in t_probe_start()
3452 iter->flags |= FTRACE_ITER_PROBE; in t_probe_start()
3464 probe = iter->probe; in t_probe_show()
3465 probe_entry = iter->probe_entry; in t_probe_show()
3468 return -EIO; in t_probe_show()
3470 probe_ops = probe->probe_ops; in t_probe_show()
3472 if (probe_ops->print) in t_probe_show()
3473 return probe_ops->print(m, probe_entry->ip, probe_ops, probe->data); in t_probe_show()
3475 seq_printf(m, "%ps:%ps\n", (void *)probe_entry->ip, in t_probe_show()
3476 (void *)probe_ops->func); in t_probe_show()
3484 struct ftrace_iterator *iter = m->private; in t_mod_next()
3485 struct trace_array *tr = iter->tr; in t_mod_next()
3488 iter->pos = *pos; in t_mod_next()
3490 iter->mod_list = iter->mod_list->next; in t_mod_next()
3492 if (iter->mod_list == &tr->mod_trace || in t_mod_next()
3493 iter->mod_list == &tr->mod_notrace) { in t_mod_next()
3494 iter->flags &= ~FTRACE_ITER_MOD; in t_mod_next()
3498 iter->mod_pos = *pos; in t_mod_next()
3505 struct ftrace_iterator *iter = m->private; in t_mod_start()
3509 if (iter->func_pos > *pos) in t_mod_start()
3512 iter->mod_pos = iter->func_pos; in t_mod_start()
3515 if (!iter->tr) in t_mod_start()
3518 for (l = 0; l <= (*pos - iter->func_pos); ) { in t_mod_start()
3524 iter->flags &= ~FTRACE_ITER_MOD; in t_mod_start()
3529 iter->flags |= FTRACE_ITER_MOD; in t_mod_start()
3538 struct trace_array *tr = iter->tr; in t_mod_show()
3540 if (WARN_ON_ONCE(!iter->mod_list) || in t_mod_show()
3541 iter->mod_list == &tr->mod_trace || in t_mod_show()
3542 iter->mod_list == &tr->mod_notrace) in t_mod_show()
3543 return -EIO; in t_mod_show()
3545 ftrace_mod = list_entry(iter->mod_list, struct ftrace_mod_load, list); in t_mod_show()
3547 if (ftrace_mod->func) in t_mod_show()
3548 seq_printf(m, "%s", ftrace_mod->func); in t_mod_show()
3552 seq_printf(m, ":mod:%s\n", ftrace_mod->module); in t_mod_show()
3560 struct ftrace_iterator *iter = m->private; in t_func_next()
3566 if (iter->idx >= iter->pg->index) { in t_func_next()
3567 if (iter->pg->next) { in t_func_next()
3568 iter->pg = iter->pg->next; in t_func_next()
3569 iter->idx = 0; in t_func_next()
3573 rec = &iter->pg->records[iter->idx++]; in t_func_next()
3574 if (((iter->flags & (FTRACE_ITER_FILTER | FTRACE_ITER_NOTRACE)) && in t_func_next()
3575 !ftrace_lookup_ip(iter->hash, rec->ip)) || in t_func_next()
3577 ((iter->flags & FTRACE_ITER_ENABLED) && in t_func_next()
3578 !(rec->flags & FTRACE_FL_ENABLED)) || in t_func_next()
3580 ((iter->flags & FTRACE_ITER_TOUCHED) && in t_func_next()
3581 !(rec->flags & FTRACE_FL_TOUCHED))) { in t_func_next()
3591 iter->pos = iter->func_pos = *pos; in t_func_next()
3592 iter->func = rec; in t_func_next()
3600 struct ftrace_iterator *iter = m->private; in t_next()
3607 if (iter->flags & FTRACE_ITER_PROBE) in t_next()
3610 if (iter->flags & FTRACE_ITER_MOD) in t_next()
3613 if (iter->flags & FTRACE_ITER_PRINTALL) { in t_next()
3629 iter->pos = 0; in reset_iter_read()
3630 iter->func_pos = 0; in reset_iter_read()
3631 iter->flags &= ~(FTRACE_ITER_PRINTALL | FTRACE_ITER_PROBE | FTRACE_ITER_MOD); in reset_iter_read()
3636 struct ftrace_iterator *iter = m->private; in t_start()
3648 if (*pos < iter->pos) in t_start()
3656 if ((iter->flags & (FTRACE_ITER_FILTER | FTRACE_ITER_NOTRACE)) && in t_start()
3657 ftrace_hash_empty(iter->hash)) { in t_start()
3658 iter->func_pos = 1; /* Account for the message */ in t_start()
3661 iter->flags |= FTRACE_ITER_PRINTALL; in t_start()
3663 iter->flags &= ~FTRACE_ITER_PROBE; in t_start()
3667 if (iter->flags & FTRACE_ITER_MOD) in t_start()
3675 iter->pg = ftrace_pages_start; in t_start()
3676 iter->idx = 0; in t_start()
3707 seq_printf(m, " ->%pS", ptr); in add_trampoline_func()
3727 ret = kallsyms_lookup(rec->ip, NULL, &offset, NULL, str); in test_for_valid_rec()
3731 rec->flags |= FTRACE_FL_DISABLED; in test_for_valid_rec()
3794 return ret == NULL ? -1 : 0; in print_rec()
3811 struct ftrace_iterator *iter = m->private; in t_show()
3814 if (iter->flags & FTRACE_ITER_PROBE) in t_show()
3817 if (iter->flags & FTRACE_ITER_MOD) in t_show()
3820 if (iter->flags & FTRACE_ITER_PRINTALL) { in t_show()
3821 if (iter->flags & FTRACE_ITER_NOTRACE) in t_show()
3828 rec = iter->func; in t_show()
3833 if (iter->flags & FTRACE_ITER_ADDRS) in t_show()
3834 seq_printf(m, "%lx ", rec->ip); in t_show()
3836 if (print_rec(m, rec->ip)) { in t_show()
3838 WARN_ON_ONCE(!(rec->flags & FTRACE_FL_DISABLED)); in t_show()
3843 if (iter->flags & (FTRACE_ITER_ENABLED | FTRACE_ITER_TOUCHED)) { in t_show()
3848 rec->flags & FTRACE_FL_REGS ? " R" : " ", in t_show()
3849 rec->flags & FTRACE_FL_IPMODIFY ? " I" : " ", in t_show()
3850 rec->flags & FTRACE_FL_DIRECT ? " D" : " ", in t_show()
3851 rec->flags & FTRACE_FL_CALL_OPS ? " O" : " ", in t_show()
3852 rec->flags & FTRACE_FL_MODIFIED ? " M " : " "); in t_show()
3853 if (rec->flags & FTRACE_FL_TRAMP_EN) { in t_show()
3858 (void *)ops->trampoline, in t_show()
3859 (void *)ops->func); in t_show()
3868 if (rec->flags & FTRACE_FL_CALL_OPS_EN) { in t_show()
3872 ops, ops->func); in t_show()
3877 if (rec->flags & FTRACE_FL_DIRECT) { in t_show()
3880 direct = ftrace_find_rec_direct(rec->ip); in t_show()
3882 seq_printf(m, "\n\tdirect-->%pS", (void *)direct); in t_show()
3909 return -ENODEV; in ftrace_avail_open()
3913 return -ENOMEM; in ftrace_avail_open()
3915 iter->pg = ftrace_pages_start; in ftrace_avail_open()
3916 iter->ops = &global_ops; in ftrace_avail_open()
3937 return -ENOMEM; in ftrace_enabled_open()
3939 iter->pg = ftrace_pages_start; in ftrace_enabled_open()
3940 iter->flags = FTRACE_ITER_ENABLED; in ftrace_enabled_open()
3941 iter->ops = &global_ops; in ftrace_enabled_open()
3962 return -ENOMEM; in ftrace_touched_open()
3964 iter->pg = ftrace_pages_start; in ftrace_touched_open()
3965 iter->flags = FTRACE_ITER_TOUCHED; in ftrace_touched_open()
3966 iter->ops = &global_ops; in ftrace_touched_open()
3982 return -ENODEV; in ftrace_avail_addrs_open()
3986 return -ENOMEM; in ftrace_avail_addrs_open()
3988 iter->pg = ftrace_pages_start; in ftrace_avail_addrs_open()
3989 iter->flags = FTRACE_ITER_ADDRS; in ftrace_avail_addrs_open()
3990 iter->ops = &global_ops; in ftrace_avail_addrs_open()
3996 * ftrace_regex_open - initialize function tracer filter files
4018 struct trace_array *tr = ops->private; in ftrace_regex_open()
4019 int ret = -ENOMEM; in ftrace_regex_open()
4024 return -ENODEV; in ftrace_regex_open()
4027 return -ENODEV; in ftrace_regex_open()
4033 if (trace_parser_get_init(&iter->parser, FTRACE_BUFF_MAX)) in ftrace_regex_open()
4036 iter->ops = ops; in ftrace_regex_open()
4037 iter->flags = flag; in ftrace_regex_open()
4038 iter->tr = tr; in ftrace_regex_open()
4040 mutex_lock(&ops->func_hash->regex_lock); in ftrace_regex_open()
4043 hash = ops->func_hash->notrace_hash; in ftrace_regex_open()
4044 mod_head = tr ? &tr->mod_notrace : NULL; in ftrace_regex_open()
4046 hash = ops->func_hash->filter_hash; in ftrace_regex_open()
4047 mod_head = tr ? &tr->mod_trace : NULL; in ftrace_regex_open()
4050 iter->mod_list = mod_head; in ftrace_regex_open()
4052 if (file->f_mode & FMODE_WRITE) { in ftrace_regex_open()
4055 if (file->f_flags & O_TRUNC) { in ftrace_regex_open()
4056 iter->hash = alloc_ftrace_hash(size_bits); in ftrace_regex_open()
4059 iter->hash = alloc_and_copy_ftrace_hash(size_bits, hash); in ftrace_regex_open()
4062 if (!iter->hash) { in ftrace_regex_open()
4063 trace_parser_put(&iter->parser); in ftrace_regex_open()
4067 iter->hash = hash; in ftrace_regex_open()
4071 if (file->f_mode & FMODE_READ) { in ftrace_regex_open()
4072 iter->pg = ftrace_pages_start; in ftrace_regex_open()
4076 struct seq_file *m = file->private_data; in ftrace_regex_open()
4077 m->private = iter; in ftrace_regex_open()
4080 free_ftrace_hash(iter->hash); in ftrace_regex_open()
4081 trace_parser_put(&iter->parser); in ftrace_regex_open()
4084 file->private_data = iter; in ftrace_regex_open()
4087 mutex_unlock(&ops->func_hash->regex_lock); in ftrace_regex_open()
4102 struct ftrace_ops *ops = inode->i_private; in ftrace_filter_open()
4113 struct ftrace_ops *ops = inode->i_private; in ftrace_notrace_open()
4120 /* Type for quick search ftrace basic regexes (globs) from filter_parse_regex */
4128 * If symbols in an architecture don't correspond exactly to the user-visible
4142 str = arch_ftrace_match_adjust(str, g->search); in ftrace_match()
4144 switch (g->type) { in ftrace_match()
4146 if (strcmp(str, g->search) == 0) in ftrace_match()
4150 if (strncmp(str, g->search, g->len) == 0) in ftrace_match()
4154 if (strstr(str, g->search)) in ftrace_match()
4159 if (slen >= g->len && in ftrace_match()
4160 memcmp(str + slen - g->len, g->search, g->len) == 0) in ftrace_match()
4164 if (glob_match(g->search, str)) in ftrace_match()
4178 entry = ftrace_lookup_ip(hash, rec->ip); in enter_record()
4189 if (add_hash_entry(hash, rec->ip) == NULL) in enter_record()
4190 ret = -ENOMEM; in enter_record()
4199 long index = simple_strtoul(func_g->search, NULL, 0); in add_rec_by_index()
4204 if (--index < 0) in add_rec_by_index()
4208 if (pg->index <= index) { in add_rec_by_index()
4209 index -= pg->index; in add_rec_by_index()
4213 rec = &pg->records[index]; in add_rec_by_index()
4227 return -1; in lookup_ip()
4245 if (lookup_ip(rec->ip, &modname, str)) { in ftrace_match_record()
4248 !(rec->flags & FTRACE_FL_DISABLED)); in ftrace_match_record()
4256 if (!mod_g->len) { in ftrace_match_record()
4274 if (!func_g->len) in ftrace_match_record()
4318 if (rec->flags & FTRACE_FL_DISABLED) in match_records()
4351 if (ops->flags & FTRACE_OPS_FL_ENABLED) { in ftrace_ops_update_code()
4361 if (ops->func_hash != &global_ops.local_hash) in ftrace_ops_update_code()
4365 if (op->func_hash == &global_ops.local_hash && in ftrace_ops_update_code()
4366 op->flags & FTRACE_OPS_FL_ENABLED) { in ftrace_ops_update_code()
4384 old_hash_ops.filter_hash = ops->func_hash->filter_hash; in ftrace_hash_move_and_update_ops()
4385 old_hash_ops.notrace_hash = ops->func_hash->notrace_hash; in ftrace_hash_move_and_update_ops()
4404 if (n > sizeof(modname) - 1) in module_exists()
4415 struct list_head *head = enable ? &tr->mod_trace : &tr->mod_notrace; in cache_mod()
4423 ret = -EINVAL; in cache_mod()
4427 if (strcmp(ftrace_mod->module, module) != 0) in cache_mod()
4432 (ftrace_mod->func && in cache_mod()
4433 strcmp(ftrace_mod->func, func) == 0)) { in cache_mod()
4442 ret = -EINVAL; in cache_mod()
4468 mutex_lock(&ops->func_hash->regex_lock); in process_mod_list()
4471 orig_hash = &ops->func_hash->filter_hash; in process_mod_list()
4473 orig_hash = &ops->func_hash->notrace_hash; in process_mod_list()
4484 if (strcmp(ftrace_mod->module, mod) != 0) in process_mod_list()
4487 if (ftrace_mod->func) in process_mod_list()
4488 func = kstrdup(ftrace_mod->func, GFP_KERNEL); in process_mod_list()
4495 list_move(&ftrace_mod->list, &process_mods); in process_mod_list()
4498 kfree(ftrace_mod->func); in process_mod_list()
4499 ftrace_mod->func = func; in process_mod_list()
4506 func = ftrace_mod->func; in process_mod_list()
4514 new_hash->flags &= ~FTRACE_HASH_FL_MOD; in process_mod_list()
4523 mutex_unlock(&ops->func_hash->regex_lock); in process_mod_list()
4539 if (!list_empty(&tr->mod_trace)) in process_cached_mods()
4540 process_mod_list(&tr->mod_trace, tr->ops, mod, true); in process_cached_mods()
4541 if (!list_empty(&tr->mod_notrace)) in process_cached_mods()
4542 process_mod_list(&tr->mod_notrace, tr->ops, mod, false); in process_cached_mods()
4563 return -ENODEV; in ftrace_mod_callback()
4568 return -ENOMEM; in ftrace_mod_callback()
4605 probe_ops = probe->probe_ops; in function_trace_probe_call()
4613 probe_ops->func(ip, parent_ip, probe->tr, probe_ops, probe->data); in function_trace_probe_call()
4627 * allocate_ftrace_func_mapper - allocate a new ftrace_func_mapper
4645 * ftrace_func_mapper_find_ip - Find some data mapped to an ip
4661 entry = ftrace_lookup_ip(&mapper->hash, ip); in ftrace_func_mapper_find_ip()
4666 return &map->data; in ftrace_func_mapper_find_ip()
4670 * ftrace_func_mapper_add_ip - Map some data to an ip
4683 entry = ftrace_lookup_ip(&mapper->hash, ip); in ftrace_func_mapper_add_ip()
4685 return -EBUSY; in ftrace_func_mapper_add_ip()
4689 return -ENOMEM; in ftrace_func_mapper_add_ip()
4691 map->entry.ip = ip; in ftrace_func_mapper_add_ip()
4692 map->data = data; in ftrace_func_mapper_add_ip()
4694 __add_hash_entry(&mapper->hash, &map->entry); in ftrace_func_mapper_add_ip()
4700 * ftrace_func_mapper_remove_ip - Remove an ip from the mapping
4716 entry = ftrace_lookup_ip(&mapper->hash, ip); in ftrace_func_mapper_remove_ip()
4721 data = map->data; in ftrace_func_mapper_remove_ip()
4723 remove_hash_entry(&mapper->hash, entry); in ftrace_func_mapper_remove_ip()
4730 * free_ftrace_func_mapper - free a mapping of ips and data
4743 int size, i; in free_ftrace_func_mapper() local
4748 if (free_func && mapper->hash.count) { in free_ftrace_func_mapper()
4749 size = 1 << mapper->hash.size_bits; in free_ftrace_func_mapper()
4750 for (i = 0; i < size; i++) { in free_ftrace_func_mapper()
4751 hhd = &mapper->hash.buckets[i]; in free_ftrace_func_mapper()
4758 free_ftrace_hash(&mapper->hash); in free_ftrace_func_mapper()
4767 WARN_ON(probe->ref <= 0); in release_probe()
4770 probe->ref--; in release_probe()
4772 if (!probe->ref) { in release_probe()
4773 probe_ops = probe->probe_ops; in release_probe()
4776 * the probe->data itself in release_probe()
4778 if (probe_ops->free) in release_probe()
4779 probe_ops->free(probe_ops, probe->tr, 0, probe->data); in release_probe()
4780 list_del(&probe->list); in release_probe()
4792 probe->ref++; in acquire_probe_locked()
4806 int size; in register_ftrace_function_probe() local
4811 return -EINVAL; in register_ftrace_function_probe()
4815 return -EINVAL; in register_ftrace_function_probe()
4820 list_for_each_entry(iter, &tr->func_probes, list) { in register_ftrace_function_probe()
4821 if (iter->probe_ops == probe_ops) { in register_ftrace_function_probe()
4830 return -ENOMEM; in register_ftrace_function_probe()
4832 probe->probe_ops = probe_ops; in register_ftrace_function_probe()
4833 probe->ops.func = function_trace_probe_call; in register_ftrace_function_probe()
4834 probe->tr = tr; in register_ftrace_function_probe()
4835 ftrace_ops_init(&probe->ops); in register_ftrace_function_probe()
4836 list_add(&probe->list, &tr->func_probes); in register_ftrace_function_probe()
4844 * Note, there's a small window here that the func_hash->filter_hash in register_ftrace_function_probe()
4847 mutex_lock(&probe->ops.func_hash->regex_lock); in register_ftrace_function_probe()
4849 orig_hash = &probe->ops.func_hash->filter_hash; in register_ftrace_function_probe()
4854 ret = -ENOMEM; in register_ftrace_function_probe()
4862 ret = -EINVAL; in register_ftrace_function_probe()
4867 size = 1 << hash->size_bits; in register_ftrace_function_probe()
4868 for (i = 0; i < size; i++) { in register_ftrace_function_probe()
4869 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in register_ftrace_function_probe()
4870 if (ftrace_lookup_ip(old_hash, entry->ip)) in register_ftrace_function_probe()
4877 if (probe_ops->init) { in register_ftrace_function_probe()
4878 ret = probe_ops->init(probe_ops, tr, in register_ftrace_function_probe()
4879 entry->ip, data, in register_ftrace_function_probe()
4880 &probe->data); in register_ftrace_function_probe()
4882 if (probe_ops->free && count) in register_ftrace_function_probe()
4883 probe_ops->free(probe_ops, tr, in register_ftrace_function_probe()
4884 0, probe->data); in register_ftrace_function_probe()
4885 probe->data = NULL; in register_ftrace_function_probe()
4897 ret = -EINVAL; in register_ftrace_function_probe()
4901 ret = ftrace_hash_move_and_update_ops(&probe->ops, orig_hash, in register_ftrace_function_probe()
4907 probe->ref += count; in register_ftrace_function_probe()
4909 if (!(probe->ops.flags & FTRACE_OPS_FL_ENABLED)) in register_ftrace_function_probe()
4910 ret = ftrace_startup(&probe->ops, 0); in register_ftrace_function_probe()
4918 mutex_unlock(&probe->ops.func_hash->regex_lock); in register_ftrace_function_probe()
4926 if (!probe_ops->free || !count) in register_ftrace_function_probe()
4930 for (i = 0; i < size; i++) { in register_ftrace_function_probe()
4931 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in register_ftrace_function_probe()
4932 if (ftrace_lookup_ip(old_hash, entry->ip)) in register_ftrace_function_probe()
4934 probe_ops->free(probe_ops, tr, entry->ip, probe->data); in register_ftrace_function_probe()
4955 int i, ret = -ENODEV; in unregister_ftrace_function_probe_func()
4956 int size; in unregister_ftrace_function_probe_func() local
4969 return -EINVAL; in unregister_ftrace_function_probe_func()
4974 list_for_each_entry(iter, &tr->func_probes, list) { in unregister_ftrace_function_probe_func()
4975 if (iter->probe_ops == probe_ops) { in unregister_ftrace_function_probe_func()
4983 ret = -EINVAL; in unregister_ftrace_function_probe_func()
4984 if (!(probe->ops.flags & FTRACE_OPS_FL_INITIALIZED)) in unregister_ftrace_function_probe_func()
4991 mutex_lock(&probe->ops.func_hash->regex_lock); in unregister_ftrace_function_probe_func()
4993 orig_hash = &probe->ops.func_hash->filter_hash; in unregister_ftrace_function_probe_func()
5003 ret = -ENOMEM; in unregister_ftrace_function_probe_func()
5010 size = 1 << hash->size_bits; in unregister_ftrace_function_probe_func()
5011 for (i = 0; i < size; i++) { in unregister_ftrace_function_probe_func()
5012 hlist_for_each_entry_safe(entry, tmp, &hash->buckets[i], hlist) { in unregister_ftrace_function_probe_func()
5015 kallsyms_lookup(entry->ip, NULL, NULL, in unregister_ftrace_function_probe_func()
5022 hlist_add_head(&entry->hlist, &hhd); in unregister_ftrace_function_probe_func()
5028 ret = -EINVAL; in unregister_ftrace_function_probe_func()
5034 WARN_ON(probe->ref < count); in unregister_ftrace_function_probe_func()
5036 probe->ref -= count; in unregister_ftrace_function_probe_func()
5039 ftrace_shutdown(&probe->ops, 0); in unregister_ftrace_function_probe_func()
5041 ret = ftrace_hash_move_and_update_ops(&probe->ops, orig_hash, in unregister_ftrace_function_probe_func()
5046 ftrace_run_modify_code(&probe->ops, FTRACE_UPDATE_CALLS, in unregister_ftrace_function_probe_func()
5051 hlist_del(&entry->hlist); in unregister_ftrace_function_probe_func()
5052 if (probe_ops->free) in unregister_ftrace_function_probe_func()
5053 probe_ops->free(probe_ops, tr, entry->ip, probe->data); in unregister_ftrace_function_probe_func()
5059 mutex_unlock(&probe->ops.func_hash->regex_lock); in unregister_ftrace_function_probe_func()
5075 list_for_each_entry_safe(probe, n, &tr->func_probes, list) in clear_ftrace_function_probes()
5076 unregister_ftrace_function_probe_func(NULL, tr, probe->probe_ops); in clear_ftrace_function_probes()
5083 * Currently we only register ftrace commands from __init, so mark this
5093 if (strcmp(cmd->name, p->name) == 0) { in register_ftrace_command()
5094 ret = -EBUSY; in register_ftrace_command()
5098 list_add(&cmd->list, &ftrace_commands); in register_ftrace_command()
5106 * Currently we only unregister ftrace commands from __init, so mark
5112 int ret = -ENODEV; in unregister_ftrace_command()
5116 if (strcmp(cmd->name, p->name) == 0) { in unregister_ftrace_command()
5118 list_del_init(&p->list); in unregister_ftrace_command()
5131 struct ftrace_hash *hash = iter->hash; in ftrace_process_regex()
5132 struct trace_array *tr = iter->ops->private; in ftrace_process_regex()
5135 int ret = -EINVAL; in ftrace_process_regex()
5142 ret = -EINVAL; in ftrace_process_regex()
5154 if (strcmp(p->name, command) == 0) { in ftrace_process_regex()
5155 ret = p->func(tr, hash, func, command, next, enable); in ftrace_process_regex()
5176 if (file->f_mode & FMODE_READ) { in ftrace_regex_write()
5177 struct seq_file *m = file->private_data; in ftrace_regex_write()
5178 iter = m->private; in ftrace_regex_write()
5180 iter = file->private_data; in ftrace_regex_write()
5183 return -ENODEV; in ftrace_regex_write()
5185 /* iter->hash is a local copy, so we don't need regex_lock */ in ftrace_regex_write()
5187 parser = &iter->parser; in ftrace_regex_write()
5192 ret = ftrace_process_regex(iter, parser->buffer, in ftrace_regex_write()
5193 parser->idx, enable); in ftrace_regex_write()
5225 return -EINVAL; in __ftrace_match_addr()
5230 return -ENOENT; in __ftrace_match_addr()
5239 return entry ? 0 : -ENOMEM; in __ftrace_match_addr()
5272 return -ENODEV; in ftrace_set_hash()
5274 mutex_lock(&ops->func_hash->regex_lock); in ftrace_set_hash()
5277 orig_hash = &ops->func_hash->filter_hash; in ftrace_set_hash()
5279 orig_hash = &ops->func_hash->notrace_hash; in ftrace_set_hash()
5287 ret = -ENOMEM; in ftrace_set_hash()
5292 ret = -EINVAL; in ftrace_set_hash()
5306 mutex_unlock(&ops->func_hash->regex_lock); in ftrace_set_hash()
5345 if (!(ops->flags & FTRACE_OPS_FL_INITIALIZED)) in check_direct_multi()
5346 return -EINVAL; in check_direct_multi()
5347 if ((ops->flags & MULTI_FLAGS) != MULTI_FLAGS) in check_direct_multi()
5348 return -EINVAL; in check_direct_multi()
5355 int size, i; in remove_direct_functions_hash() local
5357 size = 1 << hash->size_bits; in remove_direct_functions_hash()
5358 for (i = 0; i < size; i++) { in remove_direct_functions_hash()
5359 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in remove_direct_functions_hash()
5360 del = __ftrace_lookup_ip(direct_functions, entry->ip); in remove_direct_functions_hash()
5361 if (del && del->direct == addr) { in remove_direct_functions_hash()
5370 * register_ftrace_direct - Call a custom trampoline directly
5385 * -EINVAL - The @ops object was already registered with this call or
5387 * -EBUSY - Another direct function is already attached (there can be only one)
5388 * -ENODEV - @ip does not point to a ftrace nop location (or not supported)
5389 * -ENOMEM - There was an allocation failure.
5395 int err = -EBUSY, size, i; in register_ftrace_direct() local
5397 if (ops->func || ops->trampoline) in register_ftrace_direct()
5398 return -EINVAL; in register_ftrace_direct()
5399 if (!(ops->flags & FTRACE_OPS_FL_INITIALIZED)) in register_ftrace_direct()
5400 return -EINVAL; in register_ftrace_direct()
5401 if (ops->flags & FTRACE_OPS_FL_ENABLED) in register_ftrace_direct()
5402 return -EINVAL; in register_ftrace_direct()
5404 hash = ops->func_hash->filter_hash; in register_ftrace_direct()
5406 return -EINVAL; in register_ftrace_direct()
5411 size = 1 << hash->size_bits; in register_ftrace_direct()
5412 for (i = 0; i < size; i++) { in register_ftrace_direct()
5413 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in register_ftrace_direct()
5414 if (ftrace_find_rec_direct(entry->ip)) in register_ftrace_direct()
5419 err = -ENOMEM; in register_ftrace_direct()
5422 size = hash->count + direct_functions->count; in register_ftrace_direct()
5423 if (size > 32) in register_ftrace_direct()
5424 size = 32; in register_ftrace_direct()
5425 new_hash = alloc_ftrace_hash(fls(size)); in register_ftrace_direct()
5430 size = 1 << direct_functions->size_bits; in register_ftrace_direct()
5431 for (i = 0; i < size; i++) { in register_ftrace_direct()
5432 hlist_for_each_entry(entry, &direct_functions->buckets[i], hlist) { in register_ftrace_direct()
5433 new = add_hash_entry(new_hash, entry->ip); in register_ftrace_direct()
5436 new->direct = entry->direct; in register_ftrace_direct()
5441 size = 1 << hash->size_bits; in register_ftrace_direct()
5442 for (i = 0; i < size; i++) { in register_ftrace_direct()
5443 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in register_ftrace_direct()
5444 new = add_hash_entry(new_hash, entry->ip); in register_ftrace_direct()
5448 new->direct = addr; in register_ftrace_direct()
5449 entry->direct = addr; in register_ftrace_direct()
5457 ops->func = call_direct_funcs; in register_ftrace_direct()
5458 ops->flags = MULTI_FLAGS; in register_ftrace_direct()
5459 ops->trampoline = FTRACE_REGS_ADDR; in register_ftrace_direct()
5460 ops->direct_call = addr; in register_ftrace_direct()
5480 * unregister_ftrace_direct - Remove calls to custom trampoline
5490 * -EINVAL - The @ops object was not properly registered.
5495 struct ftrace_hash *hash = ops->func_hash->filter_hash; in unregister_ftrace_direct()
5499 return -EINVAL; in unregister_ftrace_direct()
5500 if (!(ops->flags & FTRACE_OPS_FL_ENABLED)) in unregister_ftrace_direct()
5501 return -EINVAL; in unregister_ftrace_direct()
5509 ops->func = NULL; in unregister_ftrace_direct()
5510 ops->trampoline = 0; in unregister_ftrace_direct()
5527 int i, size; in __modify_ftrace_direct() local
5534 tmp_ops.func_hash = ops->func_hash; in __modify_ftrace_direct()
5547 hash = ops->func_hash->filter_hash; in __modify_ftrace_direct()
5548 size = 1 << hash->size_bits; in __modify_ftrace_direct()
5549 for (i = 0; i < size; i++) { in __modify_ftrace_direct()
5550 hlist_for_each_entry(iter, &hash->buckets[i], hlist) { in __modify_ftrace_direct()
5551 entry = __ftrace_lookup_ip(direct_functions, iter->ip); in __modify_ftrace_direct()
5554 entry->direct = addr; in __modify_ftrace_direct()
5558 WRITE_ONCE(ops->direct_call, addr); in __modify_ftrace_direct()
5569 * modify_ftrace_direct_nolock - Modify an existing direct 'multi' call
5584 * -EINVAL - The @ops object was not properly registered.
5589 return -EINVAL; in modify_ftrace_direct_nolock()
5590 if (!(ops->flags & FTRACE_OPS_FL_ENABLED)) in modify_ftrace_direct_nolock()
5591 return -EINVAL; in modify_ftrace_direct_nolock()
5598 * modify_ftrace_direct - Modify an existing direct 'multi' call
5610 * -EINVAL - The @ops object was not properly registered.
5617 return -EINVAL; in modify_ftrace_direct()
5618 if (!(ops->flags & FTRACE_OPS_FL_ENABLED)) in modify_ftrace_direct()
5619 return -EINVAL; in modify_ftrace_direct()
5630 * ftrace_set_filter_ip - set a function to filter on in ftrace by address
5631 * @ops - the ops to set the filter with
5632 * @ip - the address to add to or remove from the filter.
5633 * @remove - non zero to remove the ip from the filter
5634 * @reset - non zero to reset all filters before applying this filter.
5652 * ftrace_set_filter_ips - set functions to filter on in ftrace by addresses
5653 * @ops - the ops to set the filter with
5654 * @ips - the array of addresses to add to or remove from the filter.
5655 * @cnt - the number of addresses in @ips
5656 * @remove - non zero to remove ips from the filter
5657 * @reset - non zero to reset all filters before applying this filter.
5675 * ftrace_ops_set_global_filter - setup ops to use global filters
5676 * @ops - the ops which will use the global filters
5678 * ftrace users who need global function trace filtering should call this.
5683 if (ops->flags & FTRACE_OPS_FL_INITIALIZED) in ftrace_ops_set_global_filter()
5687 ops->func_hash = &global_ops.local_hash; in ftrace_ops_set_global_filter()
5699 * ftrace_set_filter - set a function to filter on in ftrace
5700 * @ops - the ops to set the filter with
5701 * @buf - the string that holds the function filter text.
5702 * @len - the length of the string.
5703 * @reset - non zero to reset all filters before applying this filter.
5721 * ftrace_set_notrace - set a function to not trace in ftrace
5722 * @ops - the ops to set the notrace filter with
5723 * @buf - the string that holds the function notrace text.
5724 * @len - the length of the string.
5725 * @reset - non zero to reset all filters before applying this filter.
5743 * ftrace_set_global_filter - set a function to filter on with global tracers
5744 * @buf - the string that holds the function filter text.
5745 * @len - the length of the string.
5746 * @reset - non zero to reset all filters before applying this filter.
5758 * ftrace_set_global_notrace - set a function to not trace with global tracers
5759 * @buf - the string that holds the function notrace text.
5760 * @len - the length of the string.
5761 * @reset - non zero to reset all filters before applying this filter.
5842 printk(KERN_DEBUG "ftrace: function %s not " in set_ftrace_early_graph()
5882 struct seq_file *m = (struct seq_file *)file->private_data; in ftrace_regex_release()
5888 if (file->f_mode & FMODE_READ) { in ftrace_regex_release()
5889 iter = m->private; in ftrace_regex_release()
5892 iter = file->private_data; in ftrace_regex_release()
5894 parser = &iter->parser; in ftrace_regex_release()
5896 int enable = !(iter->flags & FTRACE_ITER_NOTRACE); in ftrace_regex_release()
5898 ftrace_process_regex(iter, parser->buffer, in ftrace_regex_release()
5899 parser->idx, enable); in ftrace_regex_release()
5904 mutex_lock(&iter->ops->func_hash->regex_lock); in ftrace_regex_release()
5906 if (file->f_mode & FMODE_WRITE) { in ftrace_regex_release()
5907 filter_hash = !!(iter->flags & FTRACE_ITER_FILTER); in ftrace_regex_release()
5910 orig_hash = &iter->ops->func_hash->filter_hash; in ftrace_regex_release()
5911 if (iter->tr) { in ftrace_regex_release()
5912 if (list_empty(&iter->tr->mod_trace)) in ftrace_regex_release()
5913 iter->hash->flags &= ~FTRACE_HASH_FL_MOD; in ftrace_regex_release()
5915 iter->hash->flags |= FTRACE_HASH_FL_MOD; in ftrace_regex_release()
5918 orig_hash = &iter->ops->func_hash->notrace_hash; in ftrace_regex_release()
5921 ftrace_hash_move_and_update_ops(iter->ops, orig_hash, in ftrace_regex_release()
5922 iter->hash, filter_hash); in ftrace_regex_release()
5926 iter->hash = NULL; in ftrace_regex_release()
5929 mutex_unlock(&iter->ops->func_hash->regex_lock); in ftrace_regex_release()
5930 free_ftrace_hash(iter->hash); in ftrace_regex_release()
5931 if (iter->tr) in ftrace_regex_release()
5932 trace_array_put(iter->tr); in ftrace_regex_release()
6009 struct ftrace_graph_data *fgd = m->private; in __g_next()
6010 struct ftrace_func_entry *entry = fgd->entry; in __g_next()
6012 int i, idx = fgd->idx; in __g_next()
6014 if (*pos >= fgd->hash->count) in __g_next()
6019 fgd->entry = entry; in __g_next()
6026 for (i = idx; i < 1 << fgd->hash->size_bits; i++) { in __g_next()
6027 head = &fgd->hash->buckets[i]; in __g_next()
6029 fgd->entry = entry; in __g_next()
6030 fgd->idx = i; in __g_next()
6046 struct ftrace_graph_data *fgd = m->private; in g_start()
6050 if (fgd->type == GRAPH_FILTER_FUNCTION) in g_start()
6051 fgd->hash = rcu_dereference_protected(ftrace_graph_hash, in g_start()
6054 fgd->hash = rcu_dereference_protected(ftrace_graph_notrace_hash, in g_start()
6058 if (ftrace_hash_empty(fgd->hash) && !*pos) in g_start()
6061 fgd->idx = 0; in g_start()
6062 fgd->entry = NULL; in g_start()
6079 struct ftrace_graph_data *fgd = m->private; in g_show()
6081 if (fgd->type == GRAPH_FILTER_FUNCTION) in g_show()
6088 seq_printf(m, "%ps\n", (void *)entry->ip); in g_show()
6111 if (file->f_mode & FMODE_WRITE) { in __ftrace_graph_open()
6114 if (trace_parser_get_init(&fgd->parser, FTRACE_BUFF_MAX)) in __ftrace_graph_open()
6115 return -ENOMEM; in __ftrace_graph_open()
6117 if (file->f_flags & O_TRUNC) in __ftrace_graph_open()
6121 fgd->hash); in __ftrace_graph_open()
6123 ret = -ENOMEM; in __ftrace_graph_open()
6128 if (file->f_mode & FMODE_READ) { in __ftrace_graph_open()
6131 struct seq_file *m = file->private_data; in __ftrace_graph_open()
6132 m->private = fgd; in __ftrace_graph_open()
6139 file->private_data = fgd; in __ftrace_graph_open()
6142 if (ret < 0 && file->f_mode & FMODE_WRITE) in __ftrace_graph_open()
6143 trace_parser_put(&fgd->parser); in __ftrace_graph_open()
6145 fgd->new_hash = new_hash; in __ftrace_graph_open()
6148 * All uses of fgd->hash must be taken with the graph_lock in __ftrace_graph_open()
6150 * fgd->hash to be reinitialized when it is taken again. in __ftrace_graph_open()
6152 fgd->hash = NULL; in __ftrace_graph_open()
6164 return -ENODEV; in ftrace_graph_open()
6168 return -ENOMEM; in ftrace_graph_open()
6172 fgd->hash = rcu_dereference_protected(ftrace_graph_hash, in ftrace_graph_open()
6174 fgd->type = GRAPH_FILTER_FUNCTION; in ftrace_graph_open()
6175 fgd->seq_ops = &ftrace_graph_seq_ops; in ftrace_graph_open()
6192 return -ENODEV; in ftrace_graph_notrace_open()
6196 return -ENOMEM; in ftrace_graph_notrace_open()
6200 fgd->hash = rcu_dereference_protected(ftrace_graph_notrace_hash, in ftrace_graph_notrace_open()
6202 fgd->type = GRAPH_FILTER_NOTRACE; in ftrace_graph_notrace_open()
6203 fgd->seq_ops = &ftrace_graph_seq_ops; in ftrace_graph_notrace_open()
6221 if (file->f_mode & FMODE_READ) { in ftrace_graph_release()
6222 struct seq_file *m = file->private_data; in ftrace_graph_release()
6224 fgd = m->private; in ftrace_graph_release()
6227 fgd = file->private_data; in ftrace_graph_release()
6231 if (file->f_mode & FMODE_WRITE) { in ftrace_graph_release()
6233 parser = &fgd->parser; in ftrace_graph_release()
6236 ret = ftrace_graph_set_hash(fgd->new_hash, in ftrace_graph_release()
6237 parser->buffer); in ftrace_graph_release()
6242 new_hash = __ftrace_hash_move(fgd->new_hash); in ftrace_graph_release()
6244 ret = -ENOMEM; in ftrace_graph_release()
6250 if (fgd->type == GRAPH_FILTER_FUNCTION) { in ftrace_graph_release()
6277 free_ftrace_hash(fgd->new_hash); in ftrace_graph_release()
6303 return -ENODEV; in ftrace_graph_set_hash()
6308 if (rec->flags & FTRACE_FL_DISABLED) in ftrace_graph_set_hash()
6312 entry = ftrace_lookup_ip(hash, rec->ip); in ftrace_graph_set_hash()
6319 if (add_hash_entry(hash, rec->ip) == NULL) in ftrace_graph_set_hash()
6333 return -EINVAL; in ftrace_graph_set_hash()
6343 struct ftrace_graph_data *fgd = file->private_data; in ftrace_graph_write()
6350 if (file->f_mode & FMODE_READ) { in ftrace_graph_write()
6351 struct seq_file *m = file->private_data; in ftrace_graph_write()
6352 fgd = m->private; in ftrace_graph_write()
6355 parser = &fgd->parser; in ftrace_graph_write()
6362 ret = ftrace_graph_set_hash(fgd->new_hash, in ftrace_graph_write()
6363 parser->buffer); in ftrace_graph_write()
6414 if (ops->flags & FTRACE_OPS_FL_ENABLED) in ftrace_destroy_filter_files()
6416 ops->flags |= FTRACE_OPS_FL_DELETED; in ftrace_destroy_filter_files()
6458 return -1; in ftrace_cmp_ips()
6468 if (WARN(start[i - 1] > start[i], in test_is_sorted()
6470 (void *)start[i - 1], start[i - 1], in test_is_sorted()
6475 pr_info("ftrace section at %px sorted properly\n", start); in test_is_sorted()
6496 int ret = -ENOMEM; in ftrace_process_locs()
6498 count = end - start; in ftrace_process_locs()
6517 return -ENOMEM; in ftrace_process_locs()
6534 if (WARN_ON(ftrace_pages->next)) { in ftrace_process_locs()
6536 while (ftrace_pages->next) in ftrace_process_locs()
6537 ftrace_pages = ftrace_pages->next; in ftrace_process_locs()
6540 ftrace_pages->next = start_pg; in ftrace_process_locs()
6559 end_offset = (pg->index+1) * sizeof(pg->records[0]); in ftrace_process_locs()
6560 if (end_offset > PAGE_SIZE << pg->order) { in ftrace_process_locs()
6562 if (WARN_ON(!pg->next)) in ftrace_process_locs()
6564 pg = pg->next; in ftrace_process_locs()
6567 rec = &pg->records[pg->index++]; in ftrace_process_locs()
6568 rec->ip = addr; in ftrace_process_locs()
6571 if (pg->next) { in ftrace_process_locs()
6572 pg_unuse = pg->next; in ftrace_process_locs()
6573 pg->next = NULL; in ftrace_process_locs()
6610 unsigned int size; member
6631 if (!op->trampoline || symnum--) in ftrace_get_trampoline_kallsym()
6633 *value = op->trampoline; in ftrace_get_trampoline_kallsym()
6641 return -ERANGE; in ftrace_get_trampoline_kallsym()
6656 if (!(ops->flags & FTRACE_OPS_FL_ENABLED)) in ops_references_ip()
6664 if (!ftrace_hash_empty(ops->func_hash->filter_hash) && in ops_references_ip()
6665 !__ftrace_lookup_ip(ops->func_hash->filter_hash, ip)) in ops_references_ip()
6669 if (ftrace_lookup_ip(ops->func_hash->notrace_hash, ip)) in ops_references_ip()
6687 for (ops = ftrace_ops_list; ops != &ftrace_list_end; ops = ops->next) { in referenced_filters()
6688 if (ops_references_ip(ops, rec->ip)) { in referenced_filters()
6689 if (WARN_ON_ONCE(ops->flags & FTRACE_OPS_FL_DIRECT)) in referenced_filters()
6691 if (WARN_ON_ONCE(ops->flags & FTRACE_OPS_FL_IPMODIFY)) in referenced_filters()
6694 if (ops->flags & FTRACE_OPS_FL_SAVE_REGS) in referenced_filters()
6695 rec->flags |= FTRACE_FL_REGS; in referenced_filters()
6696 if (cnt == 1 && ops->trampoline) in referenced_filters()
6697 rec->flags |= FTRACE_FL_TRAMP; in referenced_filters()
6699 rec->flags &= ~FTRACE_FL_TRAMP; in referenced_filters()
6716 for (i = 0; i < pg->index; i++) { in clear_mod_from_hash()
6717 rec = &pg->records[i]; in clear_mod_from_hash()
6718 entry = __ftrace_lookup_ip(hash, rec->ip); in clear_mod_from_hash()
6725 entry->ip = 0; in clear_mod_from_hash()
6736 if (!tr->ops || !tr->ops->func_hash) in clear_mod_from_hashes()
6738 mutex_lock(&tr->ops->func_hash->regex_lock); in clear_mod_from_hashes()
6739 clear_mod_from_hash(pg, tr->ops->func_hash->filter_hash); in clear_mod_from_hashes()
6740 clear_mod_from_hash(pg, tr->ops->func_hash->notrace_hash); in clear_mod_from_hashes()
6741 mutex_unlock(&tr->ops->func_hash->regex_lock); in clear_mod_from_hashes()
6753 list_for_each_entry_safe(mod_func, n, &mod_map->funcs, list) { in ftrace_free_mod_map()
6754 kfree(mod_func->name); in ftrace_free_mod_map()
6755 list_del(&mod_func->list); in ftrace_free_mod_map()
6777 if (mod_map->mod == mod) { in ftrace_release_mod()
6778 list_del_rcu(&mod_map->list); in ftrace_release_mod()
6779 call_rcu(&mod_map->rcu, ftrace_free_mod_map); in ftrace_release_mod()
6790 rec = &pg->records[0]; in ftrace_release_mod()
6791 if (within_module(rec->ip, mod)) { in ftrace_release_mod()
6803 ftrace_update_tot_cnt -= pg->index; in ftrace_release_mod()
6804 *last_pg = pg->next; in ftrace_release_mod()
6806 pg->next = tmp_page; in ftrace_release_mod()
6809 last_pg = &pg->next; in ftrace_release_mod()
6822 if (pg->records) { in ftrace_release_mod()
6823 free_pages((unsigned long)pg->records, pg->order); in ftrace_release_mod()
6824 ftrace_number_of_pages -= 1 << pg->order; in ftrace_release_mod()
6826 tmp_page = pg->next; in ftrace_release_mod()
6828 ftrace_number_of_groups--; in ftrace_release_mod()
6852 * text to read-only, as we now need to set it back to read-write in ftrace_module_enable()
6866 if (!within_module(rec->ip, mod)) in ftrace_module_enable()
6872 rec->flags = FTRACE_FL_DISABLED; in ftrace_module_enable()
6887 rec->flags &= ~FTRACE_FL_DISABLED; in ftrace_module_enable()
6888 rec->flags += cnt; in ftrace_module_enable()
6907 process_cached_mods(mod->name); in ftrace_module_enable()
6914 if (ftrace_disabled || !mod->num_ftrace_callsites) in ftrace_module_init()
6917 ret = ftrace_process_locs(mod, mod->ftrace_callsites, in ftrace_module_init()
6918 mod->ftrace_callsites + mod->num_ftrace_callsites); in ftrace_module_init()
6920 pr_warn("ftrace: failed to allocate entries for module '%s' functions\n", in ftrace_module_init()
6921 mod->name); in ftrace_module_init()
6934 ret = kallsyms_lookup(rec->ip, &symsize, &offset, &modname, str); in save_ftrace_mod_rec()
6942 mod_func->name = kstrdup(str, GFP_KERNEL); in save_ftrace_mod_rec()
6943 if (!mod_func->name) { in save_ftrace_mod_rec()
6948 mod_func->ip = rec->ip - offset; in save_ftrace_mod_rec()
6949 mod_func->size = symsize; in save_ftrace_mod_rec()
6951 mod_map->num_funcs++; in save_ftrace_mod_rec()
6953 list_add_rcu(&mod_func->list, &mod_map->funcs); in save_ftrace_mod_rec()
6966 mod_map->mod = mod; in allocate_ftrace_mod_map()
6967 mod_map->start_addr = start; in allocate_ftrace_mod_map()
6968 mod_map->end_addr = end; in allocate_ftrace_mod_map()
6969 mod_map->num_funcs = 0; in allocate_ftrace_mod_map()
6971 INIT_LIST_HEAD_RCU(&mod_map->funcs); in allocate_ftrace_mod_map()
6973 list_add_rcu(&mod_map->list, &ftrace_mod_maps); in allocate_ftrace_mod_map()
6980 unsigned long addr, unsigned long *size, in ftrace_func_address_lookup() argument
6986 list_for_each_entry_rcu(mod_func, &mod_map->funcs, list) { in ftrace_func_address_lookup()
6987 if (addr >= mod_func->ip && in ftrace_func_address_lookup()
6988 addr < mod_func->ip + mod_func->size) { in ftrace_func_address_lookup()
6995 if (size) in ftrace_func_address_lookup()
6996 *size = found_func->size; in ftrace_func_address_lookup()
6998 *off = addr - found_func->ip; in ftrace_func_address_lookup()
7000 strscpy(sym, found_func->name, KSYM_NAME_LEN); in ftrace_func_address_lookup()
7002 return found_func->name; in ftrace_func_address_lookup()
7009 ftrace_mod_address_lookup(unsigned long addr, unsigned long *size, in ftrace_mod_address_lookup() argument
7018 ret = ftrace_func_address_lookup(mod_map, addr, size, off, sym); in ftrace_mod_address_lookup()
7021 *modname = mod_map->mod->name; in ftrace_mod_address_lookup()
7041 if (symnum >= mod_map->num_funcs) { in ftrace_mod_get_kallsym()
7042 symnum -= mod_map->num_funcs; in ftrace_mod_get_kallsym()
7046 list_for_each_entry_rcu(mod_func, &mod_map->funcs, list) { in ftrace_mod_get_kallsym()
7048 symnum--; in ftrace_mod_get_kallsym()
7052 *value = mod_func->ip; in ftrace_mod_get_kallsym()
7054 strscpy(name, mod_func->name, KSYM_NAME_LEN); in ftrace_mod_get_kallsym()
7055 strscpy(module_name, mod_map->mod->name, MODULE_NAME_LEN); in ftrace_mod_get_kallsym()
7103 entry = ftrace_lookup_ip(hash, func->ip); in clear_func_from_hash()
7110 entry->ip = 0; in clear_func_from_hash()
7120 if (!tr->ops || !tr->ops->func_hash) in clear_func_from_hashes()
7122 mutex_lock(&tr->ops->func_hash->regex_lock); in clear_func_from_hashes()
7123 clear_func_from_hash(func, tr->ops->func_hash->filter_hash); in clear_func_from_hashes()
7124 clear_func_from_hash(func, tr->ops->func_hash->notrace_hash); in clear_func_from_hashes()
7125 mutex_unlock(&tr->ops->func_hash->regex_lock); in clear_func_from_hashes()
7137 MEM_FAIL(1, "alloc failure, ftrace filter could be stale\n"); in add_to_clear_hash_list()
7141 func->ip = rec->ip; in add_to_clear_hash_list()
7142 list_add(&func->list, clear_list); in add_to_clear_hash_list()
7171 for (pg = ftrace_pages_start; pg; last_pg = &pg->next, pg = *last_pg) { in ftrace_free_mem()
7172 if (end < pg->records[0].ip || in ftrace_free_mem()
7173 start >= (pg->records[pg->index - 1].ip + MCOUNT_INSN_SIZE)) in ftrace_free_mem()
7176 rec = bsearch(&key, pg->records, pg->index, in ftrace_free_mem()
7188 pg->index--; in ftrace_free_mem()
7189 ftrace_update_tot_cnt--; in ftrace_free_mem()
7190 if (!pg->index) { in ftrace_free_mem()
7191 *last_pg = pg->next; in ftrace_free_mem()
7192 pg->next = tmp_page; in ftrace_free_mem()
7200 (pg->index - (rec - pg->records)) * sizeof(*rec)); in ftrace_free_mem()
7245 count = __stop_mcount_loc - __start_mcount_loc; in ftrace_init()
7247 pr_info("ftrace: No functions to be traced?\n"); in ftrace_init()
7251 pr_info("ftrace: allocating %ld entries in %ld pages\n", in ftrace_init()
7258 pr_warn("ftrace: failed to allocate entries for functions\n"); in ftrace_init()
7262 pr_info("ftrace: allocated %ld pages with %ld groups\n", in ftrace_init()
7281 unsigned long trampoline = ops->trampoline; in ftrace_update_trampoline()
7284 if (ops->trampoline && ops->trampoline != trampoline && in ftrace_update_trampoline()
7285 (ops->flags & FTRACE_OPS_FL_ALLOC_TRAMP)) { in ftrace_update_trampoline()
7289 ops->trampoline, ops->trampoline_size, false, in ftrace_update_trampoline()
7295 perf_event_text_poke((void *)ops->trampoline, NULL, 0, in ftrace_update_trampoline()
7296 (void *)ops->trampoline, in ftrace_update_trampoline()
7297 ops->trampoline_size); in ftrace_update_trampoline()
7303 INIT_LIST_HEAD(&tr->func_probes); in ftrace_init_trace_array()
7304 INIT_LIST_HEAD(&tr->mod_trace); in ftrace_init_trace_array()
7305 INIT_LIST_HEAD(&tr->mod_notrace); in ftrace_init_trace_array()
7333 tr->ops = &global_ops; in ftrace_init_global_array_ops()
7334 tr->ops->private = tr; in ftrace_init_global_array_ops()
7341 if (tr->flags & TRACE_ARRAY_FL_GLOBAL) { in ftrace_init_array_ops()
7342 if (WARN_ON(tr->ops->func != ftrace_stub)) in ftrace_init_array_ops()
7343 printk("ftrace ops had %pS for function\n", in ftrace_init_array_ops()
7344 tr->ops->func); in ftrace_init_array_ops()
7346 tr->ops->func = func; in ftrace_init_array_ops()
7347 tr->ops->private = tr; in ftrace_init_array_ops()
7352 tr->ops->func = ftrace_stub; in ftrace_reset_array_ops()
7374 if (op->flags & FTRACE_OPS_FL_STUB) in __ftrace_ops_list_func()
7381 * If any of the above fails then the op->func() is not executed. in __ftrace_ops_list_func()
7383 if ((!(op->flags & FTRACE_OPS_FL_RCU) || rcu_is_watching()) && in __ftrace_ops_list_func()
7385 if (FTRACE_WARN_ON(!op->func)) { in __ftrace_ops_list_func()
7389 op->func(ip, parent_ip, op, fregs); in __ftrace_ops_list_func()
7440 if (!(op->flags & FTRACE_OPS_FL_RCU) || rcu_is_watching()) in ftrace_ops_assist_func()
7441 op->func(ip, parent_ip, op, fregs); in ftrace_ops_assist_func()
7448 * ftrace_ops_get_func - get the function a trampoline should call
7451 * Normally the mcount trampoline will call the ops->func, but there
7464 if (ops->flags & (FTRACE_OPS_FL_RECURSION | in ftrace_ops_get_func()
7468 return ops->func; in ftrace_ops_get_func()
7481 pid_list = rcu_dereference_sched(tr->function_pids); in ftrace_filter_pid_sched_switch_probe()
7482 no_pid_list = rcu_dereference_sched(tr->function_no_pids); in ftrace_filter_pid_sched_switch_probe()
7485 this_cpu_write(tr->array_buffer.data->ftrace_ignore_pid, in ftrace_filter_pid_sched_switch_probe()
7488 this_cpu_write(tr->array_buffer.data->ftrace_ignore_pid, in ftrace_filter_pid_sched_switch_probe()
7489 next->pid); in ftrace_filter_pid_sched_switch_probe()
7500 pid_list = rcu_dereference_sched(tr->function_pids); in ftrace_pid_follow_sched_process_fork()
7503 pid_list = rcu_dereference_sched(tr->function_no_pids); in ftrace_pid_follow_sched_process_fork()
7513 pid_list = rcu_dereference_sched(tr->function_pids); in ftrace_pid_follow_sched_process_exit()
7516 pid_list = rcu_dereference_sched(tr->function_no_pids); in ftrace_pid_follow_sched_process_exit()
7541 pid_list = rcu_dereference_protected(tr->function_pids, in clear_ftrace_pids()
7543 no_pid_list = rcu_dereference_protected(tr->function_no_pids, in clear_ftrace_pids()
7554 per_cpu_ptr(tr->array_buffer.data, cpu)->ftrace_ignore_pid = FTRACE_PID_TRACE; in clear_ftrace_pids()
7558 rcu_assign_pointer(tr->function_pids, NULL); in clear_ftrace_pids()
7561 rcu_assign_pointer(tr->function_no_pids, NULL); in clear_ftrace_pids()
7600 struct trace_array *tr = m->private; in fpid_start()
7605 pid_list = rcu_dereference_sched(tr->function_pids); in fpid_start()
7615 struct trace_array *tr = m->private; in fpid_next()
7616 struct trace_pid_list *pid_list = rcu_dereference_sched(tr->function_pids); in fpid_next()
7653 struct trace_array *tr = m->private; in fnpid_start()
7658 pid_list = rcu_dereference_sched(tr->function_no_pids); in fnpid_start()
7668 struct trace_array *tr = m->private; in fnpid_next()
7669 struct trace_pid_list *pid_list = rcu_dereference_sched(tr->function_no_pids); in fnpid_next()
7688 struct trace_array *tr = inode->i_private; in pid_open()
7696 if ((file->f_mode & FMODE_WRITE) && in pid_open()
7697 (file->f_flags & O_TRUNC)) in pid_open()
7710 return -EINVAL; in pid_open()
7717 m = file->private_data; in pid_open()
7719 m->private = tr; in pid_open()
7747 pid_list = rcu_dereference_protected(tr->function_pids, in ignore_task_cpu()
7749 no_pid_list = rcu_dereference_protected(tr->function_no_pids, in ignore_task_cpu()
7753 this_cpu_write(tr->array_buffer.data->ftrace_ignore_pid, in ignore_task_cpu()
7756 this_cpu_write(tr->array_buffer.data->ftrace_ignore_pid, in ignore_task_cpu()
7757 current->pid); in ignore_task_cpu()
7764 struct seq_file *m = filp->private_data; in pid_write()
7765 struct trace_array *tr = m->private; in pid_write()
7778 filtered_pids = rcu_dereference_protected(tr->function_pids, in pid_write()
7780 other_pids = rcu_dereference_protected(tr->function_no_pids, in pid_write()
7784 filtered_pids = rcu_dereference_protected(tr->function_no_pids, in pid_write()
7786 other_pids = rcu_dereference_protected(tr->function_pids, in pid_write()
7790 ret = -EINVAL; in pid_write()
7801 rcu_assign_pointer(tr->function_pids, pid_list); in pid_write()
7804 rcu_assign_pointer(tr->function_no_pids, pid_list); in pid_write()
7852 struct trace_array *tr = inode->i_private; in ftrace_pid_release()
7887 WARN_ON(!(tr->flags & TRACE_ARRAY_FL_GLOBAL)); in ftrace_init_tracefs_toplevel()
7894 * ftrace_kill - kill ftrace
7896 * This function should be used by panic code. It stops ftrace
7897 * but in a not so nice way. If you need to simply kill ftrace
7898 * from a non-atomic section, use ftrace_kill.
7909 * ftrace_is_dead - Test if ftrace is dead or not.
7911 * Returns 1 if ftrace is "dead", zero otherwise.
7936 int size, i, ret; in prepare_direct_functions_for_ipmodify() local
7940 if (!(ops->flags & FTRACE_OPS_FL_IPMODIFY)) in prepare_direct_functions_for_ipmodify()
7943 hash = ops->func_hash->filter_hash; in prepare_direct_functions_for_ipmodify()
7944 size = 1 << hash->size_bits; in prepare_direct_functions_for_ipmodify()
7945 for (i = 0; i < size; i++) { in prepare_direct_functions_for_ipmodify()
7946 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in prepare_direct_functions_for_ipmodify()
7947 unsigned long ip = entry->ip; in prepare_direct_functions_for_ipmodify()
7952 if (!(op->flags & FTRACE_OPS_FL_DIRECT)) in prepare_direct_functions_for_ipmodify()
7962 if (!op->ops_func) in prepare_direct_functions_for_ipmodify()
7963 return -EBUSY; in prepare_direct_functions_for_ipmodify()
7965 ret = op->ops_func(op, FTRACE_OPS_CMD_ENABLE_SHARE_IPMODIFY_PEER); in prepare_direct_functions_for_ipmodify()
7985 int size, i; in cleanup_direct_functions_after_ipmodify() local
7987 if (!(ops->flags & FTRACE_OPS_FL_IPMODIFY)) in cleanup_direct_functions_after_ipmodify()
7992 hash = ops->func_hash->filter_hash; in cleanup_direct_functions_after_ipmodify()
7993 size = 1 << hash->size_bits; in cleanup_direct_functions_after_ipmodify()
7994 for (i = 0; i < size; i++) { in cleanup_direct_functions_after_ipmodify()
7995 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in cleanup_direct_functions_after_ipmodify()
7996 unsigned long ip = entry->ip; in cleanup_direct_functions_after_ipmodify()
8001 if (!(op->flags & FTRACE_OPS_FL_DIRECT)) in cleanup_direct_functions_after_ipmodify()
8011 if (found_op && op->ops_func) in cleanup_direct_functions_after_ipmodify()
8012 op->ops_func(op, FTRACE_OPS_CMD_DISABLE_SHARE_IPMODIFY_PEER); in cleanup_direct_functions_after_ipmodify()
8056 * register_ftrace_function - register a function for profiling
8062 * Note: @ops->func and all the functions it calls must be labeled
8084 * unregister_ftrace_function - unregister a function for profiling.
8087 * Unregister a function that was added to be called by ftrace profiling.
8127 sym = bsearch(&name, args->syms, args->cnt, sizeof(*args->syms), symbols_cmp); in kallsyms_callback()
8131 idx = sym - args->syms; in kallsyms_callback()
8132 if (args->addrs[idx]) in kallsyms_callback()
8138 args->addrs[idx] = addr; in kallsyms_callback()
8139 args->found++; in kallsyms_callback()
8140 return args->found == args->cnt ? 1 : 0; in kallsyms_callback()
8144 * ftrace_lookup_symbols - Lookup addresses for array of symbols
8157 * -ESRCH otherwise.
8174 return found_all ? 0 : -ESRCH; in ftrace_lookup_symbols()
8189 /* ftrace_start_up is true if we want ftrace running */ in ftrace_startup_sysctl()
8205 /* ftrace_start_up is true if ftrace is running */ in ftrace_shutdown_sysctl()
8223 if (op->flags & FTRACE_OPS_FL_PERMANENT) in is_permanent_ops_registered()
8234 int ret = -ENODEV; in ftrace_enable_sysctl()
8248 /* we are starting ftrace again */ in ftrace_enable_sysctl()
8258 ret = -EBUSY; in ftrace_enable_sysctl()
8262 /* stopping ftrace calls (just send to ftrace_stub) */ in ftrace_enable_sysctl()