Christian Brauner of Microsoft began sending out his various pull requests today of new material for the Linux 6.14 kernel in advance of the merge window expected to open next week. One of the interesting pull requests is carrying the work of Omar Sandoval for faster /proc/kcore reads that can help with debugger performance.
Back in November I originally brought up the tentative patches at the time around Linux kernel optimizations for speeding-up debuggers reading /proc/kcore. That work has now crossed the finish line and has been submitted for pulling by Linus Torvalds into the Linux 6.14 kernel.
Christian Brauner explains in the pull request:
“The performance of /proc/kcore reads has been showing up as a bottleneck for the drgn debugger. drgn scripts often spend ~25% of their time in the kernel reading from /proc/kcore.
A lot of this overhead comes from silly inefficiencies. This pull request contains fixes for the low-hanging fruit. The fixes are all fairly small and straightforward. The result is a 25% improvement in read latency in micro-benchmarks (from ~235 nanoseconds to ~175) and a 15% improvement in execution time for real-world drgn scripts:
– Make /proc/kcore entry permanent.
– Avoid walking the list on every read.
– Use percpu_rw_semaphore for kclist_lock.
– Make Omar Sandoval the official maintainer for /proc/kcore.”
More details via this pull request.
Drgn is the programmable debugger developed by Meta that can allow using Python scripts for debugging the Linux kernel and more. More details on Drgn can be found via the GitHub project site.