International Edition
Latest News
Technology

Linus Torvalds Uses Claude Code to Fix Linux Kernel Bottleneck

Linus Torvalds Deploys Claude Code to Fix Linux Kernel Bottleneck Linux creator Linus Torvalds used Anthropic’s Claude Code to develop a patch series that addressed a page-cache performance problem in the Linux kernel, achieving a throughput improvement on…

Linus Torvalds Uses Claude Code to Fix Linux Kernel Bottleneck

Linus Torvalds Deploys Claude Code to Fix Linux Kernel Bottleneck

Linux creator Linus Torvalds used Anthropic’s Claude Code to develop a patch series that addressed a page-cache performance problem in the Linux kernel, achieving a throughput improvement on his test system, according to reports. The breakthrough addresses an issue that had slowed buffered reads for more than two years, though maintainers have since raised concerns about memory reclamation and race conditions.

The performance issue centers on folio reference-count contention during common buffered-read operations. According to Hardware Busters data cited by sources, folio reference-count contention accounted for 99.92% of cross-core load HITMs during eight-thread tests on Torvalds’ Core i7-8565U laptop. Matthew Wilcox, an Oracle engineer and longtime Linux kernel memory-management developer, first flagged the bottleneck in 2024 after it emerged in a customer workload.

Claude Code Implementation and Threadripper Benchmark Results

Torvalds discovered an experimental branch named noref-filemap-read-with-llm within his development tree. The initial eight-patch series, built on Linux 7.3-rc6, was written entirely by Claude Code under Torvalds’ direction. Torvalds stated that the AI assistant handled the implementation, tests, and initial documentation, while he personally managed the code review and benchmark execution.

On a 64-thread Ryzen Threadripper running under heavy contention, the revised ten-patch rcu-free-v3 series pushed throughput from 13.3 million to 304 million reads per second. Concurrently, kernel cycles per read dropped from nearly 20,000 down to 735. The patches eliminate folio reference-count operations from the common buffered-read path by utilizing a new PG_rcu_free flag and RCU-delayed reclamation to protect the folio during userspace copies.

Maintainer Scrutiny Over Memory Reclamation and Race Conditions

The performance gains introduced trade-offs that drew immediate criticism from kernel maintainers. Wilcox questioned the use of the new PG_rcu_free flag, proposing a page type approach instead alongside inactive-list folio reclamation after an RCU grace period. Torvalds rejected both suggestions, noting that the flag must be set while a folio remains mappable into userspace, and that inactive-list reclamation fails to cover truncate and hole-punch operations.

Kiryl Shutsemau, a Linux kernel developer, subsequently suggested restricting the flag exclusively to 64-bit systems—a modification backed by Arm engineer and Linux memory-management maintainer David Hildenbrand. Shutsemau also identified a race condition in filemap_read_rcu_batch(), where a folio replacement followed by an extension of i_size could expose unwritten data. Torvalds recommended moving the file-size read earlier in the execution path, a change Shutsemau incorporated into a revised patch.

Frequently Asked Questions About the Linux Kernel AI Patches

What specific problem did the Claude Code patches solve in the Linux kernel?

The patches eliminate folio reference-count operations from a common buffered-read path to resolve a page-cache reference-counting bottleneck that developers had struggled with for over two years. This bottleneck caused severe cross-core contention during buffered reads.

Who originally flagged the page-cache bottleneck before Torvalds’ intervention?

Matthew Wilcox, an Oracle engineer and longtime Linux kernel memory-management developer, flagged the issue in 2024 after it surfaced in an actual customer workload.

Who is now leading the development of the memory reclamation fix?

Torvalds handed further development to Kiryl Shutsemau, a Linux kernel developer who previously worked on the same memory bottleneck and who identified and patched a subsequent race condition in filemap_read_rcu_batch().

Torvalds Used Claude Code on the Linux Kernel. What's Proven, What Isn't

About the author: Anika Shah - Technology

MSc in Computer Science, senior reporter. Anika focuses on AI ethics, cybersecurity, and emerging hardware—frequently moderating panels at CES and Web Summit. “Anika Shah decodes tech breakthroughs and startup disruption shaping tomorrow’s digital landscape.”