lac-dcc/honey-potion

Remove deprecated functions from benchmarks.

Closed this issue · 3 comments

As it stands we use a deprecated function bpf_prog_load_xattr to open and load our benchmarks. This deprecated version does not exist in newer versions of Libbpf (exists on 0.8 but not on 1.1). The objective is to make our project compliant with the 1.1 version, so we need to substitute that function for the new counterpart. After this change we will have most if not all of the project compliant with the newer versions of Libbpf, helping us to solve issue #34.

Currently all deprecated functions with the exception of bpf_perf_event_read_simple in xdpdump have been updated with newer versions that maintain the same functionality. This currently lies in the RmDeprecatedFunc branch and will be merged into master soon.

Substituting bpf_perf_event_read_simple has been harder than expected and has lead to many dead ends. I shall describe here what attempts I have made made so that others don't repeat my mistakes.

  1. bpf_perf_event_read_simple was called in the front-end file. The front-end has to include libbpf.h for the functions to do many of the steps to load and attach the programs. libbpf.h has a conflict with bpf_helpers.h, which is used in the back-end. This halted research in the solution of using functions like bpf_perf_event_read or bpf_perf_event_read_value, as those are located in bpf_helpers.h
  2. We were given an example from ChatGPT that used the library bpf_perf.h to get the bpf_perf_event_read to the front-end. Sadly, the only instance of bpf_perf.h I could find was by cloning git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git with a depth of 1, and that instance does not contain any function of the type of bpf_perf_... (or any function at all). The file can be found in linux/tools/lib/perf/include/perf.

And here are some information sources that may provide useful for whomever tackles this issue next:

  1. The only relevant information about bpf_perf_event_read_simple is located in this issue. It's implicit from it that perf_buffer__poll and perf_buffer__consume may be replacements for the functionality of bpf_perf_event_read_simple, however they don't seem as easy to use.
  2. The documentation of what bpf_perf_event_read_value can do is found in this link and seems to be a good substitute. Sadly, it seems like that function was made to operate in the back-end of LIBBPF, not the front-end.

Substituting bpf_perf_event_read_simple has been harder than expected and has lead to many dead ends. I shall describe here what attempts I have made made so that others don't repeat my mistakes.

  1. bpf_perf_event_read_simple was called in the front-end file. The front-end has to include libbpf.h for the functions to do many of the steps to load and attach the programs. libbpf.h has a conflict with bpf_helpers.h, which is used in the back-end. This halted research in the solution of using functions like bpf_perf_event_read or bpf_perf_event_read_value, as those are located in bpf_helpers.h
  2. We were given an example from ChatGPT that used the library bpf_perf.h to get the bpf_perf_event_read to the front-end. Sadly, the only instance of bpf_perf.h I could find was by cloning git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git with a depth of 1, and that instance does not contain any function of the type of bpf_perf_... (or any function at all). The file can be found in linux/tools/lib/perf/include/perf.

And here are some information sources that may provide useful for whomever tackles this issue next:

  1. The only relevant information about bpf_perf_event_read_simple is located in this issue. It's implicit from it that perf_buffer__poll and perf_buffer__consume may be replacements for the functionality of bpf_perf_event_read_simple, however they don't seem as easy to use.
  2. The documentation of what bpf_perf_event_read_value can do is found in this link and seems to be a good substitute. Sadly, it seems like that function was made to operate in the back-end of LIBBPF, not the front-end.

I've replaced bpf_perf_event_read_simple with perf_buffer__new, following the example of xdp_sample_pkts_user.c.