|
@@ -255,9 +255,9 @@ static struct pid * const ftrace_swapper_pid = &init_struct_pid;
|
|
|
|
|
|
static struct hlist_head ftrace_func_hash[FTRACE_FUNC_HASHSIZE] __read_mostly;
|
|
static struct hlist_head ftrace_func_hash[FTRACE_FUNC_HASHSIZE] __read_mostly;
|
|
|
|
|
|
-struct ftrace_func_hook {
|
|
|
|
|
|
+struct ftrace_func_probe {
|
|
struct hlist_node node;
|
|
struct hlist_node node;
|
|
- struct ftrace_hook_ops *ops;
|
|
|
|
|
|
+ struct ftrace_probe_ops *ops;
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
unsigned long ip;
|
|
unsigned long ip;
|
|
void *data;
|
|
void *data;
|
|
@@ -830,11 +830,11 @@ static void *t_hash_start(struct seq_file *m, loff_t *pos)
|
|
|
|
|
|
static int t_hash_show(struct seq_file *m, void *v)
|
|
static int t_hash_show(struct seq_file *m, void *v)
|
|
{
|
|
{
|
|
- struct ftrace_func_hook *rec;
|
|
|
|
|
|
+ struct ftrace_func_probe *rec;
|
|
struct hlist_node *hnd = v;
|
|
struct hlist_node *hnd = v;
|
|
char str[KSYM_SYMBOL_LEN];
|
|
char str[KSYM_SYMBOL_LEN];
|
|
|
|
|
|
- rec = hlist_entry(hnd, struct ftrace_func_hook, node);
|
|
|
|
|
|
+ rec = hlist_entry(hnd, struct ftrace_func_probe, node);
|
|
|
|
|
|
if (rec->ops->print)
|
|
if (rec->ops->print)
|
|
return rec->ops->print(m, rec->ip, rec->ops, rec->data);
|
|
return rec->ops->print(m, rec->ip, rec->ops, rec->data);
|
|
@@ -1351,9 +1351,9 @@ static int __init ftrace_mod_cmd_init(void)
|
|
device_initcall(ftrace_mod_cmd_init);
|
|
device_initcall(ftrace_mod_cmd_init);
|
|
|
|
|
|
static void
|
|
static void
|
|
-function_trace_hook_call(unsigned long ip, unsigned long parent_ip)
|
|
|
|
|
|
+function_trace_probe_call(unsigned long ip, unsigned long parent_ip)
|
|
{
|
|
{
|
|
- struct ftrace_func_hook *entry;
|
|
|
|
|
|
+ struct ftrace_func_probe *entry;
|
|
struct hlist_head *hhd;
|
|
struct hlist_head *hhd;
|
|
struct hlist_node *n;
|
|
struct hlist_node *n;
|
|
unsigned long key;
|
|
unsigned long key;
|
|
@@ -1379,18 +1379,18 @@ function_trace_hook_call(unsigned long ip, unsigned long parent_ip)
|
|
ftrace_preempt_enable(resched);
|
|
ftrace_preempt_enable(resched);
|
|
}
|
|
}
|
|
|
|
|
|
-static struct ftrace_ops trace_hook_ops __read_mostly =
|
|
|
|
|
|
+static struct ftrace_ops trace_probe_ops __read_mostly =
|
|
{
|
|
{
|
|
- .func = function_trace_hook_call,
|
|
|
|
|
|
+ .func = function_trace_probe_call,
|
|
};
|
|
};
|
|
|
|
|
|
-static int ftrace_hook_registered;
|
|
|
|
|
|
+static int ftrace_probe_registered;
|
|
|
|
|
|
-static void __enable_ftrace_function_hook(void)
|
|
|
|
|
|
+static void __enable_ftrace_function_probe(void)
|
|
{
|
|
{
|
|
int i;
|
|
int i;
|
|
|
|
|
|
- if (ftrace_hook_registered)
|
|
|
|
|
|
+ if (ftrace_probe_registered)
|
|
return;
|
|
return;
|
|
|
|
|
|
for (i = 0; i < FTRACE_FUNC_HASHSIZE; i++) {
|
|
for (i = 0; i < FTRACE_FUNC_HASHSIZE; i++) {
|
|
@@ -1402,16 +1402,16 @@ static void __enable_ftrace_function_hook(void)
|
|
if (i == FTRACE_FUNC_HASHSIZE)
|
|
if (i == FTRACE_FUNC_HASHSIZE)
|
|
return;
|
|
return;
|
|
|
|
|
|
- __register_ftrace_function(&trace_hook_ops);
|
|
|
|
|
|
+ __register_ftrace_function(&trace_probe_ops);
|
|
ftrace_startup(0);
|
|
ftrace_startup(0);
|
|
- ftrace_hook_registered = 1;
|
|
|
|
|
|
+ ftrace_probe_registered = 1;
|
|
}
|
|
}
|
|
|
|
|
|
-static void __disable_ftrace_function_hook(void)
|
|
|
|
|
|
+static void __disable_ftrace_function_probe(void)
|
|
{
|
|
{
|
|
int i;
|
|
int i;
|
|
|
|
|
|
- if (!ftrace_hook_registered)
|
|
|
|
|
|
+ if (!ftrace_probe_registered)
|
|
return;
|
|
return;
|
|
|
|
|
|
for (i = 0; i < FTRACE_FUNC_HASHSIZE; i++) {
|
|
for (i = 0; i < FTRACE_FUNC_HASHSIZE; i++) {
|
|
@@ -1421,16 +1421,16 @@ static void __disable_ftrace_function_hook(void)
|
|
}
|
|
}
|
|
|
|
|
|
/* no more funcs left */
|
|
/* no more funcs left */
|
|
- __unregister_ftrace_function(&trace_hook_ops);
|
|
|
|
|
|
+ __unregister_ftrace_function(&trace_probe_ops);
|
|
ftrace_shutdown(0);
|
|
ftrace_shutdown(0);
|
|
- ftrace_hook_registered = 0;
|
|
|
|
|
|
+ ftrace_probe_registered = 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ftrace_free_entry_rcu(struct rcu_head *rhp)
|
|
static void ftrace_free_entry_rcu(struct rcu_head *rhp)
|
|
{
|
|
{
|
|
- struct ftrace_func_hook *entry =
|
|
|
|
- container_of(rhp, struct ftrace_func_hook, rcu);
|
|
|
|
|
|
+ struct ftrace_func_probe *entry =
|
|
|
|
+ container_of(rhp, struct ftrace_func_probe, rcu);
|
|
|
|
|
|
if (entry->ops->free)
|
|
if (entry->ops->free)
|
|
entry->ops->free(&entry->data);
|
|
entry->ops->free(&entry->data);
|
|
@@ -1439,10 +1439,10 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
|
|
|
|
|
|
|
|
|
|
int
|
|
int
|
|
-register_ftrace_function_hook(char *glob, struct ftrace_hook_ops *ops,
|
|
|
|
|
|
+register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
|
|
void *data)
|
|
void *data)
|
|
{
|
|
{
|
|
- struct ftrace_func_hook *entry;
|
|
|
|
|
|
+ struct ftrace_func_probe *entry;
|
|
struct ftrace_page *pg;
|
|
struct ftrace_page *pg;
|
|
struct dyn_ftrace *rec;
|
|
struct dyn_ftrace *rec;
|
|
int type, len, not;
|
|
int type, len, not;
|
|
@@ -1453,7 +1453,7 @@ register_ftrace_function_hook(char *glob, struct ftrace_hook_ops *ops,
|
|
type = ftrace_setup_glob(glob, strlen(glob), &search, ¬);
|
|
type = ftrace_setup_glob(glob, strlen(glob), &search, ¬);
|
|
len = strlen(search);
|
|
len = strlen(search);
|
|
|
|
|
|
- /* we do not support '!' for function hooks */
|
|
|
|
|
|
+ /* we do not support '!' for function probes */
|
|
if (WARN_ON(not))
|
|
if (WARN_ON(not))
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|
|
@@ -1468,7 +1468,7 @@ register_ftrace_function_hook(char *glob, struct ftrace_hook_ops *ops,
|
|
|
|
|
|
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
|
|
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
|
|
if (!entry) {
|
|
if (!entry) {
|
|
- /* If we did not hook to any, then return error */
|
|
|
|
|
|
+ /* If we did not process any, then return error */
|
|
if (!count)
|
|
if (!count)
|
|
count = -ENOMEM;
|
|
count = -ENOMEM;
|
|
goto out_unlock;
|
|
goto out_unlock;
|
|
@@ -1498,7 +1498,7 @@ register_ftrace_function_hook(char *glob, struct ftrace_hook_ops *ops,
|
|
hlist_add_head_rcu(&entry->node, &ftrace_func_hash[key]);
|
|
hlist_add_head_rcu(&entry->node, &ftrace_func_hash[key]);
|
|
|
|
|
|
} while_for_each_ftrace_rec();
|
|
} while_for_each_ftrace_rec();
|
|
- __enable_ftrace_function_hook();
|
|
|
|
|
|
+ __enable_ftrace_function_probe();
|
|
|
|
|
|
out_unlock:
|
|
out_unlock:
|
|
mutex_unlock(&ftrace_lock);
|
|
mutex_unlock(&ftrace_lock);
|
|
@@ -1507,15 +1507,15 @@ register_ftrace_function_hook(char *glob, struct ftrace_hook_ops *ops,
|
|
}
|
|
}
|
|
|
|
|
|
enum {
|
|
enum {
|
|
- HOOK_TEST_FUNC = 1,
|
|
|
|
- HOOK_TEST_DATA = 2
|
|
|
|
|
|
+ PROBE_TEST_FUNC = 1,
|
|
|
|
+ PROBE_TEST_DATA = 2
|
|
};
|
|
};
|
|
|
|
|
|
static void
|
|
static void
|
|
-__unregister_ftrace_function_hook(char *glob, struct ftrace_hook_ops *ops,
|
|
|
|
|
|
+__unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
|
|
void *data, int flags)
|
|
void *data, int flags)
|
|
{
|
|
{
|
|
- struct ftrace_func_hook *entry;
|
|
|
|
|
|
+ struct ftrace_func_probe *entry;
|
|
struct hlist_node *n, *tmp;
|
|
struct hlist_node *n, *tmp;
|
|
char str[KSYM_SYMBOL_LEN];
|
|
char str[KSYM_SYMBOL_LEN];
|
|
int type = MATCH_FULL;
|
|
int type = MATCH_FULL;
|
|
@@ -1530,7 +1530,7 @@ __unregister_ftrace_function_hook(char *glob, struct ftrace_hook_ops *ops,
|
|
type = ftrace_setup_glob(glob, strlen(glob), &search, ¬);
|
|
type = ftrace_setup_glob(glob, strlen(glob), &search, ¬);
|
|
len = strlen(search);
|
|
len = strlen(search);
|
|
|
|
|
|
- /* we do not support '!' for function hooks */
|
|
|
|
|
|
+ /* we do not support '!' for function probes */
|
|
if (WARN_ON(not))
|
|
if (WARN_ON(not))
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -1542,10 +1542,10 @@ __unregister_ftrace_function_hook(char *glob, struct ftrace_hook_ops *ops,
|
|
hlist_for_each_entry_safe(entry, n, tmp, hhd, node) {
|
|
hlist_for_each_entry_safe(entry, n, tmp, hhd, node) {
|
|
|
|
|
|
/* break up if statements for readability */
|
|
/* break up if statements for readability */
|
|
- if ((flags & HOOK_TEST_FUNC) && entry->ops != ops)
|
|
|
|
|
|
+ if ((flags & PROBE_TEST_FUNC) && entry->ops != ops)
|
|
continue;
|
|
continue;
|
|
|
|
|
|
- if ((flags & HOOK_TEST_DATA) && entry->data != data)
|
|
|
|
|
|
+ if ((flags & PROBE_TEST_DATA) && entry->data != data)
|
|
continue;
|
|
continue;
|
|
|
|
|
|
/* do this last, since it is the most expensive */
|
|
/* do this last, since it is the most expensive */
|
|
@@ -1560,27 +1560,27 @@ __unregister_ftrace_function_hook(char *glob, struct ftrace_hook_ops *ops,
|
|
call_rcu(&entry->rcu, ftrace_free_entry_rcu);
|
|
call_rcu(&entry->rcu, ftrace_free_entry_rcu);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- __disable_ftrace_function_hook();
|
|
|
|
|
|
+ __disable_ftrace_function_probe();
|
|
mutex_unlock(&ftrace_lock);
|
|
mutex_unlock(&ftrace_lock);
|
|
}
|
|
}
|
|
|
|
|
|
void
|
|
void
|
|
-unregister_ftrace_function_hook(char *glob, struct ftrace_hook_ops *ops,
|
|
|
|
|
|
+unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
|
|
void *data)
|
|
void *data)
|
|
{
|
|
{
|
|
- __unregister_ftrace_function_hook(glob, ops, data,
|
|
|
|
- HOOK_TEST_FUNC | HOOK_TEST_DATA);
|
|
|
|
|
|
+ __unregister_ftrace_function_probe(glob, ops, data,
|
|
|
|
+ PROBE_TEST_FUNC | PROBE_TEST_DATA);
|
|
}
|
|
}
|
|
|
|
|
|
void
|
|
void
|
|
-unregister_ftrace_function_hook_func(char *glob, struct ftrace_hook_ops *ops)
|
|
|
|
|
|
+unregister_ftrace_function_probe_func(char *glob, struct ftrace_probe_ops *ops)
|
|
{
|
|
{
|
|
- __unregister_ftrace_function_hook(glob, ops, NULL, HOOK_TEST_FUNC);
|
|
|
|
|
|
+ __unregister_ftrace_function_probe(glob, ops, NULL, PROBE_TEST_FUNC);
|
|
}
|
|
}
|
|
|
|
|
|
-void unregister_ftrace_function_hook_all(char *glob)
|
|
|
|
|
|
+void unregister_ftrace_function_probe_all(char *glob)
|
|
{
|
|
{
|
|
- __unregister_ftrace_function_hook(glob, NULL, NULL, 0);
|
|
|
|
|
|
+ __unregister_ftrace_function_probe(glob, NULL, NULL, 0);
|
|
}
|
|
}
|
|
|
|
|
|
static LIST_HEAD(ftrace_commands);
|
|
static LIST_HEAD(ftrace_commands);
|