TLDRocket
Sign in

Linus Torvalds let Claude Code fix the Linux page cache. Then reviewers found a race.

The New Stack Amanda Caswell

Torvalds used Claude Code on a Linux page-cache fix and got a huge speedup. Reviewers then found a race and memory-reclaim worries.

Based on reporting by The New Stack, Amanda Caswell — read the original for the full story.

Summary, retelling and take written by AI under human oversight; images are AI-generated illustrations. How we work · Report an error

Linus Torvalds tried Anthropic’s Claude Code on a Linux kernel bottleneck that had been bothering developers for more than two years. The result was a 10-patch series that, on his Ryzen Threadripper, pushed a synthetic benchmark up 23-fold. That’s the headline. The fine print is less tidy: reviewers quickly spotted a race condition, and memory reclamation is still under debate.

The target was page-cache reference-count contention, a problem that has been especially ugly in buffered reads. Torvalds had already spent 18 months running a broken version of his own fix, and other developers had hit trouble with their attempts too. On his Core i7-8565U laptop, Hardware Busters reported that folio reference-count contention accounted for 99.92% of cross-core load HITMs in eight-thread tests. Matthew Wilcox, the Oracle engineer who flagged the bottleneck in 2024 after seeing it in a customer workload, was already on the case before Claude entered the picture.

Torvalds’ tree briefly showed an experimental branch called noref-filemap-read-with-llm, which Phoronix spotted on Sunday. Torvalds said Claude Code wrote the implementation, the tests, and the first draft of the documentation, while he reviewed it and ran the benchmarks himself. That’s awkward for anyone who liked mocking AI-generated code as a cheap party trick. The patches are not magic, though. They remove folio reference-count operations from a common buffered-read path, and Torvalds himself warned that the real-world gains would be smaller than the benchmark numbers suggest.

The technical shape changed between the earlier and later versions. The newer rcu-free-v3 series uses a PG_rcu_free flag and RCU-delayed reclamation to keep a folio protected through userspace copy, so long as the copy doesn’t fault. On Torvalds’ Threadripper, that version took throughput from 13.3 million reads per second to 304 million, while cycles per read fell from nearly 20,000 to 735. But the first design had trade-offs, including an expedited grace period after 1,024 queued pages and a slower path for reads into unmapped user pages.

Wilcox pushed back on the new flag and wanted a page type instead, plus RCU grace-period reclamation for inactive-list folios. Torvalds rejected that route, and Kiryl Shutsemau — now carrying the next round — later found a race in filemap_read_rcu_batch() that could expose data never written if folio replacement lined up badly with an i_size extension. Torvalds suggested moving the file-size read earlier and tightening the folio checks, and Shutsemau folded that into a revised patch.

My take — AI-written commentary, not fact-checked reporting

This is the Linux way: heroic performance work, then a reviewer walks in and finds the trapdoor. Claude Code may have written the patch, but the real authorship still belongs to the people willing to argue over races, grace periods, and the parts nobody wants to benchmark. AI can draft code; it still can’t replace kernel paranoia, which is probably for the best.

Read more about this at: The New Stack

Related stories

The daily briefing

Every AI story that matters, in your inbox by 8am.

TLDRocket reads all relevant sources, removes duplicate coverage, and summarises the day in two minutes. Follow companies and topics for alerts, or get the briefing in Slack. Free, no spam, unsubscribe anytime.