tracing: Add ftrace_hash_key() helper function
Replace the couple of use cases that has small logic to produce the ftrace function key id with a helper function. No need for duplicate code. Acked-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
parent
b9b0c831be
commit
2b0cce0e19
|
@ -1185,6 +1185,15 @@ struct ftrace_page {
|
||||||
static struct ftrace_page *ftrace_pages_start;
|
static struct ftrace_page *ftrace_pages_start;
|
||||||
static struct ftrace_page *ftrace_pages;
|
static struct ftrace_page *ftrace_pages;
|
||||||
|
|
||||||
|
static __always_inline unsigned long
|
||||||
|
ftrace_hash_key(struct ftrace_hash *hash, unsigned long ip)
|
||||||
|
{
|
||||||
|
if (hash->size_bits > 0)
|
||||||
|
return hash_long(ip, hash->size_bits);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct ftrace_func_entry *
|
struct ftrace_func_entry *
|
||||||
ftrace_lookup_ip(struct ftrace_hash *hash, unsigned long ip)
|
ftrace_lookup_ip(struct ftrace_hash *hash, unsigned long ip)
|
||||||
{
|
{
|
||||||
|
@ -1195,11 +1204,7 @@ ftrace_lookup_ip(struct ftrace_hash *hash, unsigned long ip)
|
||||||
if (ftrace_hash_empty(hash))
|
if (ftrace_hash_empty(hash))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (hash->size_bits > 0)
|
key = ftrace_hash_key(hash, ip);
|
||||||
key = hash_long(ip, hash->size_bits);
|
|
||||||
else
|
|
||||||
key = 0;
|
|
||||||
|
|
||||||
hhd = &hash->buckets[key];
|
hhd = &hash->buckets[key];
|
||||||
|
|
||||||
hlist_for_each_entry_rcu_notrace(entry, hhd, hlist) {
|
hlist_for_each_entry_rcu_notrace(entry, hhd, hlist) {
|
||||||
|
@ -1215,11 +1220,7 @@ static void __add_hash_entry(struct ftrace_hash *hash,
|
||||||
struct hlist_head *hhd;
|
struct hlist_head *hhd;
|
||||||
unsigned long key;
|
unsigned long key;
|
||||||
|
|
||||||
if (hash->size_bits)
|
key = ftrace_hash_key(hash, entry->ip);
|
||||||
key = hash_long(entry->ip, hash->size_bits);
|
|
||||||
else
|
|
||||||
key = 0;
|
|
||||||
|
|
||||||
hhd = &hash->buckets[key];
|
hhd = &hash->buckets[key];
|
||||||
hlist_add_head(&entry->hlist, hhd);
|
hlist_add_head(&entry->hlist, hhd);
|
||||||
hash->count++;
|
hash->count++;
|
||||||
|
|
Loading…
Reference in New Issue