Complete AI Training
Sign inGet my AI kit

Your job's AI kit

Get your AI kit

Tell us who you are and what you do. We show you your kit right away and email you the link: skills, prompts, AI agents, MCP servers and courses for your job.

500+ jobs ready, and we make a kit for any other job. No payment needed to look.

Share

AI news ·

Linus Torvalds uses Claude Code to triple Linux small-read throughput by reworking the page cache

Linus Torvalds reworked the Linux page cache to triple small-read throughput to over 30 million reads per second, crediting Anthropic's Claude Code as the primary author.

Linus Torvalds has pushed a branch to his own Linux repository that reworks the page cache and triples small-read throughput, crediting Anthropic's Claude Code as the primary author of the code, test programs, and even the cover letter draft. The branch, named noref-filemap-read-with-llm, targets a scalability bottleneck that Matthew Wilcox flagged from a customer workload in 2024. On Torvalds' laptop, eight threads hammering the same file with 16-byte reads jumped from roughly 10 million to over 30 million reads per second.

The work sits on top of Linux 7.3-rc6 and was spotted by Phoronix's Michael Larabel while waiting for the 7.3-rc7 tag. Torvalds rarely hosts topic branches in his main tree, which normally carries little more than master.

The cache line bottleneck

When multiple threads issue tiny reads against the same file, each read takes a reference on the folio backing that page and drops it afterward. Both steps are atomic writes to the same struct page cache line, forcing the line to bounce from core to core. On Torvalds' Core i7-8565U laptop, that single line accounted for 99.92% of the cross-core load HITMs.

Earlier attempts copied data into a stack buffer without a reference and validated it afterward, but those efforts stalled on races that validation cannot catch - such as a page being freed and reinserted at the same index.

Removing the race instead of detecting it

Torvalds took the opposite approach. A folio that leaves the page cache now goes back to the page allocator only after an RCU grace period. A reader inside an RCU read-side section can copy straight from the page into the user buffer without taking a reference, using no bounce buffer and imposing no limit on read size.

The numbers, all from a single 4-core, 8-thread laptop with mitigations disabled, tell a clear story. With eight threads on one file, kernel cycles per read fell from about 2,950 to roughly 725. Throughput climbed from 9.9-10.4 million to 30-33 million reads per second. Single-thread reads dropped from 452-454 cycles to 408-409. Load HITMs measured with perf c2c collapsed from 30,538 to 101.

The memory trade-off

Deferring frees means memory sits around waiting to be reused - exactly the objection Wilcox raised when the idea surfaced before. Torvalds concedes this is "the part of this series that is least solved." Two of the eight patches add a safety valve: once a CPU has more than 1,024 pages queued, a worker forces an expedited grace period and frees them.

In a 2 GiB VM stress test, the six-patch version let the OOM killer fire on 4 and 8 CPUs, while the full series ran to completion on 1, 2, 4, and 8. There is a regression, too. A read into a user page not yet mapped now takes one extra failed exception before falling back to the old path, pushing a 16-byte single-thread read from roughly 4,150 to 6,550 cycles.

Crediting the AI

The disclosure appears in a short "Tools" section near the end of the cover letter. Torvalds writes that the code, the test programs, the review behind his list of open problems, and the first draft of the letter itself came from Claude Code working under his direction. The benchmarks ran on his own machine. He has used AI for kernel debugging before, but crediting an agent with a memory-management series in his own tree marks a step further.

None of this is merged. The branch has been measured on exactly one laptop, and Torvalds openly flags pieces of the design he is unsure about. He expects bigger and multi-socket machines to gain more, though nothing larger has been tested. Whether it lands will depend on how the memory-management maintainers respond and whether someone with a many-core server is willing to rerun his numbers.

Why this matters for IT and development

This branch shows a kernel maintainer using an AI coding agent not for boilerplate or bug fixes, but for a core memory-management redesign - and crediting it publicly. For development teams, the takeaway is practical: the bottleneck was a single cache line bouncing across cores, and the fix removed the need for atomic reference counting on the hot path entirely. The pattern of deferring frees through RCU to eliminate synchronization is one that systems programmers working on high-concurrency data structures can apply directly. The memory trade-off and the regression on unmapped pages also serve as a concrete case study in measuring the full cost of a performance patch before merging.

Share