Re: [PATCH] mm: Add new vma flag VM_LOCAL_CPU

From: Dave Hansen
Date: Wed May 23 2018 - 12:37:10 EST


On 05/22/2018 10:51 AM, Matthew Wilcox wrote:
> But CR3 is a per-CPU register. So it'd be *possible* to allocate one
> PGD per CPU (per process). Have them be identical in all but one of
> the PUD entries. Then you've reserved 1/512 of your address space for
> per-CPU pages.
>
> Complicated, ugly, memory-consuming. But possible.

Yep, and you'd probably want a cache of them so you don't end up having
to go rewrite half of the PGD every time you context-switch. But, on
the plus side, the logic would be pretty similar if not identical to the
way that we manage PCIDs. If your mm was recently active on the CPU,
you can use a PGD that's already been constructed. If not, you're stuck
making a new one.

Andy L. was alto talking about using this kind of mechanism to simplify
the entry code. Instead of needing per-cpu areas where we index by the
CPU number, or by using %GS, we could have per-cpu data or code that has
a fixed virtual address.

It'd be a fun project, but it might not ever pan out.