Kernel interrupt and lock

check latest kernel buildin kernel interrupt: https://www.cnblogs.com/aaronLinux/p/6341590.html timer: https://blog.csdn.net/njuitjf/article/details/108454786 locks: thread: BH context GFP_KERNEL/GFP_ATOMIC: spin_lock/spin_lock_bh rcu_read/write_lock RCU_INIT_POINTER()/rcu_access_pointer red-black tree..

How to compile llvm for BPF

My steps: 1 2 3 4 5 6 7 8 9 10 11 12 13 dnf install -y cmake ninja-build gcc gcc-c++ git clone https://github.com/llvm/llvm-project.git cd llvm-project/ git checkout -b llvmorg-13 llvmorg-13-init cd llvm/ mkdir build_13 cd $! cmake -G "Ninja" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \ -DLLVM_ENABLE_PROJECTS="clang" \ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr .. ninja -j20 ninja install clang -v Here is the message from Jesper (The commands I use listed below are indented, and not prefix with $ because it makes it easier to copy-paste into your cmdline.

Get start with XDP in 20m

The XDP(eXpress Data Path) is a powerful new network feature in Linux based on eBPF, that enables high-performance programmable access to networking packets before they enter the networking stack. But it also has a high start curve to learn, many developers have written introduction blogs for this feature. e.g. Paolo Abeni’s Using XDP in RHEL8 and Toke’s Using XDP in RHEL8. As the XDP is a new technology and is still in fast-moving.

map_in_map

This artical will talk about how to create map-in-map program. We need to create a outer map with type BPF_MAP_TYPE_ARRAY_OF_MAPS or BPF_MAP_TYPE_HASH_OF_MAPS. MAX_ENTRIES = 4 struct bpf_map_def SEC(“maps”) inner_map = { .type = BPF_MAP_TYPE_ARRAY, .key_size = sizeof(u32), .value_size = sizeof(int), .max_entries = MAX_ENTRIES, }; struct bpf_map_def SEC(“maps”) outer_map = { .type = BPF_MAP_TYPE_ARRAY_OF_MAPS, .key_size = sizeof(u32), .value_size = sizeof(u32), .max_entries = MAX_ENTRIES, }; In userspace program, we need: struct bpf_object_open_attr obj_open_attr = { .

xdp_pinning

iproute2 support setting pinning in maps. Here is an example about how to use it. Note that libbpf do not support setting pinning in map defination. So this way is not recommand. $ cat xdp_pin.c #include <uapi/linux/bpf.h> #include <bpf/bpf_helpers.h> struct bpf_elf_map { __u32 type; __u32 size_key; __u32 size_value; __u32 max_elem; __u32 flags; __u32 id; __u32 pinning; }; struct bpf_elf_map SEC(“maps”) xdp_pin_map = { .type = BPF_MAP_TYPE_PERCPU_HASH, .size_key = sizeof(__u64), .size_value = sizeof(__u64), .