Yovao News · The World, In Focus. From Local to Global, Never Miss a Beat

Linus Torvalds Adopts AI to Write Linux Kernel Patches

Linus Torvalds Adopts AI to Write Linux Kernel Patches

Linus Torvalds, the visionary behind the Linux kernel, has officially confirmed that he utilized artificial intelligence to generate code for a recent kernel patch. The submission, which tackles a persistent performance issue related to shared-memory bottlenecks, was largely drafted using Anthropic’s Claude Code, signaling a definitive step in Torvalds’ evolving relationship with AI tools.

In his Git commit message, Torvalds disclosed the assistance, stating, “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.” This disclosure follows a gradual softening in his stance over the past few years, moving from broad skepticism to recognizing AI as a practical utility for programmers and maintainers.

The patch addresses a known contention problem within Linux’s page cache, which stores file data in memory. When multiple threads repeatedly access small data segments from the same cached file, they trigger atomic reference-count updates on shared cache lines. This competition can significantly degrade performance. In testing on a four-core, eight-thread Intel Core i7-8565U laptop, Torvalds observed that this shared cache line contention accounted for 99.92% of cross-core load during 16-byte pread() calls.

To resolve this, the proposed patches modify when the kernel can reuse memory removed from the page cache. Instead of immediate reclamation, the system now defers reuse until a read-copy-update (RCU) grace period expires. This allows readers protected by RCU sections to copy data directly into user buffers without acquiring folio references, effectively trading immediate memory reclamation for a more efficient read path.

The performance improvements in this specific workload are notable. Throughput for eight-thread operations increased from approximately 9.9–10.4 million reads per second to 30–33 million, while kernel cycles per read dropped from roughly 2,950 to 725. Torvalds noted in his pull request that systems with more CPUs or multiple sockets are expected to see even greater gains, though he cautioned that these results stem from experimental benchmarks on a personal laptop rather than a guarantee that the entire Linux operating system will run three times faster.

Despite the promising benchmarks, the solution is not yet finalized. Torvalds admitted that memory reclamation remains “the part of this series that is least solved,” as delaying reuse can leave pages unavailable while the kernel waits for RCU periods. Additionally, the new path introduces a regression when reading unmapped user pages, resulting in an extra failed exception before falling back to existing methods. As of October 13, the branch had not been merged into the mainline Linux 7.3-rc6 release, and its future inclusion remains uncertain.

This development represents a culmination of Torvalds’ gradual acceptance of AI. In December 2023, he viewed AI primarily as a tool for bug identification. By late 2025, he expressed strong belief in AI for code maintenance and review, though generating serious code was still considered off-limits. His perspective shifted further in January 2026 when he began experimenting with AI-assisted coding on a personal Python project.

Following a discussion at Open Source Summit Europe in Prague, Torvalds described his current 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,” he said. “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.” However, he also warned developers to exercise extreme caution when applying AI to critical infrastructure, a caveat clearly illustrated by the unresolved engineering trade-offs in this kernel patch.

Leave a Reply

Your email address will not be published. Required fields are marked *