Linus Torvalds Uses AI for Linux Kernel Patches: 3x Read Throughput, Unresolved Memory Issues

Linus Torvalds employed Claude Code to create an 8-patch series that removes a page-cache contention bottleneck for tiny concurrent reads, boosting 8-thread throughput from ~10M to ~32M reads/sec on a laptop, but the patches delay memory reuse via RCU grace periods and still have regressions, leaving them unmerged as of October 2024.

21CTO
21CTO
21CTO
Linus Torvalds Uses AI for Linux Kernel Patches: 3x Read Throughput, Unresolved Memory Issues

Problem: Page-Cache Contention on Small Reads

When multiple threads repeatedly read small chunks (e.g., 16-byte pread() calls) from the same cached file, the Linux page cache incurs heavy contention. Each read takes and drops a reference on the underlying page, requiring atomic updates to a shared reference counter. On a quad-core, eight-thread Intel Core i7-8565U laptop, HITM (modified cache-line hit) metrics showed that 99.92% of cross-core traffic came from bouncing this single cache line.

The issue was first highlighted in 2024 by Matthew Wilcox, who reported a customer workload suffering from it. Earlier fix attempts had failed.

Solution: Delay Page Reuse Until RCU Grace Period

Torvalds personally measured the bottleneck, then directed Claude Code to produce a patch series (branch noref-filemap-read-with-llm). The core idea: instead of immediately returning a page to the allocator after the last reference drops, keep the page alive until an RCU (read-copy-update) grace period elapses. RCU-protected readers can then copy data directly into user buffers without taking a page reference at all, eliminating the atomic refcount updates on the hot cache line.

Performance Results

8-thread workload : throughput rose from ~9.9–10.4 million reads/sec to ~30–33 million reads/sec; kernel cycles per read fell from ~2,950 to ~725.

Single-thread workload : modest improvement, cycles per read from ~452–454 down to ~408–409.

Torvalds noted in the PR: “Machines with more CPUs or multiple sockets should see larger gains; not yet measured on larger systems.”

He cautioned that this does not mean Linux overall runs three times faster—only this specific micro-benchmark on his Prague laptop during Linux Plumbers Conference.

Trade-offs and Current Status

Delayed memory reuse : pages stay allocated until the RCU grace period ends. Torvalds called this “the hardest part of this series.”

Regressions : when a read targets an unmapped user page, the new fast path throws an extra fault before falling back to the old path.

As of October 13, the branch had not been merged into Linux 7.3-rc6; its eventual inclusion and timeline remain uncertain.

Torvalds’ Evolving Stance on AI

Dec 2023 : viewed AI as a potential helper for finding bugs, not writing code.

2024 : called the AI industry “90% marketing, 10% reality.”

Late 2025 : said he was “very much a believer in AI as a tool,” interested in maintenance and patch review, but still not considering AI for serious new kernel code.

Jan 2026 : experimented with AI-assisted coding on a hobby Python audio-visualization project.

Oct 9, 2026 (Open Source Summit Europe, Prague): told Dirk Hohndel, “I used to think AI was not so great—but now I really like using it… if you use it correctly and treat it as a tool, AI is a great tool, and I find it makes programming more fun.” He still warned: “You have to be very careful using AI when you do things that really matter.”

Conclusion

The page-cache experiment showcases both sides of Torvalds’ position: Claude Code helped produce a promising optimization with measurable gains, yet unresolved memory-reclamation issues and regressions prevent immediate production use. Torvalds reiterated his long-held philosophy: “I firmly believe that over time these small improvements eventually turn into major features… the goal is always continuous improvement, steady progress.”

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performance optimizationconcurrencyRCULinux kernelAI-assisted codingpage cacheLinus TorvaldsClaude Code
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.