12
12
#include "trace.h"
13
13
14
14
static DEFINE_MUTEX (syscall_trace_lock );
15
- static int sys_refcount_enter ;
16
- static int sys_refcount_exit ;
17
- static DECLARE_BITMAP (enabled_enter_syscalls , NR_syscalls ) ;
18
- static DECLARE_BITMAP (enabled_exit_syscalls , NR_syscalls ) ;
19
15
20
16
static int syscall_enter_register (struct ftrace_event_call * event ,
21
17
enum trace_reg type , void * data );
@@ -303,8 +299,9 @@ static int syscall_exit_define_fields(struct ftrace_event_call *call)
303
299
return ret ;
304
300
}
305
301
306
- static void ftrace_syscall_enter (void * ignore , struct pt_regs * regs , long id )
302
+ static void ftrace_syscall_enter (void * data , struct pt_regs * regs , long id )
307
303
{
304
+ struct trace_array * tr = data ;
308
305
struct syscall_trace_enter * entry ;
309
306
struct syscall_metadata * sys_data ;
310
307
struct ring_buffer_event * event ;
@@ -315,7 +312,7 @@ static void ftrace_syscall_enter(void *ignore, struct pt_regs *regs, long id)
315
312
syscall_nr = trace_get_syscall_nr (current , regs );
316
313
if (syscall_nr < 0 )
317
314
return ;
318
- if (!test_bit (syscall_nr , enabled_enter_syscalls ))
315
+ if (!test_bit (syscall_nr , tr -> enabled_enter_syscalls ))
319
316
return ;
320
317
321
318
sys_data = syscall_nr_to_meta (syscall_nr );
@@ -324,7 +321,8 @@ static void ftrace_syscall_enter(void *ignore, struct pt_regs *regs, long id)
324
321
325
322
size = sizeof (* entry ) + sizeof (unsigned long ) * sys_data -> nb_args ;
326
323
327
- event = trace_current_buffer_lock_reserve (& buffer ,
324
+ buffer = tr -> buffer ;
325
+ event = trace_buffer_lock_reserve (buffer ,
328
326
sys_data -> enter_event -> event .type , size , 0 , 0 );
329
327
if (!event )
330
328
return ;
@@ -338,8 +336,9 @@ static void ftrace_syscall_enter(void *ignore, struct pt_regs *regs, long id)
338
336
trace_current_buffer_unlock_commit (buffer , event , 0 , 0 );
339
337
}
340
338
341
- static void ftrace_syscall_exit (void * ignore , struct pt_regs * regs , long ret )
339
+ static void ftrace_syscall_exit (void * data , struct pt_regs * regs , long ret )
342
340
{
341
+ struct trace_array * tr = data ;
343
342
struct syscall_trace_exit * entry ;
344
343
struct syscall_metadata * sys_data ;
345
344
struct ring_buffer_event * event ;
@@ -349,14 +348,15 @@ static void ftrace_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
349
348
syscall_nr = trace_get_syscall_nr (current , regs );
350
349
if (syscall_nr < 0 )
351
350
return ;
352
- if (!test_bit (syscall_nr , enabled_exit_syscalls ))
351
+ if (!test_bit (syscall_nr , tr -> enabled_exit_syscalls ))
353
352
return ;
354
353
355
354
sys_data = syscall_nr_to_meta (syscall_nr );
356
355
if (!sys_data )
357
356
return ;
358
357
359
- event = trace_current_buffer_lock_reserve (& buffer ,
358
+ buffer = tr -> buffer ;
359
+ event = trace_buffer_lock_reserve (buffer ,
360
360
sys_data -> exit_event -> event .type , sizeof (* entry ), 0 , 0 );
361
361
if (!event )
362
362
return ;
@@ -370,71 +370,79 @@ static void ftrace_syscall_exit(void *ignore, struct pt_regs *regs, long ret)
370
370
trace_current_buffer_unlock_commit (buffer , event , 0 , 0 );
371
371
}
372
372
373
- static int reg_event_syscall_enter (struct ftrace_event_call * call )
373
+ static int reg_event_syscall_enter (struct ftrace_event_file * file ,
374
+ struct ftrace_event_call * call )
374
375
{
376
+ struct trace_array * tr = file -> tr ;
375
377
int ret = 0 ;
376
378
int num ;
377
379
378
380
num = ((struct syscall_metadata * )call -> data )-> syscall_nr ;
379
381
if (WARN_ON_ONCE (num < 0 || num >= NR_syscalls ))
380
382
return - ENOSYS ;
381
383
mutex_lock (& syscall_trace_lock );
382
- if (!sys_refcount_enter )
383
- ret = register_trace_sys_enter (ftrace_syscall_enter , NULL );
384
+ if (!tr -> sys_refcount_enter )
385
+ ret = register_trace_sys_enter (ftrace_syscall_enter , tr );
384
386
if (!ret ) {
385
- set_bit (num , enabled_enter_syscalls );
386
- sys_refcount_enter ++ ;
387
+ set_bit (num , tr -> enabled_enter_syscalls );
388
+ tr -> sys_refcount_enter ++ ;
387
389
}
388
390
mutex_unlock (& syscall_trace_lock );
389
391
return ret ;
390
392
}
391
393
392
- static void unreg_event_syscall_enter (struct ftrace_event_call * call )
394
+ static void unreg_event_syscall_enter (struct ftrace_event_file * file ,
395
+ struct ftrace_event_call * call )
393
396
{
397
+ struct trace_array * tr = file -> tr ;
394
398
int num ;
395
399
396
400
num = ((struct syscall_metadata * )call -> data )-> syscall_nr ;
397
401
if (WARN_ON_ONCE (num < 0 || num >= NR_syscalls ))
398
402
return ;
399
403
mutex_lock (& syscall_trace_lock );
400
- sys_refcount_enter -- ;
401
- clear_bit (num , enabled_enter_syscalls );
402
- if (!sys_refcount_enter )
403
- unregister_trace_sys_enter (ftrace_syscall_enter , NULL );
404
+ tr -> sys_refcount_enter -- ;
405
+ clear_bit (num , tr -> enabled_enter_syscalls );
406
+ if (!tr -> sys_refcount_enter )
407
+ unregister_trace_sys_enter (ftrace_syscall_enter , tr );
404
408
mutex_unlock (& syscall_trace_lock );
405
409
}
406
410
407
- static int reg_event_syscall_exit (struct ftrace_event_call * call )
411
+ static int reg_event_syscall_exit (struct ftrace_event_file * file ,
412
+ struct ftrace_event_call * call )
408
413
{
414
+ struct trace_array * tr = file -> tr ;
409
415
int ret = 0 ;
410
416
int num ;
411
417
412
418
num = ((struct syscall_metadata * )call -> data )-> syscall_nr ;
413
419
if (WARN_ON_ONCE (num < 0 || num >= NR_syscalls ))
414
420
return - ENOSYS ;
415
421
mutex_lock (& syscall_trace_lock );
416
- if (!sys_refcount_exit )
417
- ret = register_trace_sys_exit (ftrace_syscall_exit , NULL );
422
+ if (!tr -> sys_refcount_exit )
423
+ ret = register_trace_sys_exit (ftrace_syscall_exit , tr );
418
424
if (!ret ) {
419
- set_bit (num , enabled_exit_syscalls );
420
- sys_refcount_exit ++ ;
425
+ set_bit (num , tr -> enabled_exit_syscalls );
426
+ tr -> sys_refcount_exit ++ ;
421
427
}
422
428
mutex_unlock (& syscall_trace_lock );
423
429
return ret ;
424
430
}
425
431
426
- static void unreg_event_syscall_exit (struct ftrace_event_call * call )
432
+ static void unreg_event_syscall_exit (struct ftrace_event_file * file ,
433
+ struct ftrace_event_call * call )
427
434
{
435
+ struct trace_array * tr = file -> tr ;
428
436
int num ;
429
437
430
438
num = ((struct syscall_metadata * )call -> data )-> syscall_nr ;
431
439
if (WARN_ON_ONCE (num < 0 || num >= NR_syscalls ))
432
440
return ;
433
441
mutex_lock (& syscall_trace_lock );
434
- sys_refcount_exit -- ;
435
- clear_bit (num , enabled_exit_syscalls );
436
- if (!sys_refcount_exit )
437
- unregister_trace_sys_exit (ftrace_syscall_exit , NULL );
442
+ tr -> sys_refcount_exit -- ;
443
+ clear_bit (num , tr -> enabled_exit_syscalls );
444
+ if (!tr -> sys_refcount_exit )
445
+ unregister_trace_sys_exit (ftrace_syscall_exit , tr );
438
446
mutex_unlock (& syscall_trace_lock );
439
447
}
440
448
@@ -685,11 +693,13 @@ static void perf_sysexit_disable(struct ftrace_event_call *call)
685
693
static int syscall_enter_register (struct ftrace_event_call * event ,
686
694
enum trace_reg type , void * data )
687
695
{
696
+ struct ftrace_event_file * file = data ;
697
+
688
698
switch (type ) {
689
699
case TRACE_REG_REGISTER :
690
- return reg_event_syscall_enter (event );
700
+ return reg_event_syscall_enter (file , event );
691
701
case TRACE_REG_UNREGISTER :
692
- unreg_event_syscall_enter (event );
702
+ unreg_event_syscall_enter (file , event );
693
703
return 0 ;
694
704
695
705
#ifdef CONFIG_PERF_EVENTS
@@ -711,11 +721,13 @@ static int syscall_enter_register(struct ftrace_event_call *event,
711
721
static int syscall_exit_register (struct ftrace_event_call * event ,
712
722
enum trace_reg type , void * data )
713
723
{
724
+ struct ftrace_event_file * file = data ;
725
+
714
726
switch (type ) {
715
727
case TRACE_REG_REGISTER :
716
- return reg_event_syscall_exit (event );
728
+ return reg_event_syscall_exit (file , event );
717
729
case TRACE_REG_UNREGISTER :
718
- unreg_event_syscall_exit (event );
730
+ unreg_event_syscall_exit (file , event );
719
731
return 0 ;
720
732
721
733
#ifdef CONFIG_PERF_EVENTS
0 commit comments