@@ -1160,13 +1160,11 @@ int __trace_array_puts(struct trace_array *tr, unsigned long ip,
1160
1160
1161
1161
trace_ctx = tracing_gen_ctx ();
1162
1162
buffer = tr -> array_buffer .buffer ;
1163
- ring_buffer_nest_start (buffer );
1163
+ guard ( ring_buffer_nest ) (buffer );
1164
1164
event = __trace_buffer_lock_reserve (buffer , TRACE_PRINT , alloc ,
1165
1165
trace_ctx );
1166
- if (!event ) {
1167
- size = 0 ;
1168
- goto out ;
1169
- }
1166
+ if (!event )
1167
+ return 0 ;
1170
1168
1171
1169
entry = ring_buffer_event_data (event );
1172
1170
entry -> ip = ip ;
@@ -1182,8 +1180,6 @@ int __trace_array_puts(struct trace_array *tr, unsigned long ip,
1182
1180
1183
1181
__buffer_unlock_commit (buffer , event );
1184
1182
ftrace_trace_stack (tr , buffer , trace_ctx , 4 , NULL );
1185
- out :
1186
- ring_buffer_nest_end (buffer );
1187
1183
return size ;
1188
1184
}
1189
1185
EXPORT_SYMBOL_GPL (__trace_array_puts );
@@ -1213,7 +1209,6 @@ int __trace_bputs(unsigned long ip, const char *str)
1213
1209
struct bputs_entry * entry ;
1214
1210
unsigned int trace_ctx ;
1215
1211
int size = sizeof (struct bputs_entry );
1216
- int ret = 0 ;
1217
1212
1218
1213
if (!printk_binsafe (tr ))
1219
1214
return __trace_puts (ip , str , strlen (str ));
@@ -1227,11 +1222,11 @@ int __trace_bputs(unsigned long ip, const char *str)
1227
1222
trace_ctx = tracing_gen_ctx ();
1228
1223
buffer = tr -> array_buffer .buffer ;
1229
1224
1230
- ring_buffer_nest_start (buffer );
1225
+ guard ( ring_buffer_nest ) (buffer );
1231
1226
event = __trace_buffer_lock_reserve (buffer , TRACE_BPUTS , size ,
1232
1227
trace_ctx );
1233
1228
if (!event )
1234
- goto out ;
1229
+ return 0 ;
1235
1230
1236
1231
entry = ring_buffer_event_data (event );
1237
1232
entry -> ip = ip ;
@@ -1240,10 +1235,7 @@ int __trace_bputs(unsigned long ip, const char *str)
1240
1235
__buffer_unlock_commit (buffer , event );
1241
1236
ftrace_trace_stack (tr , buffer , trace_ctx , 4 , NULL );
1242
1237
1243
- ret = 1 ;
1244
- out :
1245
- ring_buffer_nest_end (buffer );
1246
- return ret ;
1238
+ return 1 ;
1247
1239
}
1248
1240
EXPORT_SYMBOL_GPL (__trace_bputs );
1249
1241
@@ -3397,21 +3389,19 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args)
3397
3389
3398
3390
size = sizeof (* entry ) + sizeof (u32 ) * len ;
3399
3391
buffer = tr -> array_buffer .buffer ;
3400
- ring_buffer_nest_start (buffer );
3401
- event = __trace_buffer_lock_reserve (buffer , TRACE_BPRINT , size ,
3402
- trace_ctx );
3403
- if (!event )
3404
- goto out ;
3405
- entry = ring_buffer_event_data (event );
3406
- entry -> ip = ip ;
3407
- entry -> fmt = fmt ;
3408
-
3409
- memcpy (entry -> buf , tbuffer , sizeof (u32 ) * len );
3410
- __buffer_unlock_commit (buffer , event );
3411
- ftrace_trace_stack (tr , buffer , trace_ctx , 6 , NULL );
3392
+ scoped_guard (ring_buffer_nest , buffer ) {
3393
+ event = __trace_buffer_lock_reserve (buffer , TRACE_BPRINT , size ,
3394
+ trace_ctx );
3395
+ if (!event )
3396
+ goto out_put ;
3397
+ entry = ring_buffer_event_data (event );
3398
+ entry -> ip = ip ;
3399
+ entry -> fmt = fmt ;
3412
3400
3413
- out :
3414
- ring_buffer_nest_end (buffer );
3401
+ memcpy (entry -> buf , tbuffer , sizeof (u32 ) * len );
3402
+ __buffer_unlock_commit (buffer , event );
3403
+ ftrace_trace_stack (tr , buffer , trace_ctx , 6 , NULL );
3404
+ }
3415
3405
out_put :
3416
3406
put_trace_buf ();
3417
3407
@@ -3452,20 +3442,19 @@ int __trace_array_vprintk(struct trace_buffer *buffer,
3452
3442
len = vscnprintf (tbuffer , TRACE_BUF_SIZE , fmt , args );
3453
3443
3454
3444
size = sizeof (* entry ) + len + 1 ;
3455
- ring_buffer_nest_start (buffer );
3456
- event = __trace_buffer_lock_reserve (buffer , TRACE_PRINT , size ,
3457
- trace_ctx );
3458
- if (!event )
3459
- goto out ;
3460
- entry = ring_buffer_event_data (event );
3461
- entry -> ip = ip ;
3462
-
3463
- memcpy (& entry -> buf , tbuffer , len + 1 );
3464
- __buffer_unlock_commit (buffer , event );
3465
- ftrace_trace_stack (printk_trace , buffer , trace_ctx , 6 , NULL );
3445
+ scoped_guard (ring_buffer_nest , buffer ) {
3446
+ event = __trace_buffer_lock_reserve (buffer , TRACE_PRINT , size ,
3447
+ trace_ctx );
3448
+ if (!event )
3449
+ goto out ;
3450
+ entry = ring_buffer_event_data (event );
3451
+ entry -> ip = ip ;
3466
3452
3453
+ memcpy (& entry -> buf , tbuffer , len + 1 );
3454
+ __buffer_unlock_commit (buffer , event );
3455
+ ftrace_trace_stack (printk_trace , buffer , trace_ctx , 6 , NULL );
3456
+ }
3467
3457
out :
3468
- ring_buffer_nest_end (buffer );
3469
3458
put_trace_buf ();
3470
3459
3471
3460
out_nobuffer :
0 commit comments