Chris Mason, the longtime Linux kernel developer most known for being the creator of Btrfs, has been working on a Git repository with AI review prompts he has been working on for LLM-assisted code review of Linux kernel patches. This initiative has been happening for some weeks now while the latest work was posted today for comments.
Chris wrote today on the Linux kernel mailing list:
“For anyone that is using the prompts, I’m hoping to get some feedback on changes I pushed today that break the review up into individual tasks. The previous prompts are all still there, so we can directly compare the two in terms of time, token cost, and effectiveness.
Using tasks allows us to break up large diffs into smaller chunks, and review each chunk individually. This ends up using fewer tokens a lot of the time, because we’re not sending context back and forth for the entire diff with every turn. It also catches more bugs all around.
I’m using a python script to break the changes up, and do bulk processing to pull out modified functions, types, and call graphs. This also helps reduce token usage, we’re just telling AI to load the processed results in bulk instead of making it discover the same information on its own. It’s probably buggy, I’m sure I’ll have to refine the python from here.
All those tokens saved hopefully helps make up for extra tokens spent. Each task has its own context window, so research done while processing one file in the diff has to be redone if another file in the diff needs the same functions loaded. AI providers cache tokens so it kind of works out, but I’m looking for feedback on this part especially.
The new setup has tasks for:
– Reviewing chunks of code
– Checking past lore threads (if semcode is available)
– Checking Fixes: tags
– Deep dive into syzkaller fixes (more on that below)
– Making the final report”
The Meta engineer has been investing a lot of effort into making this AI/LLM-assisted code review accurate and useful to upstream Linux kernel stakeholders. It’s already shown positive results and with the current pace it looks like it could play a helpful part in Linux kernel code review moving forward.
Those interested in Chris Mason’s review prompts for AI-assisted code review around the Linux kernel as well as systemd code review can find them via this GitHub repository.
