|
|
Log in / Subscribe / Register

Two LLM-assisted memory-management patch sets

By Jonathan Corbet
July 2, 2026
The kernel community (like many other free-software projects) has recently seen a large influx of patches developed with the assistance of large language models (LLMs). Those patches tend to come from developers who were previously unknown to the community. At the moment, though, the memory-management developers are evaluating two large patch sets, developed with LLM assistance, that were submitted by established and well-respected developers. The rather different reception accorded to that work may give insights into how LLM-generated contributions will be handled going forward.

Reliable 1GB allocations

As a Linux system runs, it tends to fragment its memory, making the allocation of large, physically contiguous chunks of memory difficult. Much work has been done over the years to improve this situation; the kernel tries hard to avoid fragmentation, and to actively defragment memory as needed. Larger allocations are more reliable than they once were. Still, allocation challenges can, for example, make it harder for the system to provide 2MB PMD-level huge pages than would be ideal.

Given that difficulty, it might seem that reliable allocation of PUD-level (1GB) huge pages is an impossible goal. But, as Rik van Riel said in the cover letter to a 40-part patch series, there are workloads that can gain significant performance benefit from the use of 1GB huge pages, if they can succeed in obtaining them. The only way to reliably allocate regions of that size in current kernels is to use the hugetlbfs subsystem, which reserves memory for this purpose at boot time. Hugetlbfs is inflexible, though; its reserved pages cannot be used for other purposes, and it cannot reserve additional pages if the workload needs them. The system administrator can only hope that the reservation set up at boot time is suitable for all workloads the system may subsequently run.

Van Riel's patch set attempts to make 1GB allocations more reliable without the need for the hugetlbfs reservation. It takes a number of approaches to reach that goal, but the core idea is the management of memory in units known as "super page blocks". The kernel breaks memory into page blocks now, and it manages them in ways designed to combat fragmentation. One of the key techniques is to segregate allocations that can be moved from those that cannot. For example, most user-space memory is movable, it is just a matter of changing all of the relevant page-table entries to match. On the other hand, allocations for the kernel's own use generally cannot be moved. By keeping the two types separate, the kernel maximizes its chances of creating entire free page blocks by moving the pages within them elsewhere.

Page blocks work reasonably well when it comes to helping the page allocator provide PMD-level huge pages. But they are much smaller than the 1GB target that Van Riel is trying to hit; on the system used to write this article, page blocks are configured to be 4MB in size. In a typical system, some page blocks will be used for movable allocations, while others will hold unmovable allocations. The movable blocks can, at need, be emptied out to create more PMD-level huge pages. But it only takes a single unmovable page block to render its entire containing 1GB huge page unmovable and, as a result, permanently fragmented.

The addition of super page blocks gives the page allocator another level of visibility into the use of memory. If a request comes in to allocate an unmovable page, the allocator will attempt to allocate from an unmovable page block as before. Should there be no such page blocks with free memory available, though, the allocator will need to pick a new page block to allocate from. Van Riel's patch set will cause the allocator to attempt to select that page block from a super page block that already holds other unmovable allocations. In other words, the segregation of movable and unmovable allocations is now done at the 1GB scale, increasing the chances that 1GB huge pages can be created and allocated at need.

There are a number of other techniques that are employed to help this overall policy succeed. Consider, for example, a virtually mapped kernel-space allocation (as might be obtained with kvmalloc()) requiring several pages. This allocation is not movable, and thus should be put into an unmovable super page block. If there are no such blocks with that many contiguous pages available, the allocator would naturally pick a new super page block, thus "tainting" it and making it unmovable. If, however, the allocation can be satisfied from existing unmovable super page blocks by splitting it into smaller chunks, the allocator will do that.

The patches in this series carry an Assisted-by tag indicating that the Claude Opus LLM was used in their creation. As noted above, though, van Riel is not a new developer needing LLM assistance to be able to put together a kernel patch. His first mention in LWN was with regard to a discussion on memory fragmentation — in 1998; he proposed the addition of a zoned memory allocator, which subsequently came to be. He is the sort of developer who is likely to get the benefit of the doubt when it comes to choices of tools.

This particular patch series has not been entirely well received, though, despite the fact that its goal — reliable allocation of 1GB huge pages — is widely supported. The most pointed criticism was surely this lengthy message from Lorenzo Stoakes, who took issue with the organization of the series and the code within it. "The series is completely unmergeable as it stands. Not even close." Other parts of the series were described as "code war crimes against __rmqueue_smallest()" or "something you expect to see on a 1990's PHP website, not in core mm code". He concluded with:

OK with all that said - to be absolutely clear - I respect you a great deal, and I KNOW you're (much, much) better than this.

And, to repeat, this idea is very exciting and I _want_ to see this land.

But I feel you've rather let the LLM run amok and it's selling you (very, very) short, given just how smart and capable you are.

Van Riel answered that he never expected the code to be merged in its current form, and that he had really been hoping for feedback on the overall design before reimplementing it in a form that could be considered for merging. The massive dump of LLM-generated code has gotten in the way of that process, though. Developers want to look at the implementation of a design to understand how it works in practice, and that has proved difficult for them to do in this case. This work will have to be redone, with more human attention paid, before it can be seriously considered, even at the design level.

Working-set tracking for virtual-machine guest memory

Virtual machines (VMs) are subject to two levels of memory management. They handle their own memory internally, but there is also host-level management that tries to ensure that the system's physical memory is used efficiently by all of the running VMs. The host-level task is easier if the VM manager (hypervisor) has visibility into which pages a given VM is actually using; that information can be used to reclaim the colder pages (or to move them to slower memory). But that information tends to be locked away inside the VM itself.

This patch series from Kiryl Shutsemau is meant to make that usage information more readily available to VM managers. It adds a new registration mode to the userfaultfd() system call that will cause the protections (at the host level) on the indicated range of pages to be marked as "no access". At registration time, it is possible to choose between two alternatives for what happens when the virtual machine does access one of those pages. If the synchronous mode has been selected, the VM manager will receive a message from the kernel and, after having noted the fault, can resolve it with another request back to the kernel. In the asynchronous mode, the kernel resets the permissions without notification to the VM manager. At a later time, the manager can scan the page range to see which pages have been accessed. This documentation patch describes the feature in more detail.

These patches, too, include an Assisted-by tag naming Claude Opus. Shutsemau does not have Van Riel's longevity in the kernel community; having made his first contribution to the 2.6.25 kernel in 2008, he is a relative newcomer. Still, his track record is long enough to make it clear that, once again, he is entirely capable of understanding the work that he is submitting to the community.

This series has been through seven revisions and significant changes resulting from the reviews that were received. In contrast to how Van Riel's work was received, none of those reviews was the role of the LLM in the creation of the work raised as a concern. In response to the second revision, though, Andrew Morton did ask for information about how the LLM was used; Shutsemau responded in detail. Much of the tool's role was in validating ideas:

For this particular project there was quite a bit of path-finding. I had a phase where I bounced ideas off Claude. It helped me understand the problem space better and formulate possible solutions. Rubber ducking on steroids.

Once it's clear _what_ to do, we formulate a plan on _how_. It also involves back and forth.

Once the plan was done, I gave the go-ahead on executing it.

The most time-consuming part of the process, he said, was reviewing the resulting code; that involved restarting the process from the beginning more than once. It took "maybe between 8 and 10" rounds to obtain code that he was happy with — before then feeding the whole series, along with a different set of prompts, to an LLM for review.

This workflow has seemingly produced a viable patch set that makes significant changes to the core memory-management code. The key to success, relative to the work previously described above, would appear to be the investment of substantial amounts of human time to get the tool to do the job properly, and in dealing with the remaining problems afterward. The care seemingly taken to ensure that the patches were up to the level of quality that the community expects by the time they hit the mailing lists appears to have made all the difference.

Shutsemau did not say whether that whole process was more efficient than simply doing the job without LLM assistance, but he does seem inclined to use that process again in the future.

The end of Shutsemau's message was a request for other developers to share their process for working with LLMs, but there were no responses. In truth, when it comes to significant work on the core kernel, he would appear to be one of the pioneers. The path toward success that he described, though, does not seem to be an easy one; anybody who is hoping to use an LLM as a quick way to become a kernel developer would do well to take note of what is likely to become the biggest success story (for kernel code) so far.

Index entries for this article
KernelDevelopment tools/Large language models
KernelMemory management/Large allocations
KernelMemory management/Virtualization


to post comments

Things you should and should not do

Posted Jul 2, 2026 17:08 UTC (Thu) by mvollrath (subscriber, #183387) [Link]

It sounds like van Riel did the thing you should never do: sending a half-baked AI-assisted email to anyone in a professional (or any) capacity. To get feedback on design seems like a job for a thoughtfully crafted RFC, before any code is shared in bulk. An AI can still assist with this, you just need to respect the audience. Anytime you switch gears from talking to an LLM to talking to people, if you haven't taken the time to clean it up, you're putting it on someone else to pick through it.

Shutsemau did put in the time, treating the LLM as a collaborator (who is available and fast but not always correct) building understanding throughout the process instead of a machine that magically makes code from an idea you had. This plays better with how LLMs fundamentally work and demonstrates understanding of the strengths and weaknesses of the tool. The tighter the feedback loop, the better. It's more like pair programming than throwing a task over the wall. Mind that, unlike pair programming with a real person, half of the shared understanding dissipates into a formless mass of information.

To state this again

Posted Jul 3, 2026 8:10 UTC (Fri) by rweikusat2 (subscriber, #117920) [Link] (19 responses)

I'll stop subscribing to LWN unless you stop this mindless LLM marketing. I'm not interested in being sold these "warez."

To state this again

Posted Jul 3, 2026 10:49 UTC (Fri) by Karellen (subscriber, #67644) [Link]

Just to counter this, I am against LLMs in general, and perplexed at their uptake by Free Software projects. But I am still interesting in finding out which projects are using them, and why, and getting a well-researched outside view of what results those projects are actually seeing. Then, if I do end up in a discussion about LLMs my position can be well-grounded and doesn't necessarily come across as plain ranting. Although I can often end up doing that anyway, at least it will be well informed ranting :-) I appreciate the reporting.

To state this again

Posted Jul 3, 2026 12:21 UTC (Fri) by daroc (editor, #160859) [Link] (1 responses)

We're really not mindlessly pro-LLM.

But whether you approve of the use of LLMs or not, there is certainly a lot of LLM-related news happening right now. Open source projects dealing with debates over their development policies is definitely in our typical topic area, even when doing so involves discussing LLMs. And we continue to cover plenty of non-LLM-related news.

That said, of course you're entitled to stop subscribing if you no longer find value in our news coverage; we'll be sad to see you go, but we do very much appreciate the support that you've given us so far.

To state this again

Posted Jul 3, 2026 19:51 UTC (Fri) by kleptog (subscriber, #1183) [Link]

I think LLMs are the most interesting thing to happen in software development in a long time. I don't know how this will all turn out, but I do know that LWN will keep me informed of the impact. The comments here are (mostly) at least well informed, even if I don't agree with them.

Keep up the reporting.

To state this again

Posted Jul 3, 2026 13:41 UTC (Fri) by vbabka (subscriber, #91706) [Link]

Calling this well-researched article "mindless LLM marketing" is frankly an insult to Jon and the rest of the LWN team and completely uncalled for.

To state this again

Posted Jul 3, 2026 13:51 UTC (Fri) by ljsloz (subscriber, #158382) [Link]

I personally find the blanket 'LLMs are bad and evil and I don't want to hear any more' approach to be actively harmful.

By taking a position which is contradicted by reality on the ground (they are effective, there are suitable ways of using them, they do provide a productivity boost albeit far less than claimed), you lose any ability to do anything about the extremely negative aspects (slop, climate impact, imperiling of the entire world economy).

Because you essentially put yourself in a fantasy world rather than dealing with reality which is messy, doesn't clearly have 'good' and 'bad' and requires nuanced thought.

Naturally we all want to be emotionally satisfied by binary thinking. But that's just not how the world is.

I gently suggest that you pay attention to those actually doing the work and experiencing the realities and who are taking risks to push back on the negatives, rather than immediately jumping to an emotional position.

And to suggest that Jon or LWN or the team in any way blindly promotes AI is so at odds with the facts (including LWN being repeatedly DDoS'd by AI scrapers) it's silly.

You should keep your subscription because, as an actual kernel developer, I can tell you that LWN is the _only_ press I've seen be consistently accurate and insightful on linux, the kernel, and open source as a whole. It's not even close.

We should all remain very grateful for the work Jon + the team does here.

To state this again

Posted Jul 4, 2026 12:26 UTC (Sat) by aimannajjar (subscriber, #184277) [Link] (13 responses)

Seriously, LWN seems compromised. Well, Big Tech has been trying to change Linux philosophy for awhile, maybe they finally did it? Look at Ubuntu acting exactly like Microsoft. Now we've got a bunch of Satya Nadellas as maintainers. Too much pragmatism does have a cost

To state this again

Posted Jul 4, 2026 14:51 UTC (Sat) by corbet (editor, #1) [Link] (12 responses)

I have to admit to being entirely mystified by these comments.

These tools are being used. One of the points of this article was that they are being used to create code at the core of the kernel. Should we pretend that this is not happening? Somehow I don't think that would serve our readers well. LLMs will not go away just because we choose to ignore them.

To state this again

Posted Jul 4, 2026 15:19 UTC (Sat) by koverstreet (subscriber, #4296) [Link] (11 responses)

There's definitely been an increase in trolling and outright hysteria, it's something I've been having to take time to deal with too.

I think people's feelings on the AI companies at the forefront are entirely understandable (and I share a lot of those!); I wonder if it would help to highlight what's been going on with open weights LLMs. The latest open weights LLMs are starting to match or maybe even surpass the closed ones, the open software stacks are becoming much more capable, and the hardware required is going to quickly drop in price by an order of magnitude - the DRAM bubble will pop, there's a ton of fabs coming online now or very soon, and it's early days for the hardware architectures still. The only remaining piece we're dependent on giant corporations for is training, and not for long on that one, I think.

Back in the early, early days of open source it was hard to get access to hardware - you needed to be affiliated with a university, or a company - or even a good compiler. It took time for stuff to get cheaper, and to democratize (and then turn into a different sort of lovely chaos). The development of AI is a bit reminiscent of that...

The world is always changing, the current situation is never a permanent state of affairs :)

To state this again

Posted Jul 4, 2026 16:50 UTC (Sat) by aimannajjar (subscriber, #184277) [Link] (10 responses)

I apologize if I came across too harsh. I understand you are just reporting on LLM use in Linux kernel. While I think my comment was uncalled for, I think Linux maintainers might be missing some crucial aspect regarding the "public perception of AI" and how that might impact Linux image, especially when people are migrating their desktops to it. Microsoft, and to lesser extent Microsoft, made these mistakes and the backlash was strong.

I believe much of the toxicity in AI discourse is due to the persistent "human-replacement" talking point championed by Big Tech CEOs, and their recurrent doubling-down on creating false hype by misrepresenting technical "achievements".

All experienced programmers know that all LLM agents will inevitably (and repeatedly) choke in any serious non-localized code change requests, we also know there is no serious "national security risks" with Mythos or Fable, we also know that LLMs will not "self-improve themselves" in any meaningful way using this technology, not when they cannot even guarantee production databases safety without humans in the loop.

Additionally all serious financial experts know that tech layoffs were not due to "AI productivity gains" but rather due to the irresponsible spending adventures and COVID-era fall outs.

Yet despite all that, Big Tech, with assistance from media and US government, is insisting on inflicting lasting damage on 1) real humans, 2) societal stability and 3) even small open-source projects by creating an extremely false narrative that does not reflect true capabilities and benefits of LLM agents.

When a large trusted open-source project is seen helping (in any way) those Big Tech's clearly-dark and psychotic ambitions, I think many people will feel disillusioned by such a free helping hand.

I agree local models will feel like a good converging point of this messy journey, even cloud LLM services becoming a commodity service and not the hyped "gold mine" being portrayed is a satisfying end result to see. But I don't think the toxicity will go away that easily, not when Big Tech, US media and government are still acting like a psychotic propaganda machine - and certainly not when hundred of thousands of people are still suffering from economic downfalls of that irresponsible behavior by those elites.

This is all to say, even if we wanted to be pragmatic about LLM use in Linux kernel, the toxicity that will come with that should be taken into account, especially when for the first time ever, the Year of the Linux Desktop is within reach.

To state this again

Posted Jul 4, 2026 16:53 UTC (Sat) by aimannajjar (subscriber, #184277) [Link]

* Sorry, meant to say "Microsoft, and to a lesser extent Canonical, ..

To state this again

Posted Jul 4, 2026 17:21 UTC (Sat) by koverstreet (subscriber, #4296) [Link]

100% agree with everything you have to say about Big Tech, and I could add a lot more of my own :)

But I was interested in AI long before the AI companies came along, because understanding how consciousness and our own minds work is even more fascinating to me than understanding how computers work; it builds on a lot of mathematics and computability theory going back 100 years or more, and takes it to the next level, and I find it absolutely beautiful.

And now we've got AIs that are legitimately capable of doing useful work, and I'm getting to see the realization of some of my own old ideas, and doing my own research (with the little time I have left over after bcachefs) into things that I wanted to be working on 20 years ago but never thought we'd crack. And in my own work, things that a year ago clearly needed to happen but looked like 10+ year projects (converting bcachefs to Rust, so I can keep making it more reliable and bulletproof, then formal verification) are now... completely tractable.

This is bloody amazing!

Yes, big tech absolutely sucks, and it's gotten worse over the course of my career, I'm seeing that too. But don't let it dominate your worldview and get you down.

The basic spirit of open source and free software was that individuals can make a difference, freely collaborating, just trying to make things better, and that hasn't changed. We'll always still be here, as long as we keep it alive.

To state this again

Posted Jul 4, 2026 22:16 UTC (Sat) by Cyberax (✭ supporter ✭, #52523) [Link] (7 responses)

> All experienced programmers know that all LLM agents will inevitably (and repeatedly) choke in any serious non-localized code change requests, we also know there is no serious "national security risks" with Mythos or Fable, we also know that LLMs will not "self-improve themselves" in any meaningful way using this technology, not when they cannot even guarantee production databases safety without humans in the loop.

First, we don't actually know that LLMs can't self-improve. Fifteen years ago we also "knew" that things like natural-language queries and machines passing the Turing test is just a crazy talk.

Second, even _with_ the current limitations the LLMs are still powerful tools. If nothing else changes and the LLM development stays frozen forever, existing models _already_ require significant adjustments in the development process.

So yeah, LWN providing overview of AI effects on the kernel development is very interesting and important.

To state this again

Posted Jul 4, 2026 23:44 UTC (Sat) by aimannajjar (subscriber, #184277) [Link] (6 responses)

LLMs can't self-improve because they're shown to be highly unreliable, i.e they hallucinate with high degree of confidence. Being both non-deterministic and highly unreliable is clear evidence they lack "intelligence" that is required to achieve self improvement.

Many pioneer researchers have said LLM as a technology is a dead-end for the stated goal of those AI companies, including things like AGI, and the so-called self-improvement.

LLMs are useful as tools, correct - too bad they didn't market them as such, I guess?

To state this again

Posted Jul 5, 2026 0:57 UTC (Sun) by koverstreet (subscriber, #4296) [Link] (5 responses)

Have you met the average human? :)

Humans guess, confabulate and outright hallucinate all the time. Tracking how well we know the things we think we know and why is a skill that takes effort to develop, and many never develop at all.

The big obstacle with LLM self-learning is a thing called the credits problem.

To state this again

Posted Jul 5, 2026 2:28 UTC (Sun) by aimannajjar (subscriber, #184277) [Link] (1 responses)

Yeah but humans can recognize when they have made a mistake and self-correct. The ones who are stuck in a hallucination cycle typically require medical intervention or end up in a self-destructive loop if they refuse help :)

LLMs can happily continue iterating with compounding hallucinations, not only that, LLMs that are trained on other LLM output degenerate and done repeatedly it leads to model collapse.

To state this again

Posted Jul 5, 2026 5:40 UTC (Sun) by koverstreet (subscriber, #4296) [Link]

> Yeah but humans can recognize when they have made a mistake and self-correct. The ones who are stuck in a hallucination cycle typically require medical intervention or end up in a self-destructive loop if they refuse help :)

You've never seen an LLM realize it made a mistake and self-correct?

> LLMs can happily continue iterating with compounding hallucinations, not only that, LLMs that are trained on other LLM output degenerate and done repeatedly it leads to model collapse.

That's the credits problem I was referring to.

To state this again

Posted Jul 6, 2026 6:41 UTC (Mon) by anselm (subscriber, #2796) [Link] (1 responses)

Calling what LLMs do “hallucination” is misleading because in humans, hallucinations are issues with spurious input processing whereas with LLMs, “hallucinations” are an output problem. A more appropriate technical term would be “bullshitting” (as per Harry G. Frankfurt) – the model just produces output regardless of its veracity, because LLMs have no knowledge, or concept of “correct” or “wrong”; all they're designed to do is to come up with a probable continuation of their output stream given their weights and context.

Of course bullshitting is something that some people do, too, but it's not generally considered a desirable trait in one's friends.

To state this again

Posted Jul 6, 2026 13:13 UTC (Mon) by aimannajjar (subscriber, #184277) [Link]

That's an interesting perspective and I agree with it. Generally speaking, anthropomorphizing those models is the most annoying thing those companies have chosen to do, Anthropics literally is now talking about models ability to "dream".

I've seen research papers by AI labs on "How to detect when AI lie", I asked the researcher presenting the paper "how is lying different from hallucinating?" - he answered (paraphrasing): "in the first the model is aware of the correct answer but is choosing to give the wrong answer". Those companies are suffering from an advanced form of psychosis when they think models have "choices" or "intentions". What's wrong with just saying "failure" or "error" like any other software?

I think it reveals something deeper about their view of the world, and their visions for it. It also explains the reckless spending chasing AGI and the toxic AI fear-mongering, which of course all is backfiring now.

To state this again

Posted Jul 6, 2026 14:56 UTC (Mon) by ballombe (subscriber, #9523) [Link]

Humans have more or less consistent personality. If you find that someone to be technically inept you will ignore them.
They have stake in their professional reputation.

On the other hand, LLM are totally unpredictable.

HugeTLB CMA

Posted Jul 13, 2026 12:37 UTC (Mon) by prati0100 (subscriber, #160597) [Link]

> Hugetlbfs is inflexible, though; its reserved pages cannot be used for other purposes

That's not exactly true. Since cf11e85fc08c ("mm: hugetlb: optionally allocate gigantic hugepages using cma"), released in v5.7, you can back hugetlb pages with CMA, which lets them be used for things like page cache, anon memory, etc. So while the memory can't be used for everything (no unmovable allocations for example), it isn't completely wasted either.


Copyright © 2026, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds