Use bpftrace for debugging - An example

Introduction bpftrace is a high-level tracing language for Linux enhanced Berkeley Packet Filter (eBPF). I found it very useful for debugging issues as well as understanding kernel code. In this post, I will use one example to demonstrate how I used bpftrace for debugging. [Read More]
Tags: BPF

An Invalid bpf_context Access Bug

I got an interesting issue while debugging a BPF program. The BPF program couldn’t be loaded because of an “invalid memory access” error. Though the access was completely within the valid memory boundary, the verifier was still not happy about it. [Read More]
Tags: Linux BPF

My First Kernel Patch

Summary Recently, I submitted my first kernel patch. I will note down the basic workflow of submitting code to kernel in this post. This folder contains more detailed instructions on how to become a kernel developer. My note will only contain minimal steps for a noob like me. [Read More]
Tags: Linux Kernel

Set up OfflineIMAP + Mutt on Mac

Summary Recently, I submitted my first kernel patch. One of the lessons I learned is that kernel mail server doesn’t accept HTML content in emails. To make sure my email contains absolutely no HTML, I set up a text-based email client (Mutt + OfflineIMAP) on my laptop. This post is... [Read More]
Tags: Tool Mac

Use Map-in-Map in BPF programs via Libbpf

Introduction Among all BPF map types, two special ones, BPF_MAP_TYPE_ARRAY_OF_MAPS and BPF_MAP_TYPE_HASH_OF_MAPS, are more complex than others. As the names imply, they are “map-in-map”, meaning that the value of each entry is also a map. [Read More]
Tags: BPF libbpf

Always Use always_inline In BPF Programs

TL;DR Recently, I solved a tricky bug in a BPF program. Because inline instead of always_inline was used to declare a function, when the function body grew big, the compiler decided to not inline it. Then the BPF program was not able to be loaded due to some verification error.... [Read More]
Tags: BPF