Linus Torvalds is now using AI to develop Linux kernel code
Linus Torvalds used AI on a Linux patch set to fix a page-cache bottleneck; gains are large, but reclamation and merge remain unresolved.
Key Takeaways
- Linus Torvalds published an experimental Linux kernel branch largely written with Anthropic’s Claude Code to address a long-standing page-cache bottleneck caused by many small file reads.
- The patches improve performance by deferring memory reuse until an RCU grace period passes, avoiding costly folio reference-count contention; in a narrow test, throughput rose from about 10 million to 30–33 million reads per second.
- The results are not a general claim that Linux is now three times faster: they apply to a specific multi-threaded 16-byte read workload on Torvalds’s personal laptop, and mainline performance has not changed yet.
- Important issues remain unresolved, including memory reclamation, a regression for unmapped user pages, and whether the branch will ever be merged into the mainline kernel.
- The experiment marks a significant shift for Torvalds and Linux development: he now uses AI to create kernel code, tests, and review materials, while still cautioning that AI must be used carefully for important work.
Linus Torvalds has published an eight-patch Linux kernel branch, largely written with Anthropic’s Claude Code, to address a page-cache slowdown that has remained unsolved since 2024. For many, it was the final step toward embracing AI for Linux development. This gives developers, maintainers, and Linux users a concrete account of what changed, how it was measured, and what remains unresolved. In his Git submission, Torvalds said the code, test programs, review, and first draft of the text were done with an LLM coding assistant under his direction.
The patches are on the branch noref-filemap-read-with-llm in Torvalds’s repository. They target a bottleneck that appears when multiple threads make small reads from the same file. Linux’s page cache stores file data in memory, and when several threads repeatedly read tiny amounts from a cached file, they must take and release references to the folio backing that data. Those reference-count updates require atomic writes to a shared cache line, forcing processor cores to compete for it.
Why a tiny read can stall a machine
The problem sounds narrow, but Torvalds measured a severe effect on a four-core, eight-thread Intel Core i7-8565U laptop. In one workload, eight threads issued 16-byte pread() calls against the same page. The shared cache line accounted for 99.92% of the measured cross-core load, according to Hit in Modified cache line (HITMs) data.
The proposed fix changes how the kernel reuses memory removed from the page cache. Instead of returning that memory to the allocator immediately, the patches defer reuse until a read-copy-update (RCU) grace period has elapsed. That allows a reader protected by an RCU read-side section to copy data directly into a user buffer without taking a folio reference.
The reported gains are large within that test. Eight-thread throughput rose from approximately 9.9–10.4 million reads per second to 30–33 million reads per second. Kernel cycles per read fell from roughly 2,950 to 725. Single-thread reads improved more modestly, from about 452–454 cycles to 408–409 cycles per read. Torvalds wrote in the pull request, or PR, that a machine with more CPUs, or more than one socket, should gain more, but nothing bigger has been measured.
That caveat matters. These are not results claiming that Linux as a whole runs three times faster. They describe an experimental small-read workload on Torvalds’s personal laptop, which he had with him in Prague at Linux Plumbers.
The trade-offs are not finished
The patches do not close the issue. Delaying memory reuse means pages can remain unavailable while the kernel waits for an RCU grace period. Torvalds called reclamation “the part of this series that is least solved.” There is also a regression when a read targets a user page that is not yet mapped: the new path incurs an additional failed exception before falling back to the existing implementation.
As of Oct. 13th, the branch remained outside the mainline Linux 7.3-rc6. Whether it will ever be merged, and on what timetable, is not settled. The known issue dates to 2024, and earlier attempts to fix it came to naught, so the new approach is a candidate rather than a completed solution.
Torvalds’s slow turn toward AI
Using Claude Code did not arrive out of nowhere. In December 2023, Torvalds described AI as a potential aid to developers and said he saw it as a tool that can help people be better at what they do. At that time, his interest was mainly in using AI to identify bugs, not to write serious programs.
By late 2025, he was calling himself a huge believer in AI as a tool. His focus had broadened from finding bugs to maintaining code and reviewing patches, while generating new serious Linux code was still largely off the table. In January 2026, he began toying with AI-assisted coding for a Python audio visualizer in a hobby project.
ZDNET has also quoted Torvalds saying, “I use AI to do the things that I’m bad at.” A related ZDNET survey reported that 75% of developers prefer Claude Code over Codex. Those comments show that the kernel experiment is part of a wider shift in how programmers treat AI assistants.
His remarks reported Oct. 9 after a conversation with Dirk Hohndel at Open Source Summit Europe in Prague were more enthusiastic. Torvalds said he used to think AI was not very good, but now he actually really likes using it. He added that AI can be a wonderful tool when used correctly and that it makes programming more enjoyable. He also cautioned that developers need to be very careful using AI when doing something real and important.
What the experiment still leaves to prove
The page-cache branch shows both sides of Torvalds’s position. Claude Code helped produce kernel code, tests, and review materials. The resulting benchmarks are promising for a specific small-read workload, but the memory-reclamation questions and the unmapped-page regression must be addressed before the experiment can become production kernel code.
For Linux users, the immediate practical effect is still unclear: mainline performance does not change yet. For maintainers, the story is more concrete. Torvalds, arguably the world’s foremost developer and maintainer, is now using AI to develop new Linux kernel code. That would have been unthinkable even a year ago. The question now is not whether AI can assist in kernel development, but whether this branch can be merged into Linux.

Comments (0)