Linus Torvalds Employs Claude Code to Optimize Linux Kernel Page Cache
Experimental patch series uses AI assistance to resolve cross-core lock contention.
1AI Enters Kernel Development
Linus Torvalds submitted an experimental eight-patch series to his repository, developed alongside the Claude Code LLM assistant. The submission marks a significant milestone where AI generated kernel code, test programs, review documentation, and initial submission drafts directly under Torvalds's supervision for Linux core systems.
2Targeting Page Cache Contention
The patch series addresses memory bottleneck issues in the Linux page cache. When concurrent threads repeatedly execute small reads against the same cached file, atomic reference-count updates on the backing folio force processor cores to compete aggressively over a single shared cache line, degrading system throughput.
3Quantifying Multi-Threaded Friction
Benchmarking an eight-thread workload issuing 16-byte pread calls on an Intel Core i7 processor revealed severe degradation. The shared cache line generated 99.92% of cross-core load based on Hit in Modified cache line metrics, confirming that cache-line contention severely hindered multi-threaded scaling.
4RCU Grace Period Architecture
The proposed solution alters kernel memory reuse timing by deferring deallocation until a read-copy-update grace period finishes. This mechanism allows readers inside an RCU section to copy cached data directly into user buffers, avoiding repeated, expensive updates to shared folio reference counters across active threads.
5Measured Throughput and Cycle Gains
In synthetic benchmarks, eight-thread throughput surged from roughly 10 million reads per second to over 30 million. Execution cycles per read dropped from 2,950 down to 725 cycles, while single-thread latency showed minor improvements from around 453 to 408 processor cycles per operation.
6Memory Reclamation Trade-Offs
The performance leap introduces distinct architectural trade-offs that prevent immediate mainline merging. Delaying page reuse leaves memory temporarily unavailable during RCU grace periods. Torvalds explicitly flagged this delayed reclamation strategy as the least resolved engineering problem within the experimental patch sequence.
7Unmapped Page Latency Regression
An additional technical hurdle involves reads targeting unmapped user memory pages. The new execution path triggers an extra failed exception before falling back to legacy kernel paths. Consequently, the experimental branch remains isolated from mainline Linux 7.3-rc6 pending further structural refinement and review.
8Evolution of Torvalds's AI Stance
Torvalds previously viewed AI strictly as a bug-finding utility, but his stance evolved into active co-development. While praising AI for improving development workflows, he maintains strict boundaries, emphasizing that deep human oversight remains vital when modifying critical infrastructure like core operating system kernels.