@@ -332,7 +332,7 @@ static void *uprobe_producer_ret(void *input)
332
332
return NULL ;
333
333
}
334
334
335
- static void usetup (bool use_retprobe , void * target_addr )
335
+ static void usetup (bool use_retprobe , bool use_multi , void * target_addr )
336
336
{
337
337
size_t uprobe_offset ;
338
338
struct bpf_link * link ;
@@ -346,7 +346,10 @@ static void usetup(bool use_retprobe, void *target_addr)
346
346
exit (1 );
347
347
}
348
348
349
- bpf_program__set_autoload (ctx .skel -> progs .bench_trigger_uprobe , true);
349
+ if (use_multi )
350
+ bpf_program__set_autoload (ctx .skel -> progs .bench_trigger_uprobe_multi , true);
351
+ else
352
+ bpf_program__set_autoload (ctx .skel -> progs .bench_trigger_uprobe , true);
350
353
351
354
err = trigger_bench__load (ctx .skel );
352
355
if (err ) {
@@ -355,16 +358,28 @@ static void usetup(bool use_retprobe, void *target_addr)
355
358
}
356
359
357
360
uprobe_offset = get_uprobe_offset (target_addr );
358
- link = bpf_program__attach_uprobe (ctx .skel -> progs .bench_trigger_uprobe ,
359
- use_retprobe ,
360
- -1 /* all PIDs */ ,
361
- "/proc/self/exe" ,
362
- uprobe_offset );
361
+ if (use_multi ) {
362
+ LIBBPF_OPTS (bpf_uprobe_multi_opts , opts ,
363
+ .retprobe = use_retprobe ,
364
+ .cnt = 1 ,
365
+ .offsets = & uprobe_offset ,
366
+ );
367
+ link = bpf_program__attach_uprobe_multi (
368
+ ctx .skel -> progs .bench_trigger_uprobe_multi ,
369
+ -1 /* all PIDs */ , "/proc/self/exe" , NULL , & opts );
370
+ ctx .skel -> links .bench_trigger_uprobe_multi = link ;
371
+ } else {
372
+ link = bpf_program__attach_uprobe (ctx .skel -> progs .bench_trigger_uprobe ,
373
+ use_retprobe ,
374
+ -1 /* all PIDs */ ,
375
+ "/proc/self/exe" ,
376
+ uprobe_offset );
377
+ ctx .skel -> links .bench_trigger_uprobe = link ;
378
+ }
363
379
if (!link ) {
364
- fprintf (stderr , "failed to attach uprobe !\n" );
380
+ fprintf (stderr , "failed to attach %s !\n" , use_multi ? "multi-uprobe" : "uprobe " );
365
381
exit (1 );
366
382
}
367
- ctx .skel -> links .bench_trigger_uprobe = link ;
368
383
}
369
384
370
385
static void usermode_count_setup (void )
@@ -374,32 +389,62 @@ static void usermode_count_setup(void)
374
389
375
390
static void uprobe_nop_setup (void )
376
391
{
377
- usetup (false, & uprobe_target_nop );
392
+ usetup (false, false /* !use_multi */ , & uprobe_target_nop );
378
393
}
379
394
380
395
static void uretprobe_nop_setup (void )
381
396
{
382
- usetup (true, & uprobe_target_nop );
397
+ usetup (true, false /* !use_multi */ , & uprobe_target_nop );
383
398
}
384
399
385
400
static void uprobe_push_setup (void )
386
401
{
387
- usetup (false, & uprobe_target_push );
402
+ usetup (false, false /* !use_multi */ , & uprobe_target_push );
388
403
}
389
404
390
405
static void uretprobe_push_setup (void )
391
406
{
392
- usetup (true, & uprobe_target_push );
407
+ usetup (true, false /* !use_multi */ , & uprobe_target_push );
393
408
}
394
409
395
410
static void uprobe_ret_setup (void )
396
411
{
397
- usetup (false, & uprobe_target_ret );
412
+ usetup (false, false /* !use_multi */ , & uprobe_target_ret );
398
413
}
399
414
400
415
static void uretprobe_ret_setup (void )
401
416
{
402
- usetup (true, & uprobe_target_ret );
417
+ usetup (true, false /* !use_multi */ , & uprobe_target_ret );
418
+ }
419
+
420
+ static void uprobe_multi_nop_setup (void )
421
+ {
422
+ usetup (false, true /* use_multi */ , & uprobe_target_nop );
423
+ }
424
+
425
+ static void uretprobe_multi_nop_setup (void )
426
+ {
427
+ usetup (true, true /* use_multi */ , & uprobe_target_nop );
428
+ }
429
+
430
+ static void uprobe_multi_push_setup (void )
431
+ {
432
+ usetup (false, true /* use_multi */ , & uprobe_target_push );
433
+ }
434
+
435
+ static void uretprobe_multi_push_setup (void )
436
+ {
437
+ usetup (true, true /* use_multi */ , & uprobe_target_push );
438
+ }
439
+
440
+ static void uprobe_multi_ret_setup (void )
441
+ {
442
+ usetup (false, true /* use_multi */ , & uprobe_target_ret );
443
+ }
444
+
445
+ static void uretprobe_multi_ret_setup (void )
446
+ {
447
+ usetup (true, true /* use_multi */ , & uprobe_target_ret );
403
448
}
404
449
405
450
const struct bench bench_trig_syscall_count = {
@@ -454,3 +499,9 @@ BENCH_TRIG_USERMODE(uprobe_ret, ret, "uprobe-ret");
454
499
BENCH_TRIG_USERMODE (uretprobe_nop , nop , "uretprobe-nop" );
455
500
BENCH_TRIG_USERMODE (uretprobe_push , push , "uretprobe-push" );
456
501
BENCH_TRIG_USERMODE (uretprobe_ret , ret , "uretprobe-ret" );
502
+ BENCH_TRIG_USERMODE (uprobe_multi_nop , nop , "uprobe-multi-nop" );
503
+ BENCH_TRIG_USERMODE (uprobe_multi_push , push , "uprobe-multi-push" );
504
+ BENCH_TRIG_USERMODE (uprobe_multi_ret , ret , "uprobe-multi-ret" );
505
+ BENCH_TRIG_USERMODE (uretprobe_multi_nop , nop , "uretprobe-multi-nop" );
506
+ BENCH_TRIG_USERMODE (uretprobe_multi_push , push , "uretprobe-multi-push" );
507
+ BENCH_TRIG_USERMODE (uretprobe_multi_ret , ret , "uretprobe-multi-ret" );
0 commit comments