GithubHelp home page GithubHelp logo

doytsujin / bpf-ringbuf-examples Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anakryiko/bpf-ringbuf-examples

0.0 1.0 0.0 711 KB

Examples of using BPF ring buffer APIs

License: BSD 3-Clause "New" or "Revised" License

Makefile 14.61% C 85.39%

bpf-ringbuf-examples's Introduction

About

This is a collection of examples showing the usage of BPF ringbuf and perfbuf APIs. Each example implements a simple tracing tool, collecting all exec() syscalls, which correspond to starting a new processes:

  • perfbuf-output uses BPF perfbuf and bpf_perf_event_output() API;
  • ringbuf-output uses BPF ringbuf and bpf_ringbuf_output() API, very similar to the one provided by BPF perfbuf;
  • ringbuf-reserve-commit shows off a distinct BPF ringbuf's bpf_ringbuf_reserve()/bpf_ringbuf_submit() pair of APIs, which provide better usability and performance, compared to the xxx_output() APIs.

These examples are a companion to the BPF ring buffer blog post.

Building & running

This repo is using libbpf through submodule at libbpf/. It also has a copy of bpftool binary (built fro x86-64 platform), which is used to generate BPF skeleton for .bpf.c files. These examples do not rely on BPF CO-RE and thus there are no extra requirements on Linux kernel, beyond some reasonably recent version for BPF perfbuf version, while BPF ringbuf examples need 5.8+ kernels.

Otherwise, everything is super straightforward:

$ git submodule update --init --recursive       # check out libbpf
$ cd src
$ make
$ sudo ./ringbuf-reserve-commit    # or ./ringbuf-output, or ./perfbuf-output
TIME     EVENT PID     COMM             FILENAME
19:17:39 EXEC  3232062 sh               /bin/sh
19:17:39 EXEC  3232062 timeout          /usr/bin/timeout
19:17:39 EXEC  3232063 ipmitool         /usr/bin/ipmitool
19:17:39 EXEC  3232065 env              /usr/bin/env
19:17:39 EXEC  3232066 env              /usr/bin/env
19:17:39 EXEC  3232065 timeout          /bin/timeout
19:17:39 EXEC  3232066 timeout          /bin/timeout
19:17:39 EXEC  3232067 sh               /bin/sh
19:17:39 EXEC  3232068 sh               /bin/sh
^C

bpf-ringbuf-examples's People

Contributors

anakryiko avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.