Linus Torvalds uses AI for kernel patches

Linus Torvalds, the creator of the Linux kernel, has released a series of eight patches in his personal repository. These patches were developed with the help of Claude Code, an AI tool, and are part of a branch named noref-filemap-read-with-llm.

Branch includes AI-assisted code and documentation

The branch contains code, test programs, open issue reviews, and a draft letter that appears to be generated by an Anthropic assistant. Benchmarks for the changes were run on Torvalds’ own machine.

AI used for memory management improvements

This is the first time Torvalds has credited an AI agent for a series of patches related to memory management in the Linux kernel. Previously, he had used AI only for debugging purposes.

Improving page cache performance

The project focuses on the page cache, a part of memory where the kernel stores recently accessed files. When multiple threads read small parts of the same file, each read can lead to two atomic writes on the same cache line, causing competition among processor cores.

New approach avoids race conditions

Previous methods involved copying data into a buffer without references and validating it afterward, but this approach failed to detect race conditions, such as a page being freed and then reinserted at the same index. Torvalds’ solution allows a page removed from the cache to return to the allocator only after a grace period.

Performance improvements measured

According to Hwbusters, with eight threads reading from a file, the kernel’s cost per read drops from around 2,950 to 725 cycles, and the throughput increases from about 10 million to 30–33 million reads per second. With a single thread, the improvement is about 10 percent.

Branch not yet merged into main kernel

The branch is based on Linux 7.3-rc6 and has not been merged into the main kernel. This means users of Ubuntu or other Linux distributions will not see the changes yet.

Torvalds remains cautious about AI use

Torvalds’ current stance contrasts with his remarks from two years ago, when he said the AI industry was “90% marketing and 10% reality.” He still opposes AI signing the code instead of the developer, a position that has caused division in the open-source community.

Future of AI-assisted code unclear

Whether the Linux kernel will accept AI-assisted code, as long as a human signs it, or exclude it entirely, remains an open question. The response from memory management maintainers is yet to be seen.