@@ -62,8 +62,6 @@ int function_trace_stop;
62
62
static int ftrace_disabled __read_mostly ;
63
63
64
64
static DEFINE_MUTEX (ftrace_lock );
65
- static DEFINE_MUTEX (ftrace_sysctl_lock );
66
- static DEFINE_MUTEX (ftrace_start_lock );
67
65
68
66
static struct ftrace_ops ftrace_list_end __read_mostly =
69
67
{
@@ -134,8 +132,6 @@ static void ftrace_test_stop_func(unsigned long ip, unsigned long parent_ip)
134
132
135
133
static int __register_ftrace_function (struct ftrace_ops * ops )
136
134
{
137
- mutex_lock (& ftrace_lock );
138
-
139
135
ops -> next = ftrace_list ;
140
136
/*
141
137
* We are entering ops into the ftrace_list but another
@@ -171,17 +167,12 @@ static int __register_ftrace_function(struct ftrace_ops *ops)
171
167
#endif
172
168
}
173
169
174
- mutex_unlock (& ftrace_lock );
175
-
176
170
return 0 ;
177
171
}
178
172
179
173
static int __unregister_ftrace_function (struct ftrace_ops * ops )
180
174
{
181
175
struct ftrace_ops * * p ;
182
- int ret = 0 ;
183
-
184
- mutex_lock (& ftrace_lock );
185
176
186
177
/*
187
178
* If we are removing the last function, then simply point
@@ -190,17 +181,15 @@ static int __unregister_ftrace_function(struct ftrace_ops *ops)
190
181
if (ftrace_list == ops && ops -> next == & ftrace_list_end ) {
191
182
ftrace_trace_function = ftrace_stub ;
192
183
ftrace_list = & ftrace_list_end ;
193
- goto out ;
184
+ return 0 ;
194
185
}
195
186
196
187
for (p = & ftrace_list ; * p != & ftrace_list_end ; p = & (* p )-> next )
197
188
if (* p == ops )
198
189
break ;
199
190
200
- if (* p != ops ) {
201
- ret = -1 ;
202
- goto out ;
203
- }
191
+ if (* p != ops )
192
+ return -1 ;
204
193
205
194
* p = (* p )-> next ;
206
195
@@ -221,10 +210,7 @@ static int __unregister_ftrace_function(struct ftrace_ops *ops)
221
210
}
222
211
}
223
212
224
- out :
225
- mutex_unlock (& ftrace_lock );
226
-
227
- return ret ;
213
+ return 0 ;
228
214
}
229
215
230
216
static void ftrace_update_pid_func (void )
@@ -622,21 +608,17 @@ static void ftrace_startup(int command)
622
608
if (unlikely (ftrace_disabled ))
623
609
return ;
624
610
625
- mutex_lock (& ftrace_start_lock );
626
611
ftrace_start_up ++ ;
627
612
command |= FTRACE_ENABLE_CALLS ;
628
613
629
614
ftrace_startup_enable (command );
630
-
631
- mutex_unlock (& ftrace_start_lock );
632
615
}
633
616
634
617
static void ftrace_shutdown (int command )
635
618
{
636
619
if (unlikely (ftrace_disabled ))
637
620
return ;
638
621
639
- mutex_lock (& ftrace_start_lock );
640
622
ftrace_start_up -- ;
641
623
if (!ftrace_start_up )
642
624
command |= FTRACE_DISABLE_CALLS ;
@@ -647,11 +629,9 @@ static void ftrace_shutdown(int command)
647
629
}
648
630
649
631
if (!command || !ftrace_enabled )
650
- goto out ;
632
+ return ;
651
633
652
634
ftrace_run_update_code (command );
653
- out :
654
- mutex_unlock (& ftrace_start_lock );
655
635
}
656
636
657
637
static void ftrace_startup_sysctl (void )
@@ -661,15 +641,13 @@ static void ftrace_startup_sysctl(void)
661
641
if (unlikely (ftrace_disabled ))
662
642
return ;
663
643
664
- mutex_lock (& ftrace_start_lock );
665
644
/* Force update next time */
666
645
saved_ftrace_func = NULL ;
667
646
/* ftrace_start_up is true if we want ftrace running */
668
647
if (ftrace_start_up )
669
648
command |= FTRACE_ENABLE_CALLS ;
670
649
671
650
ftrace_run_update_code (command );
672
- mutex_unlock (& ftrace_start_lock );
673
651
}
674
652
675
653
static void ftrace_shutdown_sysctl (void )
@@ -679,13 +657,11 @@ static void ftrace_shutdown_sysctl(void)
679
657
if (unlikely (ftrace_disabled ))
680
658
return ;
681
659
682
- mutex_lock (& ftrace_start_lock );
683
660
/* ftrace_start_up is true if ftrace is running */
684
661
if (ftrace_start_up )
685
662
command |= FTRACE_DISABLE_CALLS ;
686
663
687
664
ftrace_run_update_code (command );
688
- mutex_unlock (& ftrace_start_lock );
689
665
}
690
666
691
667
static cycle_t ftrace_update_time ;
@@ -1502,12 +1478,10 @@ ftrace_regex_release(struct inode *inode, struct file *file, int enable)
1502
1478
ftrace_match_records (iter -> buffer , iter -> buffer_idx , enable );
1503
1479
}
1504
1480
1505
- mutex_lock (& ftrace_sysctl_lock );
1506
- mutex_lock (& ftrace_start_lock );
1481
+ mutex_lock (& ftrace_lock );
1507
1482
if (ftrace_start_up && ftrace_enabled )
1508
1483
ftrace_run_update_code (FTRACE_ENABLE_CALLS );
1509
- mutex_unlock (& ftrace_start_lock );
1510
- mutex_unlock (& ftrace_sysctl_lock );
1484
+ mutex_unlock (& ftrace_lock );
1511
1485
1512
1486
kfree (iter );
1513
1487
mutex_unlock (& ftrace_regex_lock );
@@ -1824,7 +1798,7 @@ static int ftrace_convert_nops(struct module *mod,
1824
1798
unsigned long addr ;
1825
1799
unsigned long flags ;
1826
1800
1827
- mutex_lock (& ftrace_start_lock );
1801
+ mutex_lock (& ftrace_lock );
1828
1802
p = start ;
1829
1803
while (p < end ) {
1830
1804
addr = ftrace_call_adjust (* p ++ );
@@ -1843,7 +1817,7 @@ static int ftrace_convert_nops(struct module *mod,
1843
1817
local_irq_save (flags );
1844
1818
ftrace_update_code (mod );
1845
1819
local_irq_restore (flags );
1846
- mutex_unlock (& ftrace_start_lock );
1820
+ mutex_unlock (& ftrace_lock );
1847
1821
1848
1822
return 0 ;
1849
1823
}
@@ -2016,7 +1990,7 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf,
2016
1990
if (ret < 0 )
2017
1991
return ret ;
2018
1992
2019
- mutex_lock (& ftrace_start_lock );
1993
+ mutex_lock (& ftrace_lock );
2020
1994
if (val < 0 ) {
2021
1995
/* disable pid tracing */
2022
1996
if (!ftrace_pid_trace )
@@ -2055,7 +2029,7 @@ ftrace_pid_write(struct file *filp, const char __user *ubuf,
2055
2029
ftrace_startup_enable (0 );
2056
2030
2057
2031
out :
2058
- mutex_unlock (& ftrace_start_lock );
2032
+ mutex_unlock (& ftrace_lock );
2059
2033
2060
2034
return cnt ;
2061
2035
}
@@ -2118,12 +2092,12 @@ int register_ftrace_function(struct ftrace_ops *ops)
2118
2092
if (unlikely (ftrace_disabled ))
2119
2093
return -1 ;
2120
2094
2121
- mutex_lock (& ftrace_sysctl_lock );
2095
+ mutex_lock (& ftrace_lock );
2122
2096
2123
2097
ret = __register_ftrace_function (ops );
2124
2098
ftrace_startup (0 );
2125
2099
2126
- mutex_unlock (& ftrace_sysctl_lock );
2100
+ mutex_unlock (& ftrace_lock );
2127
2101
return ret ;
2128
2102
}
2129
2103
@@ -2137,10 +2111,10 @@ int unregister_ftrace_function(struct ftrace_ops *ops)
2137
2111
{
2138
2112
int ret ;
2139
2113
2140
- mutex_lock (& ftrace_sysctl_lock );
2114
+ mutex_lock (& ftrace_lock );
2141
2115
ret = __unregister_ftrace_function (ops );
2142
2116
ftrace_shutdown (0 );
2143
- mutex_unlock (& ftrace_sysctl_lock );
2117
+ mutex_unlock (& ftrace_lock );
2144
2118
2145
2119
return ret ;
2146
2120
}
@@ -2155,7 +2129,7 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
2155
2129
if (unlikely (ftrace_disabled ))
2156
2130
return - ENODEV ;
2157
2131
2158
- mutex_lock (& ftrace_sysctl_lock );
2132
+ mutex_lock (& ftrace_lock );
2159
2133
2160
2134
ret = proc_dointvec (table , write , file , buffer , lenp , ppos );
2161
2135
@@ -2184,7 +2158,7 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
2184
2158
}
2185
2159
2186
2160
out :
2187
- mutex_unlock (& ftrace_sysctl_lock );
2161
+ mutex_unlock (& ftrace_lock );
2188
2162
return ret ;
2189
2163
}
2190
2164
@@ -2296,7 +2270,7 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
2296
2270
{
2297
2271
int ret = 0 ;
2298
2272
2299
- mutex_lock (& ftrace_sysctl_lock );
2273
+ mutex_lock (& ftrace_lock );
2300
2274
2301
2275
ftrace_suspend_notifier .notifier_call = ftrace_suspend_notifier_call ;
2302
2276
register_pm_notifier (& ftrace_suspend_notifier );
@@ -2314,21 +2288,21 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
2314
2288
ftrace_startup (FTRACE_START_FUNC_RET );
2315
2289
2316
2290
out :
2317
- mutex_unlock (& ftrace_sysctl_lock );
2291
+ mutex_unlock (& ftrace_lock );
2318
2292
return ret ;
2319
2293
}
2320
2294
2321
2295
void unregister_ftrace_graph (void )
2322
2296
{
2323
- mutex_lock (& ftrace_sysctl_lock );
2297
+ mutex_lock (& ftrace_lock );
2324
2298
2325
2299
atomic_dec (& ftrace_graph_active );
2326
2300
ftrace_graph_return = (trace_func_graph_ret_t )ftrace_stub ;
2327
2301
ftrace_graph_entry = ftrace_graph_entry_stub ;
2328
2302
ftrace_shutdown (FTRACE_STOP_FUNC_RET );
2329
2303
unregister_pm_notifier (& ftrace_suspend_notifier );
2330
2304
2331
- mutex_unlock (& ftrace_sysctl_lock );
2305
+ mutex_unlock (& ftrace_lock );
2332
2306
}
2333
2307
2334
2308
/* Allocate a return stack for newly created task */
0 commit comments