Page MenuHomeFreeBSD

powerpc64: initial conversion of oea64 to rwlocks
Needs ReviewPublic

Authored by adrian on Thu, Jan 29, 4:16 AM.
Referenced Files
F145038248: D54936.id.diff
Sun, Feb 15, 7:30 AM
Unknown Object (File)
Thu, Feb 12, 1:00 AM
Unknown Object (File)
Tue, Feb 10, 11:27 PM
Unknown Object (File)
Sun, Feb 8, 10:37 PM
Unknown Object (File)
Sun, Feb 8, 9:29 AM
Unknown Object (File)
Thu, Feb 5, 1:39 AM
Unknown Object (File)
Thu, Feb 5, 1:38 AM
Unknown Object (File)
Thu, Jan 29, 4:56 PM

Details

Reviewers
jhibbits
markj
kib
Group Reviewers
PowerPC
Summary
  • convert part of the oea64 mmu code to rwlocks.
  • change the pv lock names to individual ones for analysing hotspots.
  • create a lock acquisition/free pattern based on radix mmu / amd64 pmap.
  • migrate pmap_enter, pmap_enter_object and its downstream callers over to use this.
  • convert pvo cleanup to use the lock iterator.

This means that the pv lock is held for a bit longer, but I audited the
spots and it looks OK and isn't yet tripping up witness in a 4 CPU VM.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 70486
Build 67369: arc lint + arc unit

Event Timeline

adrian added a project: PowerPC.

This is sort of WIP - there's some TODOs in here. I'd like some feedback on the locking changes and whether I missed something. Thanks!

sys/powerpc/aim/mmu_oea64.c
128

If PV lock should be by superpage, the shift should be 24, because super pages are 16MB. I wonder if that might reduce contention a bit. Since the lock would then cover the full 16MB instead of needing 8 separate locks, you may be able to simply lock once to iterate over the full super page.

sys/powerpc/aim/mmu_oea64.c
128

On amd64 the lock must be per super-page. Demotions and promotions depend on this, they need to manipulate pv entries for all pages that constitute the superpage. This is not an optimization to reduce contention, but the fundamental feature.

I do not know if this holds for powerpc pmaps, but I highly suspect that it does.

sys/powerpc/aim/mmu_oea64.c
128

You're very likely correct on this. When @luporl wrote the superpage code he probably missed this, and so did I in the review. That may explain some of the complexity in the superpage code.

sys/powerpc/aim/mmu_oea64.c
128

errr...

hw.pagesizes: { 4096, 2097152 }

that's on a power9 vm, and my power8 powernv shows the same thing.

So we're doing 2mb superpages, so that shift looks right!

sys/powerpc/aim/mmu_oea64.c
128

It's a lie. 2MB superpages are only on radix pmap. This needs to be fixed for HPT, which only supports 16MB superpages.

sys/powerpc/aim/mmu_oea64.c
128

I don't see how you could see 2097152 for HPT, because moea64_early_bootstrap() sets vm_level_0_order to 12 immediately, before it sets the pagesizes array. Something is screwy.

adrian marked an inline comment as not done.Tue, Feb 3, 7:14 AM
adrian added inline comments.
sys/powerpc/aim/mmu_oea64.c
128

ah no, it /is/ 16mb superpages on the hash table.

i'll ask markj about this in a bit more detail.

adrian marked an inline comment as done and an inline comment as not done.Tue, Feb 3, 7:18 AM

rebase after jhibbits@ recent changes

sys/powerpc/aim/mmu_oea64.c
4215

A read lock should suffice for this.

4224

Yeah, good idea to assert on this. But assert on RA_LOCKED, not RA_RLOCKED, because you do have some spots that are locking for write and others that lock for read.

adrian added inline comments.
sys/powerpc/aim/mmu_oea64.c
1056

hm should i make this a different diff?

sys/powerpc/aim/mmu_oea64.c
1056

Yeah, make it separate. I like the rest of this diff, but this I one I think would just add noise. We don't need to know which pages are contended on, because they'll keep changing as the workload changes.

updated; i removed the recursive lock as now we shouldn't be recursing.

sys/powerpc/aim/mmu_oea64.c
3765

Hm, this should be one of the lock switch/iterate calls (CHANGE_PV_LIST_WR_LOCK_TO_PHYS()) but when i do this it'll hit a lock recursion assert.

With this call here i hit witness, but not a panic.

I'll need to figure that out.

  • convert the superpage lock path to use the iterator lock
  • and another function involved as well
adrian added inline comments.
sys/powerpc/aim/mmu_oea64.c
3765

figured it out, moea64_pvo_cleanup() was also grabbing/iterating locks. I've fixed that and now it doesn't panic or give recursion witness warnings.

jhibbits added inline comments.
sys/powerpc/aim/mmu_oea64.c
4215

Do you want to assert that at the beginning of this function?

This revision is now accepted and ready to land.Sun, Feb 8, 7:06 PM
sys/powerpc/aim/mmu_oea64.c
1056

This can just be rw_init().

3773

How is it guaranteed that all of these pages are protected by the same PV list lock? All of the physical pages here belong to the same large page, right?

4224

Justin's comment is marked done but there is no assertion.

sys/powerpc/aim/mmu_oea64.c
3773

I believe that's what @jhibbits is asserting with his previous change, yes.

4215

Which vm_page_t to to use though? At the point that moea64_sp_query() has been called something's already converted a vm_page_t to /a/ page; moea64_sp_query_locked() looks for the first pvo for the superpage, then does

m = PHYS_TO_VM_PAGE(PVO_PADDR(sp));

where sp is again the first pvo in the superpage.

So, should I just put an assert on PHYS_TO_VM_PAGE(PVO_ADDR(pvo)) in entry to moea64_sp_query() ? or moea64_sp_query_locked() ? or assert that the vm_page it determined to be the "first" in the list?

(I also note that although I added a comment, there wasn't already a lock assertion there, and I kinda wanna argue that adding a lock assertion should be an separate, earlier diff in the stack so we can validate IT is currently asserting correctly.)

rw_init_flags() -> rw_init()

This revision now requires review to proceed.Sun, Feb 15, 3:30 AM
adrian marked an inline comment as done and an inline comment as not done.