iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.36k stars 3.86k forks source link

use perf_event in XDP program #4847

Open CiZ01 opened 9 months ago

CiZ01 commented 9 months ago

hello everyone, I am trying to retrieve some information from hardware registers such as the number of cpu cycles (cache misses and others) of a portion of XDP code.

The goal I would like to achieve is similar to this:

/* of the code */

START TRACING
/* code to be traced */
STOP TRACING.

/*other code*/

But my problem is how to retrieve the data I need.

I have seen various examples and tests using BPF_PERF_ARRAY, but what I understand is that it cannot be used in XDP, right?

I saw from the ebpf documentation some useful helpers for my purpose but I wouldn't know how to use them in BCC considering that they take a map as parameter.

Any advice would be really appreciated! Thanks