Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx> wrote: > 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. For the record: there are several academic studies about this subject. The most notable one is Corey [1]. [1] https://www.usenix.org/legacy/event/osdi08/tech/full_papers/boyd-wickizer/boyd_wickizer.pdf