Lifecycle of proc fd files

July 1, 2023

The fd files under /proc/<pid>/fd/ are created when a user reads or lists the fd files, not when the actual files are opened. The inode of a fd file is not deleted when the file is closed. This inode is disconnected with the closed file and stays in the VFS dcache.

read more

Malloc in glibc

November 23, 2020

I went through glibc malloc code when troubleshooting a segfault. Here are some notes on the malloc code.

read more

Kubernetes CPU requests explained

July 25, 2020

Requesting CPU resource in a pod spec does not guarantee the requested CPU for a container. The only way to guarantee this is to use "static CPU manager policy" and exclusively allocate CPUs to the container.

read more

Linux CFS and task group

April 27, 2020

I dived into the kernel scheduler code under kernel/sched/ to understand how CFS works and how the task group cpu.shares value is used in CFS.

read more

Network timeouts

November 17, 2019

Many changes in distributed systems could cause network related timeouts. TCP/IP provides plenty of feedbacks for different kinds of network errors. If we use these feedbacks properly, we could get rid of many network timeouts.

read more

Mis-Understanding Rust lifetime

September 28, 2019

Rust ownership and lifetime are very powerful tools. They were designed to help compiler get better optimization. As a side effect, they could force programmers to write cleaner code, even design better interfaces. Here are some theories and examples that may help understanding lifetimes. Disclaimer: I didn't read the compiler code so I could be wrong.

read more

Workaround for a bpf verifier error

August 29, 2019

Linux bpf verifier allows only one specific pattern for accessing skb data. To help the clang compiler generate the required access pattern, we have to write C code in a certain way to reflect this pattern.

read more

Linux bpf map internals

August 3, 2019

Linux bpf maps are used to share data among bpf programs and user applications. A bpf map could be created by simply declaring a bpf_elf_map struct. Under the hood, lots of things work together to set up the maps.

read more

resolv.conf for nameservers with a virtual IP

July 18, 2019

The file /etc/resolv.conf defines nameservers for glibc. Normally this file contains 2 or 3 nameservers for redundancy. When several nameservers serve behind one virtual IP, it is still better to have multiple (max 3) duplicated entries than having just one virtual IP entry in /etc/resolv.conf.

read more

TCP sequence number and 3-way handshake

June 26, 2019

One challenge of TCP is to handle stale packets. Packets from previous connections may get delayed in the network and interfere with new connections. To solve this problem, TCP enforces the following rule on sequence numbers.

read more