Sorry, this entry is only available in 中文.
Deepin patches LoongArch kernel probe bug: two redundant assembly lines caused Loongson random freezes
Imagine this scenario...the system installation is halfway through, and the machine freezes without warning. Checking the serial logs, there are only a few scattered exceptions. That's the trouble with kernel issues—the moment of failure is fleeting, the clues left behind are contradictory, and the true root cause is hidden in a tiny, unremarkable execution path. Tracking it down is like finding a needle in a haystack. The deepin file manager provides a file indexing feature. The kernel module used for indexing instruments filesystem functions through the VFS kretprobe hook method, collecting the information needed for indexing during file access. Recently, when a large number of file operations were combined with kernel probes, a low-level defect on the LoongArch platform was triggered, causing the system to freeze during installation or when extracting large images. deepin developers spent nine consecutive days investigating this issue, ultimately pinpointing the root cause to the LoongArch kernel's rethook trampoline function incorrectly restoring the percpu base address, and verified the fix direction through targeted experiments. What follows is the practical process from discovering to fixing this kernel issue. The article is long but packed with useful information—please read patiently~ First, let's understand a few concepts LoongArch: The processor instruction set architecture adopted by The kernel must follow the register and runtime conventions defined by this architecture. percpuvariables: Data that each CPU core holds its own copy The kernel accesses the current core's data through operations like this_cpu_(), such as scheduler and RCU state, as well as timers and FPU state. The LoongArch kernel convention uses $r21 (also called $su0) to hold the current CPU's percpu base address. During kernel-mode execution, this register should always point to the current core's percpu area. kretprobe: A Linux kernel function return tracing mechanism that can execute handling logic when a traced function rethook: The kernel mechanism used to implement this type of return tracing, responsible for arranging callbacks and continuing the original function's return flow. To temporarily take over the function return, the kernel passes through a small ...Read more

中文