Linus Torvalds Uses AI to Write Linux Kernel Code

Linux creator embraces Claude Code to fix persistent performance bottlenecks, marking a major shift in open-source development.

GeoDetect PipelineOctober 15, 2026
Share
Article cover image

Overview

Linus Torvalds has officially confirmed that he utilized artificial intelligence to draft code for the Linux kernel, marking a significant milestone in the relationship between open-source development and generative AI tools. The Linux creator and maintainer disclosed in a recent Git submission that an LLM coding assistant, specifically Anthropic’s Claude Code, was instrumental in generating a set of patches addressing a long-standing performance bottleneck.

This announcement represents the culmination of a gradual shift in Torvalds’ perspective, moving from cautious skepticism to active adoption of AI as a practical utility for software engineering. The eight-patch series, published on a dedicated branch within his repository, targets a specific contention issue in the page cache that degrades performance when multiple threads perform small, concurrent reads from the same file.

“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.” — Linus Torvalds, Git submission

While the initial results are promising, Torvalds emphasized that the solution involves complex trade-offs and remains a work in progress. The patches have not yet been merged into the mainline kernel, and several engineering challenges related to memory management and potential regressions still need to be resolved before the changes can be considered production-ready.

The Technical Problem: Shared Cache Line Contention

The primary motivation behind this effort is a performance degradation known as a shared-memory bottleneck. When multiple threads repeatedly read small amounts of data from the same cached file, they frequently acquire and release references to the folio backing that data. These operations require atomic writes to a shared cache line, forcing different processor cores to compete for access and creating a significant serialization overhead.

In typical computing scenarios, this issue might seem minor. However, in specific workloads characterized by high volumes of tiny reads, the impact is severe. During testing on a four-core, eight-thread Intel Core i7-8565U laptop, Torvalds observed that the shared cache line accounted for 99.92% of the measured cross-core load. This extreme level of contention effectively stalls parallel processing, turning what should be a multi-core advantage into a serialized drag on performance.

This is not a newly discovered flaw but a known issue that has persisted since 2024. Earlier attempts by the kernel community to resolve the contention through various synchronization mechanisms have largely failed to provide an efficient, scalable solution. The problem highlights the delicate balance between memory safety, concurrency control, and raw speed in modern operating system design.

Performance Benchmarks

The proposed patches demonstrate substantial improvements in throughput for the specific test case. By altering how the kernel handles memory references during reads, the eight-thread throughput increased from approximately 9.9–10.4 million reads per second to 30–33 million reads per second. Furthermore, kernel cycles per read dropped from roughly 2,950 to 725, indicating a dramatic reduction in computational overhead.

Single-thread performance also saw modest gains, improving from about 452–454 cycles per read to 408–409 cycles. Torvalds noted in his pull request that machines with more CPUs or multiple sockets would likely see even greater benefits, although he cautioned that such larger-scale benchmarks had not yet been conducted.

It is important to contextualize these numbers. The results reflect experimental data from a particular small-read workload on Torvalds’ personal laptop, which he used while attending the Linux Plumbers Conference in Prague. They do not imply that Linux as a whole will run three times faster across all use cases, but they do validate the effectiveness of the approach for this specific class of contention-heavy tasks.

The AI-Assisted Solution

The core of the fix lies in deferring memory reuse. Instead of immediately returning memory removed from the page cache to the allocator, the new patches delay this action until a read-copy-update (RCU) grace period has elapsed. This allows readers protected by an RCU read-side section to copy data directly into a user buffer without needing to take a folio reference, thereby eliminating the need for atomic updates to the shared reference counter.

This approach trades immediate memory reclamation for a read path that avoids the expensive synchronization overhead. By removing the need for constant reference-count updates, the kernel can process reads more efficiently across multiple cores. Torvalds collaborated with Claude Code to develop this logic, leveraging the AI tool to generate the initial drafts of the code, test programs, and documentation.

The integration of AI into this process was not a sudden departure for Torvalds but rather the latest step in an evolving workflow. He used the assistant to explore creative solutions to a stubborn problem, effectively using AI as a collaborative partner rather than a replacement for human judgment. The patches remained under his direct supervision, with the AI handling the tedious drafting while Torvalds directed the architectural strategy.

From Skeptic to Advocate

Torvalds’ embrace of AI coding assistants reflects a broader evolution in his attitude toward the technology. In late 2023, he described AI as a potential aid for identifying bugs, though he remained unconvinced about its ability to write serious code. By late 2025, he had become a “huge believer” in AI as a tool for maintaining code and reviewing patches, though generating new kernel code was still considered off-limits.

His stance continued to soften throughout early 2026, when he began experimenting with AI-assisted coding for a Python audio visualizer in a hobby project. This personal exploration paved the way for his professional adoption of Claude Code for kernel development. During a conversation with Dirk Hohndel at Open Source Summit Europe, Torvalds expressed genuine enthusiasm for the technology.

“I used to think it was just not very good — but now I’m at the point where I actually really like using AI. I think AI is a wonderful tool if you use it correctly and treat it as a tool, and I find it makes programming much more enjoyable.” — Linus Torvalds

Despite his positive remarks, Torvalds offered caveats about the responsible use of AI. He stressed that developers must treat these tools as assistants rather than autonomous agents, maintaining strict oversight over the code they produce. The goal is to enhance productivity and enjoyment without compromising the rigor and reliability expected in critical infrastructure like the Linux kernel.

Current Status and Future Outlook

As of mid-October 2026, the eight-patch series remains on the noref-filemap-read-with-llm branch and has not been merged into the mainline Linux 7.3-rc6 release. Torvalds acknowledged that the solution is not yet complete, describing the memory reclamation aspect as “the part of this series that is least solved.”

The deferral of memory reuse means that pages may remain unavailable while the kernel waits for the RCU grace period to finish. This introduces potential latency issues in memory-constrained environments. Additionally, there is a known regression when a read targets a user page that is not yet mapped, resulting in an additional failed exception before falling back to the existing implementation.

Whether these issues will be resolved in time for an upcoming kernel release remains uncertain. The Linux kernel development process is rigorous, and any changes affecting core memory management undergo intense scrutiny. While the AI-assisted approach has yielded promising performance gains, the community must weigh these benefits against the introduced complexity and potential stability risks.

For now, this initiative stands as a proof of concept: AI can assist in solving deep, low-level systems programming problems. As the patches are refined and tested, they may eventually become a standard part of the Linux memory management subsystem, setting a precedent for how AI tools are integrated into open-source development workflows.

Share

Sources

Tools mentioned