Sample Header Ad - 728x90

How does bpftrace implement its printf function?

0 votes
0 answers
44 views
the bpftrace language supports the function printf which can write something to the terminal, but as far as I know ebpf running in kernel mode cannot call arbitrary kernel functions, so how is that implemented? My rough guess is that bpftrace compile its printf function to bpf_trace_printk(which is a bpf helper being able to write formated text into TraceFS) and then the tracer process reads from /sys/kernel/tracing/trace_pipe to duplicate those text to stdout of the tracer process. But that routine would just be too slow.
Asked by 炸鱼薯条德里克 (1435 rep)
Dec 7, 2024, 01:33 AM
Last activity: Dec 7, 2024, 03:42 AM