On Thu Sep 25, 2025 at 6:27 PM UTC, Dave Hansen wrote:
On 9/24/25 08:22, Roy, Patrick wrote:
Add an option to not perform TLB flushes after direct map manipulations.
I'd really prefer this be left out for now. It's a massive can of worms. Let's agree on something that works and has well-defined behavior before we go breaking it on purpose.
As David pointed out in the MM Alignment Session yesterday, I might be able to help here. In [0] I've proposed a way to break up the direct map by ASI's "sensitivity" concept, which is weaker than the "totally absent from the direct map" being proposed here, but it has kinda similar implementation challenges.
Basically it introduces a thing called a "freetype" that extends the idea of migratetype. Like the existing idea of migratetype, it's used to physically group pages when allocating, and you can index free pages by it, i.e. each freetype gets its own freelist. But it can also encode other information than mobility (and the other stuff that's encoded in migratetype...).
Could it make sense to use that logic to just have entire pageblocks that are absent from the direct map? Then when allocating memory for the guest_memfd we get it from one of those pageblocks. Then we only have to flush the TLB if there's no memory left in pageblocks of this freetype (so the allocator has to flip another pageblock over to the "no direct map" freetype, after removing it from the direct map).
I haven't yet investigated this properly, I'll start doing that now. But I thought I'd immediately drop this note in case anyone can immediately see a reason why this doesn't work.
[0] https://lore.kernel.org/all/20250924-b4-asi-page-alloc-v1-0-2d861768041f@goo...
BTW, I think if the skip-flush flag is the only thing blocking this patchset, it would be great to merge it without it. Even if that means it's no use for Firecracker usecases that doesn't mean the underlying feature isn't valuable for _someone_. Then we can figure out how to make it work for Firecracker afterwards, one way or another.
(Just to be transparent: my nefarious ulterior motive is that it would give me an angle to start merging code that will eventually support ASI. But, I'm serious that there are probably users who would like this feature even if it's slow!)