Skip to content

Commit de31954

Browse files
committed
tetragon: Wire extra process event tail call to tracepoint sensor
before: generic_tracepoint_process_event 3878 insns now: generic_tracepoint_process_event_2 2925 insns generic_tracepoint_process_event 2501 insns Signed-off-by: Jiri Olsa <jolsa@kernel.org>
1 parent ade076d commit de31954

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

bpf/process/bpf_generic_tracepoint.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ int generic_tracepoint_filter(void *ctx);
2222
int generic_tracepoint_arg(void *ctx);
2323
int generic_tracepoint_actions(void *ctx);
2424
int generic_tracepoint_output(void *ctx);
25+
int generic_tracepoint_process_event_2(void *ctx);
2526

2627
struct {
2728
__uint(type, BPF_MAP_TYPE_PROG_ARRAY);
@@ -35,6 +36,9 @@ struct {
3536
[TAIL_CALL_ARGS] = (void *)&generic_tracepoint_arg,
3637
[TAIL_CALL_ACTIONS] = (void *)&generic_tracepoint_actions,
3738
[TAIL_CALL_SEND] = (void *)&generic_tracepoint_output,
39+
#ifndef __LARGE_BPF_PROG
40+
[TAIL_CALL_PROCESS_2] = (void *)&generic_tracepoint_process_event_2,
41+
#endif
3842
},
3943
};
4044

@@ -260,12 +264,26 @@ generic_tracepoint_event(struct generic_tracepoint_event_arg *ctx)
260264
return 0;
261265
}
262266

267+
#ifdef __LARGE_BPF_PROG
268+
__attribute__((section("tracepoint"), used)) int
269+
generic_tracepoint_process_event(void *ctx)
270+
{
271+
return generic_process_event(ctx, (struct bpf_map_def *)&tp_calls, __READ_ARG_ALL);
272+
}
273+
#else
263274
__attribute__((section("tracepoint"), used)) int
264275
generic_tracepoint_process_event(void *ctx)
265276
{
266277
return generic_process_event(ctx, (struct bpf_map_def *)&tp_calls, __READ_ARG_ALL);
267278
}
268279

280+
__attribute__((section("tracepoint"), used)) int
281+
generic_tracepoint_process_event_2(void *ctx)
282+
{
283+
return generic_process_event(ctx, (struct bpf_map_def *)&tp_calls, __READ_ARG_2);
284+
}
285+
#endif
286+
269287
__attribute__((section("tracepoint"), used)) int
270288
generic_tracepoint_filter(void *ctx)
271289
{

pkg/sensors/tracing/tracepoint_test.go

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -444,23 +444,23 @@ func TestLoadTracepointSensor(t *testing.T) {
444444
}
445445

446446
var sensorMaps = []tus.SensorMap{
447+
// generic_tracepoint_output
448+
{Name: "tcpmon_map", Progs: []uint{5}},
449+
}
450+
451+
if config.EnableLargeProgs() {
447452
// all programs
448-
{Name: "process_call_heap", Progs: []uint{0, 1, 2, 3, 4, 5}},
453+
sensorMaps = append(sensorMaps, tus.SensorMap{Name: "process_call_heap", Progs: []uint{0, 1, 2, 3, 4, 5}})
449454

450455
// all but generic_tracepoint_output
451-
{Name: "tp_calls", Progs: []uint{0, 1, 2, 3, 4}},
456+
sensorMaps = append(sensorMaps, tus.SensorMap{Name: "tp_calls", Progs: []uint{0, 1, 2, 3, 4}})
452457

453458
// all but generic_tracepoint_event,generic_tracepoint_filter
454-
{Name: "retprobe_map", Progs: []uint{1, 2}},
455-
456-
// generic_tracepoint_output
457-
{Name: "tcpmon_map", Progs: []uint{5}},
459+
sensorMaps = append(sensorMaps, tus.SensorMap{Name: "retprobe_map", Progs: []uint{1, 2}})
458460

459461
// all kprobe but generic_tracepoint_filter
460-
{Name: "config_map", Progs: []uint{0, 2}},
461-
}
462+
sensorMaps = append(sensorMaps, tus.SensorMap{Name: "config_map", Progs: []uint{0, 2}})
462463

463-
if config.EnableLargeProgs() {
464464
// shared with base sensor
465465
sensorMaps = append(sensorMaps, tus.SensorMap{Name: "execve_map", Progs: []uint{3, 4, 5}})
466466

@@ -474,11 +474,25 @@ func TestLoadTracepointSensor(t *testing.T) {
474474
sensorMaps = append(sensorMaps, tus.SensorMap{Name: "tg_conf_map", Progs: []uint{0}})
475475
}
476476
} else {
477+
sensorProgs = append(sensorProgs, tus.SensorProg{Name: "generic_tracepoint_process_event_2", Type: ebpf.TracePoint})
478+
479+
// all programs
480+
sensorMaps = append(sensorMaps, tus.SensorMap{Name: "process_call_heap", Progs: []uint{0, 1, 2, 3, 4, 5, 6}})
481+
482+
// all but generic_tracepoint_output
483+
sensorMaps = append(sensorMaps, tus.SensorMap{Name: "tp_calls", Progs: []uint{0, 1, 2, 3, 4, 6}})
484+
485+
// all but generic_tracepoint_event,generic_tracepoint_filter
486+
sensorMaps = append(sensorMaps, tus.SensorMap{Name: "retprobe_map", Progs: []uint{1, 2, 6}})
487+
488+
// all kprobe but generic_tracepoint_filter
489+
sensorMaps = append(sensorMaps, tus.SensorMap{Name: "config_map", Progs: []uint{0, 2, 6}})
490+
477491
// shared with base sensor
478492
sensorMaps = append(sensorMaps, tus.SensorMap{Name: "execve_map", Progs: []uint{3}})
479493

480494
// only generic_tracepoint_event*
481-
sensorMaps = append(sensorMaps, tus.SensorMap{Name: "buffer_heap_map", Progs: []uint{2}})
495+
sensorMaps = append(sensorMaps, tus.SensorMap{Name: "buffer_heap_map", Progs: []uint{2, 6}})
482496

483497
sensorMaps = append(sensorMaps, tus.SensorMap{Name: "tg_conf_map", Progs: []uint{0}})
484498
}

0 commit comments

Comments
 (0)