Linus Torvalds Experiments With Generating Changes To Kernel Via AI

Linus Torvalds prepared a set of patches for the memory management subsystem in the Linux kernel, implementing optimizations for reading small blocks of data from the page cache without atomically changing the refcount in the folio structure. The commit text states that the changes, associated tests, and draft note text were created by the AI ​​assistant Claude Code, with oversight from Torvalds. The change was added to a separate kernel branch noref-filemap-read-with-llm and it is not yet clear whether it will be moved to the main branch or this is just an internal experiment.

In testing, thanks to the patches, it was possible increase the throughput of reading small files in a configuration with 8 threads from 9.9-10.4 to 30-33 million operations per second (3-fold increase), with 4 threads – from 8.9-11.6 to 25-26 million/sec (2-fold increase), and with a single-threaded load from 7.9-8.1 to 8.8-8.9 million/sec. The performance gain is explained by the fact that when simultaneously accessing the page cache, severe competition occurs between threads when accessing the cache. For example, when 8 threads try to simultaneously read 16 bytes of data, 99.92% of the time is spent not on the reading itself, but on waiting for access to the reference counter.

In the patch, to guarantee data correctness, instead of setting separate locks, changing reference counters, or intermediate buffering, a workaround is used that uses delayed memory release with synchronization using the RCU (Read-Copy-Update) mechanism. The method proposed in the patch ensures that the memory page will not be physically freed until the reading thread has completed copying the data, which allows you to read data directly without setting separate locks.

/Reports, release notes, official announcements.