Linus Torvalds Uses Claude Code to Speed Page Cache

Linux creator Linus Torvalds has used Anthropic’s Claude Code to develop an experimental patch series that addresses a longstanding performance bottleneck in the Linux kernel’s page cache. The experiment, documented in an October 10 commit titled “mm: read from the page cache without folio references,” consists of eight patches targeting how Linux reads data from its page cache. Reviewers have already found a race condition and raised memory-reclamation concerns.

AI-Assisted Kernel Development
“The code, the test programs, the review behind the list above and the first draft of this text were done with an LLM coding assistant (Claude Code) under my direction,” Torvalds wrote. Torvalds pushed a branch named noref-filemap-read-with-llm to his own repository. The work represents a significant experiment in using AI tools to tackle complex systems programming challenges at the kernel level.
According to the commit published in the Linux kernel Git repository, the eight-patch series sits on Linux 7.3-rc6. Phoronix spotted it while the kernel awaited the Linux 7.3-rc7 tag.
The Performance Problem
Under the existing implementation, reading cached data requires updating reference counters, which can create contention when several threads repeatedly access the same file. When many threads make small reads of the same cached file, each read takes a reference on the backing folio and drops it afterward. These atomic writes hit one cache line, so the line bounces between CPU cores.

In eight-thread tests on Torvalds’ Core i7-8565U laptop, folio reference-count contention accounted for 99.92% of cross-core load HITMs. A folio represents one or more memory pages managed together in the kernel’s memory subsystem.
The Solution Using RCU
To address this, the experimental patches use the kernel’s Read-Copy-Update mechanism to allow certain reads without acquiring additional page references. Instead of taking references, the proposed read path relies on read-copy-update, or RCU, to prevent premature memory reuse. Folios removed from the page cache return to the allocator only after an RCU grace period, allowing protected readers to copy cached data directly into userspace.

Missing pages, incomplete data, user-buffer faults, and other conditions trigger fallback to the existing read path. This approach aims to eliminate races that earlier reference-free designs attempted to detect after copying. Those designs could miss memory being freed, reused, and reinserted at the same cache index.
Performance Gains
The initial benchmarks show substantial improvements in throughput. On Torvalds’ laptop, with an Intel Core i7-8565U processor having four cores and eight threads, a benchmark with eight threads repeatedly reading 16 bytes from the same cached file improved from about 10 million reads per second to between 30 million and 33 million.

With four threads on separate CPU cores, throughput increased from roughly 9–12 million reads per second to 25–26 million. These results demonstrate the magnitude of performance penalty caused by the reference-counting contention in highly concurrent workloads.
Memory Reclamation Trade-offs
The optimization introduces a trade-off in memory management. The cost is that freed memory sits idle briefly before reuse. Two patches add a safety valve that forces an expedited grace period once a CPU has more than 1,024 pages queued. This mechanism prevents excessive memory from sitting in a deferred state while waiting for RCU grace periods to complete.

Experimental Status and Review Concerns
The patch series remains experimental and has not been merged into the mainline kernel. Kernel developers reviewing the code have identified potential issues that need to be addressed before the patches could be considered for inclusion in a stable release.
The experimental nature is reflected in the branch name itself, which explicitly references the use of an LLM in development. This transparency allows other kernel developers to understand the provenance of the code and apply appropriate scrutiny during the review process.
Implications for Kernel Development
The use of AI coding assistants by Linus Torvalds himself represents a notable milestone in kernel development practices. While Torvalds directed the work and ran the measurements on his own hardware, Claude Code handled significant portions of the implementation, test program creation, and initial documentation.
The patches target a specific but important use case where many threads read small amounts of data from the same cached file concurrently. This pattern appears in various real-world scenarios, including database workloads, web server applications, and multi-threaded data processing systems.
Key Facts
- Linus Torvalds used Claude Code to develop an eight-patch series addressing Linux kernel page cache contention
- The patches were documented in an October 10, 2026 commit on the noref-filemap-read-with-llm branch
- Benchmarks showed read throughput increased from approximately 10 million to 30-33 million reads per second on an eight-thread test
- The patches sit on Linux 7.3-rc6 and remain experimental
- Reviewers have identified concerns including a race condition and memory reclamation issues
- The solution uses RCU (Read-Copy-Update) to eliminate reference-counting contention
Sources
- GBHackers – Claude Code Helps Linux Creator Address Longstanding Kernel Memory Performance Bottleneck
- Cyber Press – Linus Torvalds Uses Claude Code to Boost Linux Kernel File Read Performance
- Linuxiac – Linus Torvalds Experiments with AI-Generated Kernel Code
- Startup Fortune – Linus Torvalds used Claude Code to rewrite how Linux reads cached files
Sources
- Linus Torvalds Experiments with AI-Generated Kernel Code, Sees 3x Speedup
- Claude Code Helps Linux Creator Address Longstanding Kernel Memory Performance Bottleneck
- Linus Torvalds used Claude Code to rewrite how Linux reads cached files – Startup Fortune
- Linus Torvalds Uses Claude Code to Boost Linux Kernel File Read Performance





