Lines Matching full:hash

35 #include <linux/hash.h>
70 /* hash bits for specific function selection */
433 struct hlist_head *hash; member
626 memset(stat->hash, 0, in ftrace_profile_reset()
693 if (stat->hash) { in ftrace_profile_init_cpu()
701 * functions are hit. We'll make a hash of 1024 items. in ftrace_profile_init_cpu()
705 stat->hash = kzalloc_objs(struct hlist_head, size); in ftrace_profile_init_cpu()
707 if (!stat->hash) in ftrace_profile_init_cpu()
712 kfree(stat->hash); in ftrace_profile_init_cpu()
713 stat->hash = NULL; in ftrace_profile_init_cpu()
743 hhd = &stat->hash[key]; in ftrace_find_profiled_func()
762 hlist_add_head_rcu(&rec->node, &stat->hash[key]); in ftrace_add_profile()
814 if (!stat->hash || !ftrace_profile_enabled) in function_profile_call()
880 if (!stat->hash || !ftrace_profile_enabled) in profile_graph_return()
1081 * but they are used as the default "empty hash", to avoid allocating
1156 ftrace_hash_key(struct ftrace_hash *hash, unsigned long ip) in ftrace_hash_key() argument
1158 if (hash->size_bits > 0) in ftrace_hash_key()
1159 return hash_long(ip, hash->size_bits); in ftrace_hash_key()
1166 __ftrace_lookup_ip(struct ftrace_hash *hash, unsigned long ip) in __ftrace_lookup_ip() argument
1172 key = ftrace_hash_key(hash, ip); in __ftrace_lookup_ip()
1173 hhd = &hash->buckets[key]; in __ftrace_lookup_ip()
1184 * @hash: The hash to look at
1187 * Search a given @hash to see if a given instruction pointer (@ip)
1193 ftrace_lookup_ip(struct ftrace_hash *hash, unsigned long ip) in ftrace_lookup_ip() argument
1195 if (ftrace_hash_empty(hash)) in ftrace_lookup_ip()
1198 return __ftrace_lookup_ip(hash, ip); in ftrace_lookup_ip()
1201 static void __add_hash_entry(struct ftrace_hash *hash, in __add_hash_entry() argument
1207 key = ftrace_hash_key(hash, entry->ip); in __add_hash_entry()
1208 hhd = &hash->buckets[key]; in __add_hash_entry()
1210 hash->count++; in __add_hash_entry()
1214 add_ftrace_hash_entry_direct(struct ftrace_hash *hash, unsigned long ip, unsigned long direct) in add_ftrace_hash_entry_direct() argument
1224 __add_hash_entry(hash, entry); in add_ftrace_hash_entry_direct()
1230 add_hash_entry(struct ftrace_hash *hash, unsigned long ip) in add_hash_entry() argument
1232 return add_ftrace_hash_entry_direct(hash, ip, 0); in add_hash_entry()
1236 free_hash_entry(struct ftrace_hash *hash, in free_hash_entry() argument
1241 hash->count--; in free_hash_entry()
1245 remove_hash_entry(struct ftrace_hash *hash, in remove_hash_entry() argument
1249 hash->count--; in remove_hash_entry()
1252 static void ftrace_hash_clear(struct ftrace_hash *hash) in ftrace_hash_clear() argument
1257 int size = 1 << hash->size_bits; in ftrace_hash_clear()
1260 if (!hash->count) in ftrace_hash_clear()
1264 hhd = &hash->buckets[i]; in ftrace_hash_clear()
1266 free_hash_entry(hash, entry); in ftrace_hash_clear()
1268 FTRACE_WARN_ON(hash->count); in ftrace_hash_clear()
1293 void free_ftrace_hash(struct ftrace_hash *hash) in free_ftrace_hash() argument
1295 if (!hash || hash == EMPTY_HASH) in free_ftrace_hash()
1297 ftrace_hash_clear(hash); in free_ftrace_hash()
1298 kfree(hash->buckets); in free_ftrace_hash()
1299 kfree(hash); in free_ftrace_hash()
1304 struct ftrace_hash *hash; in __free_ftrace_hash_rcu() local
1306 hash = container_of(rcu, struct ftrace_hash, rcu); in __free_ftrace_hash_rcu()
1307 free_ftrace_hash(hash); in __free_ftrace_hash_rcu()
1310 static void free_ftrace_hash_rcu(struct ftrace_hash *hash) in free_ftrace_hash_rcu() argument
1312 if (!hash || hash == EMPTY_HASH) in free_ftrace_hash_rcu()
1314 call_rcu(&hash->rcu, __free_ftrace_hash_rcu); in free_ftrace_hash_rcu()
1335 struct ftrace_hash *hash; in alloc_ftrace_hash() local
1338 hash = kzalloc_obj(*hash); in alloc_ftrace_hash()
1339 if (!hash) in alloc_ftrace_hash()
1343 hash->buckets = kzalloc_objs(*hash->buckets, size); in alloc_ftrace_hash()
1345 if (!hash->buckets) { in alloc_ftrace_hash()
1346 kfree(hash); in alloc_ftrace_hash()
1350 hash->size_bits = size_bits; in alloc_ftrace_hash()
1352 return hash; in alloc_ftrace_hash()
1386 alloc_and_copy_ftrace_hash(int size_bits, struct ftrace_hash *hash) in alloc_and_copy_ftrace_hash() argument
1397 if (hash) in alloc_and_copy_ftrace_hash()
1398 new_hash->flags = hash->flags; in alloc_and_copy_ftrace_hash()
1400 /* Empty hash? */ in alloc_and_copy_ftrace_hash()
1401 if (ftrace_hash_empty(hash)) in alloc_and_copy_ftrace_hash()
1404 size = 1 << hash->size_bits; in alloc_and_copy_ftrace_hash()
1406 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in alloc_and_copy_ftrace_hash()
1412 FTRACE_WARN_ON(new_hash->count != hash->count); in alloc_and_copy_ftrace_hash()
1428 * Allocate a new hash and remove entries from @src and move them to the new hash.
1429 * On success, the @src hash will be empty and should be freed.
1467 /* Move the @src entries to a newly allocated hash */
1483 * ftrace_hash_move - move a new hash to a filter and do updates
1484 * @ops: The ops with the hash that @dst points to
1485 * @enable: True if for the filter hash, false for the notrace hash
1486 * @dst: Points to the @ops hash that should be updated
1487 * @src: The hash to update @dst with
1489 * This is called when an ftrace_ops hash is being updated and the
1492 * @enable above). If the @ops is enabled, its hash determines what
1493 * callbacks get called. This function gets called when the @ops hash
1509 /* Reject setting notrace hash on IPMODIFY ftrace_ops */ in ftrace_hash_move()
1528 * Remove the current set, update the hash and add in ftrace_hash_move()
1541 struct ftrace_ops_hash *hash) in hash_contains_ip() argument
1545 * hash and not in the notrace hash. Note, an empty hash is in hash_contains_ip()
1546 * considered a match for the filter hash, but an empty in hash_contains_ip()
1547 * notrace hash is considered not in the notrace hash. in hash_contains_ip()
1549 return (ftrace_hash_empty(hash->filter_hash) || in hash_contains_ip()
1550 __ftrace_lookup_ip(hash->filter_hash, ip)) && in hash_contains_ip()
1551 (ftrace_hash_empty(hash->notrace_hash) || in hash_contains_ip()
1552 !__ftrace_lookup_ip(hash->notrace_hash, ip)); in hash_contains_ip()
1570 struct ftrace_ops_hash hash; in ftrace_ops_test() local
1583 rcu_assign_pointer(hash.filter_hash, ops->func_hash->filter_hash); in ftrace_ops_test()
1584 rcu_assign_pointer(hash.notrace_hash, ops->func_hash->notrace_hash); in ftrace_ops_test()
1586 if (hash_contains_ip(ip, &hash)) in ftrace_ops_test()
1769 struct ftrace_hash *hash; in __ftrace_hash_rec_update() local
1783 * Otherwise we just update the items in the hash. in __ftrace_hash_rec_update()
1785 hash = ops->func_hash->filter_hash; in __ftrace_hash_rec_update()
1787 if (ftrace_hash_empty(hash)) in __ftrace_hash_rec_update()
1801 * Update if the record is not in the notrace hash. in __ftrace_hash_rec_update()
1806 in_hash = !!ftrace_lookup_ip(hash, rec->ip); in __ftrace_hash_rec_update()
1810 * We want to match all functions that are in the hash but in __ftrace_hash_rec_update()
1811 * not in the other hash. in __ftrace_hash_rec_update()
1912 if (!all && count == hash->count) in __ftrace_hash_rec_update()
1948 * ops->hash = new_hash
1952 * its old hash. The @ops hash is updated to the new hash, and then
1966 * If the ops shares the global_ops hash, then we need to update in ftrace_hash_rec_update_modify()
1967 * all ops that are enabled and use this hash. in ftrace_hash_rec_update_modify()
1993 * - If the hash is NULL, it hits all recs (if IPMODIFY is set, this is rejected)
1994 * - If the hash is EMPTY_HASH, it hits nothing
1995 * - Anything else hits the recs which match the hash entries.
2031 * hash. in __ftrace_hash_update_ipmodify()
2119 struct ftrace_hash *hash = ops->func_hash->filter_hash; in ftrace_hash_ipmodify_enable() local
2121 if (ftrace_hash_empty(hash)) in ftrace_hash_ipmodify_enable()
2122 hash = NULL; in ftrace_hash_ipmodify_enable()
2124 return __ftrace_hash_update_ipmodify(ops, EMPTY_HASH, hash, false); in ftrace_hash_ipmodify_enable()
2130 struct ftrace_hash *hash = ops->func_hash->filter_hash; in ftrace_hash_ipmodify_disable() local
2132 if (ftrace_hash_empty(hash)) in ftrace_hash_ipmodify_disable()
2133 hash = NULL; in ftrace_hash_ipmodify_disable()
2135 __ftrace_hash_update_ipmodify(ops, hash, EMPTY_HASH, false); in ftrace_hash_ipmodify_disable()
2557 * hash, then it is probably being removed from this in ftrace_find_tramp_ops_curr()
2565 * in its normal filter hash, then this must be the one in ftrace_find_tramp_ops_curr()
2617 * Search the direct_functions hash to see if the given instruction pointer
3256 * Append @new_hash entries to @hash:
3258 * If @hash is the EMPTY_HASH then it traces all functions and nothing
3261 * If @new_hash is the EMPTY_HASH, then make *hash the EMPTY_HASH so
3264 * Otherwise, go through all of @new_hash and add anything that @hash
3265 * doesn't already have, to @hash.
3270 static int append_hash(struct ftrace_hash **hash, struct ftrace_hash *new_hash, in append_hash() argument
3277 if (*hash) { in append_hash()
3278 /* An empty hash does everything */ in append_hash()
3279 if (ftrace_hash_empty(*hash)) in append_hash()
3282 *hash = alloc_ftrace_hash(size_bits); in append_hash()
3283 if (!*hash) in append_hash()
3287 /* If new_hash has everything make hash have everything */ in append_hash()
3289 free_ftrace_hash(*hash); in append_hash()
3290 *hash = EMPTY_HASH; in append_hash()
3297 /* Only add if not already in hash */ in append_hash()
3298 if (!__ftrace_lookup_ip(*hash, entry->ip) && in append_hash()
3299 add_hash_entry(*hash, entry->ip) == NULL) in append_hash()
3307 * Remove functions from @hash that are in @notrace_hash
3309 static void remove_hash(struct ftrace_hash *hash, struct ftrace_hash *notrace_hash) in remove_hash() argument
3316 /* If the notrace hash is empty, there's nothing to do */ in remove_hash()
3320 size = 1 << hash->size_bits; in remove_hash()
3322 hlist_for_each_entry_safe(entry, tmp, &hash->buckets[i], hlist) { in remove_hash()
3325 remove_hash_entry(hash, entry); in remove_hash()
3332 * Add to @hash only those that are in both @new_hash1 and @new_hash2
3337 static int intersect_hash(struct ftrace_hash **hash, struct ftrace_hash *new_hash1, in intersect_hash() argument
3345 * If new_hash1 or new_hash2 is the EMPTY_HASH then make the hash in intersect_hash()
3349 free_ftrace_hash(*hash); in intersect_hash()
3350 *hash = EMPTY_HASH; in intersect_hash()
3359 add_hash_entry(*hash, entry->ip) == NULL) in intersect_hash()
3364 if (ftrace_hash_empty(*hash)) { in intersect_hash()
3365 free_ftrace_hash(*hash); in intersect_hash()
3366 *hash = EMPTY_HASH; in intersect_hash()
3402 struct ftrace_hash *hash, in __ftrace_hash_move_and_update_ops() argument
3412 ret = ftrace_hash_move(ops, enable, orig_hash, hash); in __ftrace_hash_move_and_update_ops()
3445 /* If the filter hash is not empty, simply remove the nohash from it */ in add_first_hash()
3474 * The main ops filter hash is not empty, so its in add_next_hash()
3475 * notrace_hash had better be, as the notrace hash in add_next_hash()
3483 /* Copy the subops hash */ in add_next_hash()
3500 * Only process notrace hashes if the main filter hash is empty in add_next_hash()
3501 * (tracing all functions), otherwise the filter hash will just in add_next_hash()
3502 * remove the notrace hash functions, and the notrace hash is in add_next_hash()
3604 * o Make a copy of the subops filter hash in ftrace_startup_subops()
3606 * o Add in the main hash filter functions in ftrace_startup_subops()
3607 * o Remove any of these functions from the main notrace hash in ftrace_startup_subops()
3733 struct ftrace_hash *hash) in ftrace_hash_move_and_update_subops() argument
3746 /* Move the new hash over to the subops hash */ in ftrace_hash_move_and_update_subops()
3748 *orig_subhash = __ftrace_hash_move(hash); in ftrace_hash_move_and_update_subops()
3762 /* Put back the original hash */ in ftrace_hash_move_and_update_subops()
3783 * But notrace hash requires a test of individual module functions. in ops_traces_mod()
3958 struct ftrace_hash *hash; member
3973 struct ftrace_hash *hash; in t_probe_next() local
3997 hash = iter->probe->ops.func_hash->filter_hash; in t_probe_next()
4000 * A probe being registered may temporarily have an empty hash in t_probe_next()
4003 if (!hash || hash == EMPTY_HASH) in t_probe_next()
4006 size = 1 << hash->size_bits; in t_probe_next()
4014 hash = iter->probe->ops.func_hash->filter_hash; in t_probe_next()
4015 size = 1 << hash->size_bits; in t_probe_next()
4019 hhd = &hash->buckets[iter->pidx]; in t_probe_next()
4192 !ftrace_lookup_ip(iter->hash, rec->ip)) || in t_func_next()
4274 ftrace_hash_empty(iter->hash)) { in t_start()
4655 * @ops: The ftrace_ops that hold the hash filters
4661 * @ops. Depending on @flag it may process the filter hash or
4662 * the notrace hash of @ops. With this called from the open
4676 struct ftrace_hash *hash; in ftrace_regex_open() local
4703 hash = ops->func_hash->notrace_hash; in ftrace_regex_open()
4706 hash = ops->func_hash->filter_hash; in ftrace_regex_open()
4716 iter->hash = alloc_ftrace_hash(size_bits); in ftrace_regex_open()
4719 iter->hash = alloc_and_copy_ftrace_hash(size_bits, hash); in ftrace_regex_open()
4722 if (hash) in ftrace_regex_open()
4723 iter->hash = alloc_and_copy_ftrace_hash(hash->size_bits, hash); in ftrace_regex_open()
4725 iter->hash = EMPTY_HASH; in ftrace_regex_open()
4728 if (!iter->hash) { in ftrace_regex_open()
4744 free_ftrace_hash(iter->hash); in ftrace_regex_open()
4837 enter_record(struct ftrace_hash *hash, struct dyn_ftrace *rec, int clear_filter) in enter_record() argument
4842 entry = ftrace_lookup_ip(hash, rec->ip); in enter_record()
4848 free_hash_entry(hash, entry); in enter_record()
4853 if (add_hash_entry(hash, rec->ip) == NULL) in enter_record()
4860 add_rec_by_index(struct ftrace_hash *hash, struct ftrace_glob *func_g, in add_rec_by_index() argument
4878 enter_record(hash, rec, clear_filter); in add_rec_by_index()
4946 match_records(struct ftrace_hash *hash, char *func, int len, char *mod) in match_records() argument
4976 return add_rec_by_index(hash, &func_g, clear_filter); in match_records()
4984 ret = enter_record(hash, rec, clear_filter); in match_records()
4996 ftrace_match_records(struct ftrace_hash *hash, char *buff, int len) in ftrace_match_records() argument
4998 return match_records(hash, buff, len, NULL); in ftrace_match_records()
5034 struct ftrace_hash *hash, in ftrace_hash_move_and_update_ops() argument
5038 return ftrace_hash_move_and_update_subops(ops, orig_hash, hash); in ftrace_hash_move_and_update_ops()
5050 /* Check if any other manager subops maps to this hash */ in ftrace_hash_move_and_update_ops()
5057 return ftrace_hash_move_and_update_subops(subops, orig_hash, hash); in ftrace_hash_move_and_update_ops()
5063 return __ftrace_hash_move_and_update_ops(ops, orig_hash, hash, enable); in ftrace_hash_move_and_update_ops()
5080 /* Look to remove this hash */ in cache_mod()
5202 ftrace_mod_callback(struct trace_array *tr, struct ftrace_hash *hash, in ftrace_mod_callback() argument
5223 ret = match_records(hash, func, strlen(func), module); in ftrace_mod_callback()
5255 * period. This syncs the hash iteration and freeing of items in function_trace_probe_call()
5256 * on the hash. rcu_read_lock is too dangerous here. in function_trace_probe_call()
5269 * Note, ftrace_func_mapper is freed by free_ftrace_hash(&mapper->hash).
5270 * The hash field must be the first field.
5273 struct ftrace_hash hash; /* Must be first! */ member
5283 struct ftrace_hash *hash; in allocate_ftrace_func_mapper() local
5287 * in the hash are not ftrace_func_entry type, we define it in allocate_ftrace_func_mapper()
5290 hash = alloc_ftrace_hash(FTRACE_HASH_DEFAULT_BITS); in allocate_ftrace_func_mapper()
5291 return (struct ftrace_func_mapper *)hash; in allocate_ftrace_func_mapper()
5311 entry = ftrace_lookup_ip(&mapper->hash, ip); in ftrace_func_mapper_find_ip()
5333 entry = ftrace_lookup_ip(&mapper->hash, ip); in ftrace_func_mapper_add_ip()
5344 __add_hash_entry(&mapper->hash, &map->entry); in ftrace_func_mapper_add_ip()
5366 entry = ftrace_lookup_ip(&mapper->hash, ip); in ftrace_func_mapper_remove_ip()
5373 remove_hash_entry(&mapper->hash, entry); in ftrace_func_mapper_remove_ip()
5398 if (free_func && mapper->hash.count) { in free_ftrace_func_mapper()
5399 size = 1 << mapper->hash.size_bits; in free_ftrace_func_mapper()
5401 hhd = &mapper->hash.buckets[i]; in free_ftrace_func_mapper()
5409 free_ftrace_hash(&mapper->hash); in free_ftrace_func_mapper()
5454 struct ftrace_hash *hash; in register_ftrace_function_probe() local
5501 hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, old_hash); in register_ftrace_function_probe()
5503 if (!hash) { in register_ftrace_function_probe()
5508 ret = ftrace_match_records(hash, glob, strlen(glob)); in register_ftrace_function_probe()
5517 size = 1 << hash->size_bits; in register_ftrace_function_probe()
5519 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in register_ftrace_function_probe()
5552 hash, 1); in register_ftrace_function_probe()
5569 free_ftrace_hash(hash); in register_ftrace_function_probe()
5581 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in register_ftrace_function_probe()
5600 struct ftrace_hash *hash = NULL; in unregister_ftrace_function_probe_func() local
5654 hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, old_hash); in unregister_ftrace_function_probe_func()
5655 if (!hash) in unregister_ftrace_function_probe_func()
5660 size = 1 << hash->size_bits; in unregister_ftrace_function_probe_func()
5662 hlist_for_each_entry_safe(entry, tmp, &hash->buckets[i], hlist) { in unregister_ftrace_function_probe_func()
5671 remove_hash_entry(hash, entry); in unregister_ftrace_function_probe_func()
5688 if (ftrace_hash_empty(hash)) in unregister_ftrace_function_probe_func()
5692 hash, 1); in unregister_ftrace_function_probe_func()
5695 if (ftrace_enabled && !ftrace_hash_empty(hash)) in unregister_ftrace_function_probe_func()
5710 free_ftrace_hash(hash); in unregister_ftrace_function_probe_func()
5773 struct ftrace_hash *hash = iter->hash; in ftrace_process_regex() local
5782 ret = ftrace_match_records(hash, func, len); in ftrace_process_regex()
5798 return p->func(tr, hash, func, command, next, enable); in ftrace_process_regex()
5824 /* iter->hash is a local copy, so we don't need regex_lock */ in ftrace_regex_write()
5856 __ftrace_match_addr(struct ftrace_hash *hash, unsigned long ip, int remove) in __ftrace_match_addr() argument
5865 entry = ftrace_lookup_ip(hash, ip); in __ftrace_match_addr()
5868 free_hash_entry(hash, entry); in __ftrace_match_addr()
5870 } else if (__ftrace_lookup_ip(hash, ip) != NULL) { in __ftrace_match_addr()
5875 entry = add_hash_entry(hash, ip); in __ftrace_match_addr()
5880 ftrace_match_addr(struct ftrace_hash *hash, unsigned long *ips, in ftrace_match_addr() argument
5887 err = __ftrace_match_addr(hash, ips[i], remove); in ftrace_match_addr()
5890 * This expects the @hash is a temporary hash and if this in ftrace_match_addr()
5891 * fails the caller must free the @hash. in ftrace_match_addr()
5905 struct ftrace_hash *hash; in ftrace_set_hash() local
5919 hash = alloc_ftrace_hash(FTRACE_HASH_DEFAULT_BITS); in ftrace_set_hash()
5921 hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, *orig_hash); in ftrace_set_hash()
5923 if (!hash) { in ftrace_set_hash()
5928 if (buf && !match_records(hash, buf, len, mod)) { in ftrace_set_hash()
5941 ret = ftrace_match_addr(hash, ips, cnt, remove); in ftrace_set_hash()
5947 ret = ftrace_hash_move_and_update_ops(ops, orig_hash, hash, enable); in ftrace_set_hash()
5953 free_ftrace_hash(hash); in ftrace_set_hash()
5989 static void remove_direct_functions_hash(struct ftrace_hash *hash, unsigned long addr) in remove_direct_functions_hash() argument
5994 size = 1 << hash->size_bits; in remove_direct_functions_hash()
5996 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in remove_direct_functions_hash()
6016 struct ftrace_hash *hash = ops->func_hash->filter_hash; in reset_direct() local
6018 remove_direct_functions_hash(hash, addr); in reset_direct()
6049 struct ftrace_hash *hash, *new_hash = NULL, *free_hash = NULL; in register_ftrace_direct() local
6060 hash = ops->func_hash->filter_hash; in register_ftrace_direct()
6061 if (ftrace_hash_empty(hash)) in register_ftrace_direct()
6067 size = 1 << hash->size_bits; in register_ftrace_direct()
6069 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in register_ftrace_direct()
6077 /* Make a copy hash to place the new and the old entries in */ in register_ftrace_direct()
6078 size = hash->count + direct_functions->count; in register_ftrace_direct()
6098 size = 1 << hash->size_bits; in register_ftrace_direct()
6100 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in register_ftrace_direct()
6104 /* Update both the copy and the hash entry */ in register_ftrace_direct()
6175 struct ftrace_hash *hash = ops->func_hash->filter_hash; in __modify_ftrace_direct() local
6200 err = __ftrace_hash_update_ipmodify(ops, hash, hash, true); in __modify_ftrace_direct()
6210 size = 1 << hash->size_bits; in __modify_ftrace_direct()
6212 hlist_for_each_entry(iter, &hash->buckets[i], hlist) { in __modify_ftrace_direct()
6291 static unsigned long hash_count(struct ftrace_hash *hash) in hash_count() argument
6293 return hash ? hash->count : 0; in hash_count()
6331 * callers provided in @hash
6333 * @hash: The address of the struct ftrace_hash object
6336 * specified in @hash. The @ops will be either registered or updated.
6339 * -EINVAL - The @hash is empty
6341 int update_ftrace_direct_add(struct ftrace_ops *ops, struct ftrace_hash *hash) in update_ftrace_direct_add() argument
6352 if (!hash_count(hash)) in update_ftrace_direct_add()
6358 size = 1 << hash->size_bits; in update_ftrace_direct_add()
6360 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in update_ftrace_direct_add()
6378 new_filter_hash = hash_add(old_filter_hash, hash); in update_ftrace_direct_add()
6382 new_direct_functions = hash_add(direct_functions, hash); in update_ftrace_direct_add()
6465 * callers provided in @hash
6467 * @hash: The address of the struct ftrace_hash object
6470 * @ops specified via @hash. The @ops will be either unregistered
6474 * -EINVAL - The @hash is empty
6477 int update_ftrace_direct_del(struct ftrace_ops *ops, struct ftrace_hash *hash) in update_ftrace_direct_del() argument
6488 if (!hash_count(hash)) in update_ftrace_direct_del()
6505 size = 1 << hash->size_bits; in update_ftrace_direct_del()
6507 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in update_ftrace_direct_del()
6515 new_filter_hash = hash_sub(old_filter_hash, hash); in update_ftrace_direct_del()
6519 new_direct_functions = hash_sub(direct_functions, hash); in update_ftrace_direct_del()
6562 * callers provided in @hash
6564 * @hash: The address of the struct ftrace_hash object
6568 * @ops specified via @hash.
6575 * -EINVAL - The @hash is empty
6578 int update_ftrace_direct_mod(struct ftrace_ops *ops, struct ftrace_hash *hash, bool do_direct_lock) in update_ftrace_direct_mod() argument
6589 if (!hash_count(hash)) in update_ftrace_direct_mod()
6609 /* Enable the tmp_ops to have the same functions as the hash object. */ in update_ftrace_direct_mod()
6611 tmp_ops.func_hash->filter_hash = hash; in update_ftrace_direct_mod()
6632 size = 1 << hash->size_bits; in update_ftrace_direct_mod()
6634 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in update_ftrace_direct_mod()
6860 static int ftrace_graph_set_hash(struct ftrace_hash *hash, char *buffer);
6888 struct ftrace_hash *hash; in set_ftrace_early_graph() local
6890 hash = alloc_ftrace_hash(FTRACE_HASH_DEFAULT_BITS); in set_ftrace_early_graph()
6891 if (MEM_FAIL(!hash, "Failed to allocate hash\n")) in set_ftrace_early_graph()
6897 ret = ftrace_graph_set_hash(hash, func); in set_ftrace_early_graph()
6904 ftrace_graph_hash = hash; in set_ftrace_early_graph()
6906 ftrace_graph_notrace_hash = hash; in set_ftrace_early_graph()
6978 iter->hash->flags &= ~FTRACE_HASH_FL_MOD; in ftrace_regex_release()
6980 iter->hash->flags |= FTRACE_HASH_FL_MOD; in ftrace_regex_release()
6987 iter->hash, filter_hash); in ftrace_regex_release()
6992 free_ftrace_hash(iter->hash); in ftrace_regex_release()
7059 struct ftrace_hash *hash; member
7061 int idx; /* for hash table iteration */
7076 if (*pos >= fgd->hash->count) in __g_next()
7088 for (i = idx; i < 1 << fgd->hash->size_bits; i++) { in __g_next()
7089 head = &fgd->hash->buckets[i]; in __g_next()
7113 fgd->hash = rcu_dereference_protected(ftrace_graph_hash, in g_start()
7116 fgd->hash = rcu_dereference_protected(ftrace_graph_notrace_hash, in g_start()
7120 if (ftrace_hash_empty(fgd->hash) && !*pos) in g_start()
7183 fgd->hash); in __ftrace_graph_open()
7210 * All uses of fgd->hash must be taken with the graph_lock in __ftrace_graph_open()
7212 * fgd->hash to be reinitialized when it is taken again. in __ftrace_graph_open()
7214 fgd->hash = NULL; in __ftrace_graph_open()
7234 fgd->hash = rcu_dereference_protected(ftrace_graph_hash, in ftrace_graph_open()
7262 fgd->hash = rcu_dereference_protected(ftrace_graph_notrace_hash, in ftrace_graph_notrace_open()
7346 ftrace_graph_set_hash(struct ftrace_hash *hash, char *buffer) in ftrace_graph_set_hash() argument
7372 entry = ftrace_lookup_ip(hash, rec->ip); in ftrace_graph_set_hash()
7379 if (add_hash_entry(hash, rec->ip) == NULL) in ftrace_graph_set_hash()
7383 free_hash_entry(hash, entry); in ftrace_graph_set_hash()
7770 /* If in notrace hash, we ignore it too */ in ops_references_ip()
7809 clear_mod_from_hash(struct ftrace_page *pg, struct ftrace_hash *hash) in clear_mod_from_hash() argument
7815 if (ftrace_hash_empty(hash)) in clear_mod_from_hash()
7820 entry = __ftrace_lookup_ip(hash, rec->ip); in clear_mod_from_hash()
7824 * if/when the hash is modified again. in clear_mod_from_hash()
8210 clear_func_from_hash(struct ftrace_init_func *func, struct ftrace_hash *hash) in clear_func_from_hash() argument
8214 entry = ftrace_lookup_ip(hash, func->ip); in clear_func_from_hash()
8218 * if/when the hash is modified again. in clear_func_from_hash()
9048 struct ftrace_hash *hash; in prepare_direct_functions_for_ipmodify() local
9057 hash = ops->func_hash->filter_hash; in prepare_direct_functions_for_ipmodify()
9058 size = 1 << hash->size_bits; in prepare_direct_functions_for_ipmodify()
9060 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in prepare_direct_functions_for_ipmodify()
9097 struct ftrace_hash *hash; in cleanup_direct_functions_after_ipmodify() local
9106 hash = ops->func_hash->filter_hash; in cleanup_direct_functions_after_ipmodify()
9107 size = 1 << hash->size_bits; in cleanup_direct_functions_after_ipmodify()
9109 hlist_for_each_entry(entry, &hash->buckets[i], hlist) { in cleanup_direct_functions_after_ipmodify()