@@ -536,24 +536,21 @@ static int function_stat_show(struct seq_file *m, void *v)
536
536
{
537
537
struct ftrace_profile * rec = v ;
538
538
char str [KSYM_SYMBOL_LEN ];
539
- int ret = 0 ;
540
539
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
541
540
static struct trace_seq s ;
542
541
unsigned long long avg ;
543
542
unsigned long long stddev ;
544
543
#endif
545
- mutex_lock (& ftrace_profile_lock );
544
+ guard ( mutex ) (& ftrace_profile_lock );
546
545
547
546
/* we raced with function_profile_reset() */
548
- if (unlikely (rec -> counter == 0 )) {
549
- ret = - EBUSY ;
550
- goto out ;
551
- }
547
+ if (unlikely (rec -> counter == 0 ))
548
+ return - EBUSY ;
552
549
553
550
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
554
551
avg = div64_ul (rec -> time , rec -> counter );
555
552
if (tracing_thresh && (avg < tracing_thresh ))
556
- goto out ;
553
+ return 0 ;
557
554
#endif
558
555
559
556
kallsyms_lookup (rec -> ip , NULL , NULL , NULL , str );
@@ -590,10 +587,8 @@ static int function_stat_show(struct seq_file *m, void *v)
590
587
trace_print_seq (m , & s );
591
588
#endif
592
589
seq_putc (m , '\n' );
593
- out :
594
- mutex_unlock (& ftrace_profile_lock );
595
590
596
- return ret ;
591
+ return 0 ;
597
592
}
598
593
599
594
static void ftrace_profile_reset (struct ftrace_profile_stat * stat )
@@ -944,20 +939,16 @@ ftrace_profile_write(struct file *filp, const char __user *ubuf,
944
939
945
940
val = !!val ;
946
941
947
- mutex_lock (& ftrace_profile_lock );
942
+ guard ( mutex ) (& ftrace_profile_lock );
948
943
if (ftrace_profile_enabled ^ val ) {
949
944
if (val ) {
950
945
ret = ftrace_profile_init ();
951
- if (ret < 0 ) {
952
- cnt = ret ;
953
- goto out ;
954
- }
946
+ if (ret < 0 )
947
+ return ret ;
955
948
956
949
ret = register_ftrace_profiler ();
957
- if (ret < 0 ) {
958
- cnt = ret ;
959
- goto out ;
960
- }
950
+ if (ret < 0 )
951
+ return ret ;
961
952
ftrace_profile_enabled = 1 ;
962
953
} else {
963
954
ftrace_profile_enabled = 0 ;
@@ -968,8 +959,6 @@ ftrace_profile_write(struct file *filp, const char __user *ubuf,
968
959
unregister_ftrace_profiler ();
969
960
}
970
961
}
971
- out :
972
- mutex_unlock (& ftrace_profile_lock );
973
962
974
963
* ppos += cnt ;
975
964
@@ -5610,20 +5599,15 @@ static DEFINE_MUTEX(ftrace_cmd_mutex);
5610
5599
__init int register_ftrace_command (struct ftrace_func_command * cmd )
5611
5600
{
5612
5601
struct ftrace_func_command * p ;
5613
- int ret = 0 ;
5614
5602
5615
- mutex_lock (& ftrace_cmd_mutex );
5603
+ guard ( mutex ) (& ftrace_cmd_mutex );
5616
5604
list_for_each_entry (p , & ftrace_commands , list ) {
5617
- if (strcmp (cmd -> name , p -> name ) == 0 ) {
5618
- ret = - EBUSY ;
5619
- goto out_unlock ;
5620
- }
5605
+ if (strcmp (cmd -> name , p -> name ) == 0 )
5606
+ return - EBUSY ;
5621
5607
}
5622
5608
list_add (& cmd -> list , & ftrace_commands );
5623
- out_unlock :
5624
- mutex_unlock (& ftrace_cmd_mutex );
5625
5609
5626
- return ret ;
5610
+ return 0 ;
5627
5611
}
5628
5612
5629
5613
/*
@@ -5633,20 +5617,17 @@ __init int register_ftrace_command(struct ftrace_func_command *cmd)
5633
5617
__init int unregister_ftrace_command (struct ftrace_func_command * cmd )
5634
5618
{
5635
5619
struct ftrace_func_command * p , * n ;
5636
- int ret = - ENODEV ;
5637
5620
5638
- mutex_lock (& ftrace_cmd_mutex );
5621
+ guard (mutex )(& ftrace_cmd_mutex );
5622
+
5639
5623
list_for_each_entry_safe (p , n , & ftrace_commands , list ) {
5640
5624
if (strcmp (cmd -> name , p -> name ) == 0 ) {
5641
- ret = 0 ;
5642
5625
list_del_init (& p -> list );
5643
- goto out_unlock ;
5626
+ return 0 ;
5644
5627
}
5645
5628
}
5646
- out_unlock :
5647
- mutex_unlock (& ftrace_cmd_mutex );
5648
5629
5649
- return ret ;
5630
+ return - ENODEV ;
5650
5631
}
5651
5632
5652
5633
static int ftrace_process_regex (struct ftrace_iterator * iter ,
@@ -5656,7 +5637,7 @@ static int ftrace_process_regex(struct ftrace_iterator *iter,
5656
5637
struct trace_array * tr = iter -> ops -> private ;
5657
5638
char * func , * command , * next = buff ;
5658
5639
struct ftrace_func_command * p ;
5659
- int ret = - EINVAL ;
5640
+ int ret ;
5660
5641
5661
5642
func = strsep (& next , ":" );
5662
5643
@@ -5673,17 +5654,14 @@ static int ftrace_process_regex(struct ftrace_iterator *iter,
5673
5654
5674
5655
command = strsep (& next , ":" );
5675
5656
5676
- mutex_lock (& ftrace_cmd_mutex );
5657
+ guard (mutex )(& ftrace_cmd_mutex );
5658
+
5677
5659
list_for_each_entry (p , & ftrace_commands , list ) {
5678
- if (strcmp (p -> name , command ) == 0 ) {
5679
- ret = p -> func (tr , hash , func , command , next , enable );
5680
- goto out_unlock ;
5681
- }
5660
+ if (strcmp (p -> name , command ) == 0 )
5661
+ return p -> func (tr , hash , func , command , next , enable );
5682
5662
}
5683
- out_unlock :
5684
- mutex_unlock (& ftrace_cmd_mutex );
5685
5663
5686
- return ret ;
5664
+ return - EINVAL ;
5687
5665
}
5688
5666
5689
5667
static ssize_t
@@ -8280,7 +8258,7 @@ pid_write(struct file *filp, const char __user *ubuf,
8280
8258
if (!cnt )
8281
8259
return 0 ;
8282
8260
8283
- mutex_lock (& ftrace_lock );
8261
+ guard ( mutex ) (& ftrace_lock );
8284
8262
8285
8263
switch (type ) {
8286
8264
case TRACE_PIDS :
@@ -8296,14 +8274,13 @@ pid_write(struct file *filp, const char __user *ubuf,
8296
8274
lockdep_is_held (& ftrace_lock ));
8297
8275
break ;
8298
8276
default :
8299
- ret = - EINVAL ;
8300
8277
WARN_ON_ONCE (1 );
8301
- goto out ;
8278
+ return - EINVAL ;
8302
8279
}
8303
8280
8304
8281
ret = trace_pid_write (filtered_pids , & pid_list , ubuf , cnt );
8305
8282
if (ret < 0 )
8306
- goto out ;
8283
+ return ret ;
8307
8284
8308
8285
switch (type ) {
8309
8286
case TRACE_PIDS :
@@ -8332,11 +8309,8 @@ pid_write(struct file *filp, const char __user *ubuf,
8332
8309
8333
8310
ftrace_update_pid_func ();
8334
8311
ftrace_startup_all (0 );
8335
- out :
8336
- mutex_unlock (& ftrace_lock );
8337
8312
8338
- if (ret > 0 )
8339
- * ppos += ret ;
8313
+ * ppos += ret ;
8340
8314
8341
8315
return ret ;
8342
8316
}
@@ -8739,17 +8713,17 @@ static int
8739
8713
ftrace_enable_sysctl (const struct ctl_table * table , int write ,
8740
8714
void * buffer , size_t * lenp , loff_t * ppos )
8741
8715
{
8742
- int ret = - ENODEV ;
8716
+ int ret ;
8743
8717
8744
- mutex_lock (& ftrace_lock );
8718
+ guard ( mutex ) (& ftrace_lock );
8745
8719
8746
8720
if (unlikely (ftrace_disabled ))
8747
- goto out ;
8721
+ return - ENODEV ;
8748
8722
8749
8723
ret = proc_dointvec (table , write , buffer , lenp , ppos );
8750
8724
8751
8725
if (ret || !write || (last_ftrace_enabled == !!ftrace_enabled ))
8752
- goto out ;
8726
+ return ret ;
8753
8727
8754
8728
if (ftrace_enabled ) {
8755
8729
@@ -8763,8 +8737,7 @@ ftrace_enable_sysctl(const struct ctl_table *table, int write,
8763
8737
} else {
8764
8738
if (is_permanent_ops_registered ()) {
8765
8739
ftrace_enabled = true;
8766
- ret = - EBUSY ;
8767
- goto out ;
8740
+ return - EBUSY ;
8768
8741
}
8769
8742
8770
8743
/* stopping ftrace calls (just send to ftrace_stub) */
@@ -8774,9 +8747,7 @@ ftrace_enable_sysctl(const struct ctl_table *table, int write,
8774
8747
}
8775
8748
8776
8749
last_ftrace_enabled = !!ftrace_enabled ;
8777
- out :
8778
- mutex_unlock (& ftrace_lock );
8779
- return ret ;
8750
+ return 0 ;
8780
8751
}
8781
8752
8782
8753
static struct ctl_table ftrace_sysctls [] = {
0 commit comments