Claude Code Helps Linux Creator Address Longstanding Kernel Memory Performance Bottleneck
Linus Torvalds used Claude Code to draft unmerged Linux patches that avoid page-cache reference-count contention.
Linus Torvalds used Anthropic’s Claude Code to draft an experimental Linux patch series, “mm: read from the page cache without folio references,” aimed at page-cache scalability. On his Core i7-8565U, folio reference-count contention accounted for 99.92% of cross-core load HITMs in an eight-thread synthetic test. The unmerged work uses RCU so readers can copy cached data without taking references, deferring memory reuse. Reviewers later found a race in filemap_read_rcu_batch() that could expose never-written data; no CVE or exploitation was reported.
- Unmerged eight-patch series sits on Linux 7.3-rc6 in Torvalds’ repository.
- Synthetic tests blamed 99.92% of cross-core HITMs on folio reference counts.
- RCU lets readers copy cached file data without taking a folio reference.
- Reviewers found a race that could expose data never written to the file.
- No CVE was assigned; revised patches are still under human review.
Full article460 words · extracted from gbhackers.com · click to collapse
Linus Torvalds used Anthropic’s Claude Code to build experimental patches that remove a long-running page-cache scalability bottleneck in the Linux kernel.
The series is not merged. Reviewers have already found a race condition and raised memory-reclamation concerns.
Torvalds pushed a branch named noref-filemap-read-with-llm to his own repository. Phoronix spotted it while the kernel awaited the Linux 7.3-rc7 tag.
Claude Code Helps Fix Linux Kernel Memory Bottleneck
According to the commit published in the Linux kernel Git repository, the eight-patch series sits on Linux 7.3-rc6. It was documented in a commit titled “mm: read from the page cache without folio references.” linuxiac
Torvalds wrote that the code, test programs, review and first draft of the text were done with an LLM coding assistant under his direction. He added that the measurements were run on his machine.
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.
The patches use Read-Copy-Update (RCU). A folio leaving the page cache returns to the allocator only after an RCU grace period. A reader inside an RCU read-side section can therefore copy data straight into the user buffer without taking a reference. zdnet
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. Torvalds called the deferred freeing “the part of this series that is least solved.”
Torvalds warned that real-world gains would be much smaller than the synthetic benchmark suggests. Reads into unmapped user pages also triggered an extra fault, raising a 16-byte single-thread read from about 4,150 to 6,550 cycles. thenewstack
A later 10-patch series, rcu-free-v3, introduced a PG_rcu_free flag and RCU-delayed reclamation. Reviewers then identified a race in filemap_read_rcu_batch(). Folio replacement followed by an extension of i_size could expose data that had never been written. thenewstack
Torvalds suggested reading the file size earlier and consolidating the folio checks. Kiryl Shutsemau, who had worked on the same bottleneck, folded those changes into a revised patch and now carries the work forward. thenewstack
No CVE has been assigned, and none of the sources describe an exploited flaw. The episode matters to defenders because the changes touch memory lifetime and reclamation.
Bugs in that area, such as use-after-free and stale-data exposure, have historically carried security impact. AI-written kernel code therefore still needs the same rigorous human review as any other patch.
Phoronix noted the work could target the Linux kernel 7.4 merge window, though integration remains unresolved.