6565#define FL_GLOBAL_CONTROL_MASK (FTRACE_OPS_FL_CONTROL)
6666
6767#ifdef CONFIG_DYNAMIC_FTRACE
68- #define INIT_REGEX_LOCK (opsname ) \
69- .regex_lock = __MUTEX_INITIALIZER(opsname.regex_lock),
68+ #define INIT_OPS_HASH (opsname ) \
69+ .func_hash = &opsname.local_hash, \
70+ .local_hash.regex_lock = __MUTEX_INITIALIZER(opsname.local_hash.regex_lock),
7071#else
71- #define INIT_REGEX_LOCK (opsname )
72+ #define INIT_OPS_HASH (opsname )
7273#endif
7374
7475static struct ftrace_ops ftrace_list_end __read_mostly = {
7576 .func = ftrace_stub ,
7677 .flags = FTRACE_OPS_FL_RECURSION_SAFE | FTRACE_OPS_FL_STUB ,
78+ INIT_OPS_HASH (ftrace_list_end )
7779};
7880
7981/* ftrace_enabled is a method to turn ftrace on or off */
@@ -143,7 +145,8 @@ static inline void ftrace_ops_init(struct ftrace_ops *ops)
143145{
144146#ifdef CONFIG_DYNAMIC_FTRACE
145147 if (!(ops -> flags & FTRACE_OPS_FL_INITIALIZED )) {
146- mutex_init (& ops -> regex_lock );
148+ mutex_init (& ops -> local_hash .regex_lock );
149+ ops -> func_hash = & ops -> local_hash ;
147150 ops -> flags |= FTRACE_OPS_FL_INITIALIZED ;
148151 }
149152#endif
@@ -902,7 +905,7 @@ static void unregister_ftrace_profiler(void)
902905static struct ftrace_ops ftrace_profile_ops __read_mostly = {
903906 .func = function_profile_call ,
904907 .flags = FTRACE_OPS_FL_RECURSION_SAFE | FTRACE_OPS_FL_INITIALIZED ,
905- INIT_REGEX_LOCK (ftrace_profile_ops )
908+ INIT_OPS_HASH (ftrace_profile_ops )
906909};
907910
908911static int register_ftrace_profiler (void )
@@ -1082,11 +1085,12 @@ static const struct ftrace_hash empty_hash = {
10821085#define EMPTY_HASH ((struct ftrace_hash *)&empty_hash)
10831086
10841087static struct ftrace_ops global_ops = {
1085- .func = ftrace_stub ,
1086- .notrace_hash = EMPTY_HASH ,
1087- .filter_hash = EMPTY_HASH ,
1088- .flags = FTRACE_OPS_FL_RECURSION_SAFE | FTRACE_OPS_FL_INITIALIZED ,
1089- INIT_REGEX_LOCK (global_ops )
1088+ .func = ftrace_stub ,
1089+ .local_hash .notrace_hash = EMPTY_HASH ,
1090+ .local_hash .filter_hash = EMPTY_HASH ,
1091+ INIT_OPS_HASH (global_ops )
1092+ .flags = FTRACE_OPS_FL_RECURSION_SAFE |
1093+ FTRACE_OPS_FL_INITIALIZED ,
10901094};
10911095
10921096struct ftrace_page {
@@ -1227,8 +1231,8 @@ static void free_ftrace_hash_rcu(struct ftrace_hash *hash)
12271231void ftrace_free_filter (struct ftrace_ops * ops )
12281232{
12291233 ftrace_ops_init (ops );
1230- free_ftrace_hash (ops -> filter_hash );
1231- free_ftrace_hash (ops -> notrace_hash );
1234+ free_ftrace_hash (ops -> func_hash -> filter_hash );
1235+ free_ftrace_hash (ops -> func_hash -> notrace_hash );
12321236}
12331237
12341238static struct ftrace_hash * alloc_ftrace_hash (int size_bits )
@@ -1394,8 +1398,8 @@ ftrace_ops_test(struct ftrace_ops *ops, unsigned long ip, void *regs)
13941398 return 0 ;
13951399#endif
13961400
1397- filter_hash = rcu_dereference_raw_notrace (ops -> filter_hash );
1398- notrace_hash = rcu_dereference_raw_notrace (ops -> notrace_hash );
1401+ filter_hash = rcu_dereference_raw_notrace (ops -> func_hash -> filter_hash );
1402+ notrace_hash = rcu_dereference_raw_notrace (ops -> func_hash -> notrace_hash );
13991403
14001404 if ((ftrace_hash_empty (filter_hash ) ||
14011405 ftrace_lookup_ip (filter_hash , ip )) &&
@@ -1519,14 +1523,14 @@ static void __ftrace_hash_rec_update(struct ftrace_ops *ops,
15191523 * gets inversed.
15201524 */
15211525 if (filter_hash ) {
1522- hash = ops -> filter_hash ;
1523- other_hash = ops -> notrace_hash ;
1526+ hash = ops -> func_hash -> filter_hash ;
1527+ other_hash = ops -> func_hash -> notrace_hash ;
15241528 if (ftrace_hash_empty (hash ))
15251529 all = 1 ;
15261530 } else {
15271531 inc = !inc ;
1528- hash = ops -> notrace_hash ;
1529- other_hash = ops -> filter_hash ;
1532+ hash = ops -> func_hash -> notrace_hash ;
1533+ other_hash = ops -> func_hash -> filter_hash ;
15301534 /*
15311535 * If the notrace hash has no items,
15321536 * then there's nothing to do.
@@ -2196,8 +2200,8 @@ static inline int ops_traces_mod(struct ftrace_ops *ops)
21962200 * Filter_hash being empty will default to trace module.
21972201 * But notrace hash requires a test of individual module functions.
21982202 */
2199- return ftrace_hash_empty (ops -> filter_hash ) &&
2200- ftrace_hash_empty (ops -> notrace_hash );
2203+ return ftrace_hash_empty (ops -> func_hash -> filter_hash ) &&
2204+ ftrace_hash_empty (ops -> func_hash -> notrace_hash );
22012205}
22022206
22032207/*
@@ -2219,12 +2223,12 @@ ops_references_rec(struct ftrace_ops *ops, struct dyn_ftrace *rec)
22192223 return 0 ;
22202224
22212225 /* The function must be in the filter */
2222- if (!ftrace_hash_empty (ops -> filter_hash ) &&
2223- !ftrace_lookup_ip (ops -> filter_hash , rec -> ip ))
2226+ if (!ftrace_hash_empty (ops -> func_hash -> filter_hash ) &&
2227+ !ftrace_lookup_ip (ops -> func_hash -> filter_hash , rec -> ip ))
22242228 return 0 ;
22252229
22262230 /* If in notrace hash, we ignore it too */
2227- if (ftrace_lookup_ip (ops -> notrace_hash , rec -> ip ))
2231+ if (ftrace_lookup_ip (ops -> func_hash -> notrace_hash , rec -> ip ))
22282232 return 0 ;
22292233
22302234 return 1 ;
@@ -2544,10 +2548,10 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
25442548 } else {
25452549 rec = & iter -> pg -> records [iter -> idx ++ ];
25462550 if (((iter -> flags & FTRACE_ITER_FILTER ) &&
2547- !(ftrace_lookup_ip (ops -> filter_hash , rec -> ip ))) ||
2551+ !(ftrace_lookup_ip (ops -> func_hash -> filter_hash , rec -> ip ))) ||
25482552
25492553 ((iter -> flags & FTRACE_ITER_NOTRACE ) &&
2550- !ftrace_lookup_ip (ops -> notrace_hash , rec -> ip )) ||
2554+ !ftrace_lookup_ip (ops -> func_hash -> notrace_hash , rec -> ip )) ||
25512555
25522556 ((iter -> flags & FTRACE_ITER_ENABLED ) &&
25532557 !(rec -> flags & FTRACE_FL_ENABLED ))) {
@@ -2596,7 +2600,7 @@ static void *t_start(struct seq_file *m, loff_t *pos)
25962600 * functions are enabled.
25972601 */
25982602 if (iter -> flags & FTRACE_ITER_FILTER &&
2599- ftrace_hash_empty (ops -> filter_hash )) {
2603+ ftrace_hash_empty (ops -> func_hash -> filter_hash )) {
26002604 if (* pos > 0 )
26012605 return t_hash_start (m , pos );
26022606 iter -> flags |= FTRACE_ITER_PRINTALL ;
@@ -2750,12 +2754,12 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag,
27502754 iter -> ops = ops ;
27512755 iter -> flags = flag ;
27522756
2753- mutex_lock (& ops -> regex_lock );
2757+ mutex_lock (& ops -> func_hash -> regex_lock );
27542758
27552759 if (flag & FTRACE_ITER_NOTRACE )
2756- hash = ops -> notrace_hash ;
2760+ hash = ops -> func_hash -> notrace_hash ;
27572761 else
2758- hash = ops -> filter_hash ;
2762+ hash = ops -> func_hash -> filter_hash ;
27592763
27602764 if (file -> f_mode & FMODE_WRITE ) {
27612765 iter -> hash = alloc_and_copy_ftrace_hash (FTRACE_HASH_DEFAULT_BITS , hash );
@@ -2788,7 +2792,7 @@ ftrace_regex_open(struct ftrace_ops *ops, int flag,
27882792 file -> private_data = iter ;
27892793
27902794 out_unlock :
2791- mutex_unlock (& ops -> regex_lock );
2795+ mutex_unlock (& ops -> func_hash -> regex_lock );
27922796
27932797 return ret ;
27942798}
@@ -3026,7 +3030,7 @@ static struct ftrace_ops trace_probe_ops __read_mostly =
30263030{
30273031 .func = function_trace_probe_call ,
30283032 .flags = FTRACE_OPS_FL_INITIALIZED ,
3029- INIT_REGEX_LOCK (trace_probe_ops )
3033+ INIT_OPS_HASH (trace_probe_ops )
30303034};
30313035
30323036static int ftrace_probe_registered ;
@@ -3089,7 +3093,7 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
30893093 void * data )
30903094{
30913095 struct ftrace_func_probe * entry ;
3092- struct ftrace_hash * * orig_hash = & trace_probe_ops .filter_hash ;
3096+ struct ftrace_hash * * orig_hash = & trace_probe_ops .func_hash -> filter_hash ;
30933097 struct ftrace_hash * hash ;
30943098 struct ftrace_page * pg ;
30953099 struct dyn_ftrace * rec ;
@@ -3106,7 +3110,7 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
31063110 if (WARN_ON (not ))
31073111 return - EINVAL ;
31083112
3109- mutex_lock (& trace_probe_ops .regex_lock );
3113+ mutex_lock (& trace_probe_ops .func_hash -> regex_lock );
31103114
31113115 hash = alloc_and_copy_ftrace_hash (FTRACE_HASH_DEFAULT_BITS , * orig_hash );
31123116 if (!hash ) {
@@ -3175,7 +3179,7 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
31753179 out_unlock :
31763180 mutex_unlock (& ftrace_lock );
31773181 out :
3178- mutex_unlock (& trace_probe_ops .regex_lock );
3182+ mutex_unlock (& trace_probe_ops .func_hash -> regex_lock );
31793183 free_ftrace_hash (hash );
31803184
31813185 return count ;
@@ -3193,7 +3197,7 @@ __unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
31933197 struct ftrace_func_entry * rec_entry ;
31943198 struct ftrace_func_probe * entry ;
31953199 struct ftrace_func_probe * p ;
3196- struct ftrace_hash * * orig_hash = & trace_probe_ops .filter_hash ;
3200+ struct ftrace_hash * * orig_hash = & trace_probe_ops .func_hash -> filter_hash ;
31973201 struct list_head free_list ;
31983202 struct ftrace_hash * hash ;
31993203 struct hlist_node * tmp ;
@@ -3215,7 +3219,7 @@ __unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
32153219 return ;
32163220 }
32173221
3218- mutex_lock (& trace_probe_ops .regex_lock );
3222+ mutex_lock (& trace_probe_ops .func_hash -> regex_lock );
32193223
32203224 hash = alloc_and_copy_ftrace_hash (FTRACE_HASH_DEFAULT_BITS , * orig_hash );
32213225 if (!hash )
@@ -3268,7 +3272,7 @@ __unregister_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
32683272 mutex_unlock (& ftrace_lock );
32693273
32703274 out_unlock :
3271- mutex_unlock (& trace_probe_ops .regex_lock );
3275+ mutex_unlock (& trace_probe_ops .func_hash -> regex_lock );
32723276 free_ftrace_hash (hash );
32733277}
32743278
@@ -3464,12 +3468,12 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
34643468 if (unlikely (ftrace_disabled ))
34653469 return - ENODEV ;
34663470
3467- mutex_lock (& ops -> regex_lock );
3471+ mutex_lock (& ops -> func_hash -> regex_lock );
34683472
34693473 if (enable )
3470- orig_hash = & ops -> filter_hash ;
3474+ orig_hash = & ops -> func_hash -> filter_hash ;
34713475 else
3472- orig_hash = & ops -> notrace_hash ;
3476+ orig_hash = & ops -> func_hash -> notrace_hash ;
34733477
34743478 hash = alloc_and_copy_ftrace_hash (FTRACE_HASH_DEFAULT_BITS , * orig_hash );
34753479 if (!hash ) {
@@ -3497,7 +3501,7 @@ ftrace_set_hash(struct ftrace_ops *ops, unsigned char *buf, int len,
34973501 mutex_unlock (& ftrace_lock );
34983502
34993503 out_regex_unlock :
3500- mutex_unlock (& ops -> regex_lock );
3504+ mutex_unlock (& ops -> func_hash -> regex_lock );
35013505
35023506 free_ftrace_hash (hash );
35033507 return ret ;
@@ -3704,15 +3708,15 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
37043708
37053709 trace_parser_put (parser );
37063710
3707- mutex_lock (& iter -> ops -> regex_lock );
3711+ mutex_lock (& iter -> ops -> func_hash -> regex_lock );
37083712
37093713 if (file -> f_mode & FMODE_WRITE ) {
37103714 filter_hash = !!(iter -> flags & FTRACE_ITER_FILTER );
37113715
37123716 if (filter_hash )
3713- orig_hash = & iter -> ops -> filter_hash ;
3717+ orig_hash = & iter -> ops -> func_hash -> filter_hash ;
37143718 else
3715- orig_hash = & iter -> ops -> notrace_hash ;
3719+ orig_hash = & iter -> ops -> func_hash -> notrace_hash ;
37163720
37173721 mutex_lock (& ftrace_lock );
37183722 ret = ftrace_hash_move (iter -> ops , filter_hash ,
@@ -3723,7 +3727,7 @@ int ftrace_regex_release(struct inode *inode, struct file *file)
37233727 mutex_unlock (& ftrace_lock );
37243728 }
37253729
3726- mutex_unlock (& iter -> ops -> regex_lock );
3730+ mutex_unlock (& iter -> ops -> func_hash -> regex_lock );
37273731 free_ftrace_hash (iter -> hash );
37283732 kfree (iter );
37293733
@@ -4335,7 +4339,7 @@ void __init ftrace_init(void)
43354339static struct ftrace_ops global_ops = {
43364340 .func = ftrace_stub ,
43374341 .flags = FTRACE_OPS_FL_RECURSION_SAFE | FTRACE_OPS_FL_INITIALIZED ,
4338- INIT_REGEX_LOCK (global_ops )
4342+ INIT_OPS_HASH (global_ops )
43394343};
43404344
43414345static int __init ftrace_nodyn_init (void )
@@ -4437,7 +4441,7 @@ ftrace_ops_control_func(unsigned long ip, unsigned long parent_ip,
44374441static struct ftrace_ops control_ops = {
44384442 .func = ftrace_ops_control_func ,
44394443 .flags = FTRACE_OPS_FL_RECURSION_SAFE | FTRACE_OPS_FL_INITIALIZED ,
4440- INIT_REGEX_LOCK (control_ops )
4444+ INIT_OPS_HASH (control_ops )
44414445};
44424446
44434447static inline void
0 commit comments