Page MenuHomeFreeBSD

pmap_large_map() KPI
ClosedPublic

Authored by kib on Sep 7 2018, 12:25 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 9, 4:09 AM
Unknown Object (File)
Mar 18 2024, 3:22 PM
Unknown Object (File)
Mar 18 2024, 3:22 PM
Unknown Object (File)
Mar 18 2024, 3:22 PM
Unknown Object (File)
Mar 18 2024, 3:22 PM
Unknown Object (File)
Mar 18 2024, 3:22 PM
Unknown Object (File)
Mar 18 2024, 3:22 PM
Unknown Object (File)
Mar 18 2024, 3:22 PM

Details

Summary

Add KPI to map very large contigous physical memory regions into KVA, which are not covered by DMAP.

From what I see both with QEMU and with some real hardware started shipping, the regions for NVDIMMs might be very far apart from the normal RAM, and we expect that at least initial users of NVDIMM could install very large amount of such memory. IMO it is not reasonable to extend DMAP to cover that far-away regions both because it could overflow existing 4T window for DMAP in KVA, and because it costs in page table pages allocations, for gap and for possibly unused NV RAM.

Also, KPI provides some special functionality for fast cache flushing based on the knowledge of the NVRAM mapping use.

Some code would benefit from splitting it into ifuncs, this is for later.

An example of the memory map on the real hardware:

machdep.efi_map: 
                   Type     Physical      Virtual   #Pages Attr
       BootServicesCode 000000000000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000000001000          0x0 00000041 UC WC WT WB 
       BootServicesCode 000000042000          0x0 0000001b UC WC WT WB 
     ConventionalMemory 00000005d000          0x0 00000003 UC WC WT WB 
       BootServicesCode 000000060000          0x0 00000040 UC WC WT WB 
     ConventionalMemory 000000100000          0x0 00000b00 UC WC WT WB 
       BootServicesCode 000000c00000          0x0 00000400 UC WC WT WB 
     ConventionalMemory 000001000000          0x0 0003affc UC WC WT WB 
             LoaderData 00003bffc000          0x0 00004004 UC WC WT WB 
     ConventionalMemory 000040000000          0x0 0001acd0 UC WC WT WB 
       BootServicesData 00005acd0000          0x0 00000100 UC WC WT WB 
     ConventionalMemory 00005add0000          0x0 000040be UC WC WT WB 
             LoaderData 00005ee8e000          0x0 00004000 UC WC WT WB 
               Reserved 000062e8e000          0x0 00000025 UC WC WT WB 
     ConventionalMemory 000062eb3000          0x0 000000ab UC WC WT WB 
             LoaderCode 000062f5e000          0x0 00000077 UC WC WT WB 
     ConventionalMemory 000062fd5000          0x0 00000070 UC WC WT WB 
       BootServicesData 000063045000          0x0 000001b8 UC WC WT WB 
     ConventionalMemory 0000631fd000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000631ff000          0x0 0000010c UC WC WT WB 
     ConventionalMemory 00006330b000          0x0 00000031 UC WC WT WB 
       BootServicesData 00006333c000          0x0 0000008f UC WC WT WB 
       BootServicesCode 0000633cb000          0x0 00000001 UC WC WT WB 
       BootServicesData 0000633cc000          0x0 00000763 UC WC WT WB 
     ConventionalMemory 000063b2f000          0x0 00000002 UC WC WT WB 
       BootServicesData 000063b31000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063b32000          0x0 00000005 UC WC WT WB 
       BootServicesData 000063b37000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 000063b39000          0x0 00000001 UC WC WT WB 
       BootServicesData 000063b3a000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063b3b000          0x0 00000001 UC WC WT WB 
       BootServicesData 000063b3c000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 000063b3e000          0x0 00000002 UC WC WT WB 
       BootServicesData 000063b40000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063b41000          0x0 00000003 UC WC WT WB 
       BootServicesData 000063b44000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 000063b46000          0x0 00000003 UC WC WT WB 
       BootServicesData 000063b49000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063b4a000          0x0 0000000d UC WC WT WB 
       BootServicesData 000063b57000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 000063b59000          0x0 00000007 UC WC WT WB 
       BootServicesData 000063b60000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 000063b63000          0x0 00000003 UC WC WT WB 
       BootServicesData 000063b66000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063b67000          0x0 00000001 UC WC WT WB 
       BootServicesData 000063b68000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063b69000          0x0 00000002 UC WC WT WB 
       BootServicesData 000063b6b000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063b6c000          0x0 0000000c UC WC WT WB 
       BootServicesData 000063b78000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063b79000          0x0 00000002 UC WC WT WB 
       BootServicesData 000063b7b000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063b7c000          0x0 000000db UC WC WT WB 
       BootServicesData 000063c57000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063c58000          0x0 0000001a UC WC WT WB 
       BootServicesData 000063c72000          0x0 0000002f UC WC WT WB 
     ConventionalMemory 000063ca1000          0x0 0000000a UC WC WT WB 
       BootServicesData 000063cab000          0x0 00000069 UC WC WT WB 
     ConventionalMemory 000063d14000          0x0 00000003 UC WC WT WB 
       BootServicesData 000063d17000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063d18000          0x0 00000005 UC WC WT WB 
       BootServicesData 000063d1d000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 000063d20000          0x0 00000002 UC WC WT WB 
       BootServicesData 000063d22000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 000063d24000          0x0 00000002 UC WC WT WB 
       BootServicesData 000063d26000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063d27000          0x0 00000003 UC WC WT WB 
       BootServicesData 000063d2a000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 000063d2c000          0x0 00000001 UC WC WT WB 
       BootServicesData 000063d2d000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063d2e000          0x0 00000001 UC WC WT WB 
       BootServicesData 000063d2f000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063d30000          0x0 0000000d UC WC WT WB 
       BootServicesData 000063d3d000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 000063d3f000          0x0 00000007 UC WC WT WB 
       BootServicesData 000063d46000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 000063d49000          0x0 00000002 UC WC WT WB 
       BootServicesData 000063d4b000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063d4c000          0x0 00000002 UC WC WT WB 
       BootServicesData 000063d4e000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063d4f000          0x0 00000001 UC WC WT WB 
       BootServicesData 000063d50000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063d51000          0x0 00000003 UC WC WT WB 
       BootServicesData 000063d54000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063d55000          0x0 0000000d UC WC WT WB 
       BootServicesData 000063d62000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063d63000          0x0 000000dc UC WC WT WB 
       BootServicesData 000063e3f000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063e40000          0x0 0000001a UC WC WT WB 
       BootServicesData 000063e5a000          0x0 00000030 UC WC WT WB 
     ConventionalMemory 000063e8a000          0x0 00000009 UC WC WT WB 
       BootServicesData 000063e93000          0x0 0000004b UC WC WT WB 
     ConventionalMemory 000063ede000          0x0 00000001 UC WC WT WB 
       BootServicesData 000063edf000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063ee0000          0x0 00000002 UC WC WT WB 
       BootServicesData 000063ee2000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 000063ee4000          0x0 00000005 UC WC WT WB 
       BootServicesData 000063ee9000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 000063eec000          0x0 00000002 UC WC WT WB 
       BootServicesData 000063eee000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 000063ef0000          0x0 00000002 UC WC WT WB 
       BootServicesData 000063ef2000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063ef3000          0x0 00000003 UC WC WT WB 
       BootServicesData 000063ef6000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 000063ef8000          0x0 00000001 UC WC WT WB 
       BootServicesData 000063ef9000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 000063efc000          0x0 0000000c UC WC WT WB 
       BootServicesData 000063f08000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 000063f0a000          0x0 00000007 UC WC WT WB 
       BootServicesData 000063f11000          0x0 00000004 UC WC WT WB 
     ConventionalMemory 000063f15000          0x0 00000002 UC WC WT WB 
       BootServicesData 000063f17000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063f18000          0x0 00000002 UC WC WT WB 
       BootServicesData 000063f1a000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063f1b000          0x0 00000002 UC WC WT WB 
       BootServicesData 000063f1d000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063f1e000          0x0 0000000d UC WC WT WB 
       BootServicesData 000063f2b000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000063f2c000          0x0 000000ec UC WC WT WB 
       BootServicesData 000064018000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000064019000          0x0 00000009 UC WC WT WB 
       BootServicesData 000064022000          0x0 0000003a UC WC WT WB 
     ConventionalMemory 00006405c000          0x0 00000001 UC WC WT WB 
       BootServicesData 00006405d000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 00006405e000          0x0 00000003 UC WC WT WB 
       BootServicesData 000064061000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000064062000          0x0 0000000a UC WC WT WB 
       BootServicesData 00006406c000          0x0 0000004d UC WC WT WB 
     ConventionalMemory 0000640b9000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000640bb000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 0000640bd000          0x0 00000004 UC WC WT WB 
       BootServicesData 0000640c1000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 0000640c4000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000640c6000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 0000640c8000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000640ca000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000640cb000          0x0 00000003 UC WC WT WB 
       BootServicesData 0000640ce000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 0000640d0000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000640d2000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 0000640d4000          0x0 0000000d UC WC WT WB 
       BootServicesData 0000640e1000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 0000640e3000          0x0 00000007 UC WC WT WB 
       BootServicesData 0000640ea000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 0000640ed000          0x0 00000003 UC WC WT WB 
       BootServicesData 0000640f0000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000640f1000          0x0 00000001 UC WC WT WB 
       BootServicesData 0000640f2000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000640f3000          0x0 00000003 UC WC WT WB 
       BootServicesData 0000640f6000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000640f7000          0x0 0000000d UC WC WT WB 
       BootServicesData 000064104000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000064105000          0x0 000000eb UC WC WT WB 
       BootServicesData 0000641f0000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000641f1000          0x0 00000009 UC WC WT WB 
       BootServicesData 0000641fa000          0x0 00000011 UC WC WT WB 
     ConventionalMemory 00006420b000          0x0 00000001 UC WC WT WB 
       BootServicesData 00006420c000          0x0 0000002a UC WC WT WB 
     ConventionalMemory 000064236000          0x0 00000001 UC WC WT WB 
       BootServicesData 000064237000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000064238000          0x0 0000000d UC WC WT WB 
       BootServicesData 000064245000          0x0 0000004c UC WC WT WB 
     ConventionalMemory 000064291000          0x0 00000003 UC WC WT WB 
       BootServicesData 000064294000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000064295000          0x0 00000005 UC WC WT WB 
       BootServicesData 00006429a000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 00006429d000          0x0 00000002 UC WC WT WB 
       BootServicesData 00006429f000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 0000642a1000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000642a3000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000642a4000          0x0 00000003 UC WC WT WB 
       BootServicesData 0000642a7000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 0000642a9000          0x0 00000001 UC WC WT WB 
       BootServicesData 0000642aa000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000642ab000          0x0 00000001 UC WC WT WB 
       BootServicesData 0000642ac000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000642ad000          0x0 0000000d UC WC WT WB 
       BootServicesData 0000642ba000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 0000642bc000          0x0 00000007 UC WC WT WB 
       BootServicesData 0000642c3000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 0000642c6000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000642c8000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000642c9000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000642cb000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000642cc000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000642ce000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000642cf000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000642d1000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000642d2000          0x0 00000025 UC WC WT WB 
       BootServicesData 0000642f7000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000642f8000          0x0 000000b8 UC WC WT WB 
       BootServicesData 0000643b0000          0x0 00000007 UC WC WT WB 
     ConventionalMemory 0000643b7000          0x0 00000026 UC WC WT WB 
       BootServicesData 0000643dd000          0x0 00000027 UC WC WT WB 
     ConventionalMemory 000064404000          0x0 00000021 UC WC WT WB 
       BootServicesData 000064425000          0x0 0000005e UC WC WT WB 
     ConventionalMemory 000064483000          0x0 00000001 UC WC WT WB 
       BootServicesData 000064484000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 000064487000          0x0 00000004 UC WC WT WB 
       BootServicesData 00006448b000          0x0 00000004 UC WC WT WB 
     ConventionalMemory 00006448f000          0x0 00000002 UC WC WT WB 
       BootServicesData 000064491000          0x0 00000002 UC WC WT WB 
     ConventionalMemory 000064493000          0x0 00000002 UC WC WT WB 
       BootServicesData 000064495000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000064496000          0x0 00000001 UC WC WT WB 
       BootServicesData 000064497000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 000064498000          0x0 00000002 UC WC WT WB 
       BootServicesData 00006449a000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 00006449b000          0x0 00000001 UC WC WT WB 
       BootServicesData 00006449c000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 00006449f000          0x0 0000000c UC WC WT WB 
       BootServicesData 0000644ab000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 0000644ae000          0x0 00000007 UC WC WT WB 
       BootServicesData 0000644b5000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 0000644b8000          0x0 00000001 UC WC WT WB 
       BootServicesData 0000644b9000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 0000644bc000          0x0 00000001 UC WC WT WB 
       BootServicesData 0000644bd000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000644be000          0x0 00000001 UC WC WT WB 
       BootServicesData 0000644bf000          0x0 00000003 UC WC WT WB 
     ConventionalMemory 0000644c2000          0x0 00000024 UC WC WT WB 
       BootServicesData 0000644e6000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000644e7000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000644e9000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000644ea000          0x0 000000b9 UC WC WT WB 
       BootServicesData 0000645a3000          0x0 00000006 UC WC WT WB 
     ConventionalMemory 0000645a9000          0x0 00000003 UC WC WT WB 
       BootServicesData 0000645ac000          0x0 00000001 UC WC WT WB 
     ConventionalMemory 0000645ad000          0x0 00000022 UC WC WT WB 
       BootServicesData 0000645cf000          0x0 00000028 UC WC WT WB 
     ConventionalMemory 0000645f7000          0x0 0000001a UC WC WT WB 
             LoaderData 000064611000          0x0 00000007 UC WC WT WB 
    RuntimeServicesData 000064618000   0x64618000 00000227 UC WC WT WB RUNTIME
       BootServicesCode 00006483f000          0x0 0000022c UC WC WT WB 
     ConventionalMemory 000064a6b000          0x0 00000001 UC WC WT WB 
       BootServicesData 000064a6c000          0x0 00000049 UC WC WT WB 
       BootServicesCode 000064ab5000          0x0 00000001 UC WC WT WB 
       BootServicesData 000064ab6000          0x0 00000387 UC WC WT WB 
       BootServicesCode 000064e3d000          0x0 00000034 UC WC WT WB 
       BootServicesData 000064e71000          0x0 00000005 UC WC WT WB 
       BootServicesCode 000064e76000          0x0 00000005 UC WC WT WB 
       BootServicesData 000064e7b000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000064e7c000          0x0 00000001 UC WC WT WB 
       BootServicesData 000064e7d000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000064e7e000          0x0 00000001 UC WC WT WB 
       BootServicesData 000064e7f000          0x0 00000007 UC WC WT WB 
       BootServicesCode 000064e86000          0x0 00000003 UC WC WT WB 
       BootServicesData 000064e89000          0x0 0000010e UC WC WT WB 
       BootServicesCode 000064f97000          0x0 00000002 UC WC WT WB 
       BootServicesData 000064f99000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000064f9a000          0x0 00000004 UC WC WT WB 
       BootServicesData 000064f9e000          0x0 00000004 UC WC WT WB 
       BootServicesCode 000064fa2000          0x0 00000003 UC WC WT WB 
       BootServicesData 000064fa5000          0x0 00001069 UC WC WT WB 
      ACPIReclaimMemory 00006600e000          0x0 00000027 UC WC WT WB 
       BootServicesCode 000066035000          0x0 00000004 UC WC WT WB 
       BootServicesData 000066039000          0x0 00000023 UC WC WT WB 
      ACPIReclaimMemory 00006605c000          0x0 00000034 UC WC WT WB 
       BootServicesData 000066090000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000066091000          0x0 00000001 UC WC WT WB 
       BootServicesData 000066092000          0x0 00000066 UC WC WT WB 
      ACPIReclaimMemory 0000660f8000          0x0 000000a3 UC WC WT WB 
       BootServicesData 00006619b000          0x0 00000022 UC WC WT WB 
      ACPIReclaimMemory 0000661bd000          0x0 0000002b UC WC WT WB 
       BootServicesData 0000661e8000          0x0 00000f1d UC WC WT WB 
       BootServicesCode 000067105000          0x0 00000056 UC WC WT WB 
       BootServicesData 00006715b000          0x0 00000008 UC WC WT WB 
       BootServicesCode 000067163000          0x0 00000014 UC WC WT WB 
       BootServicesData 000067177000          0x0 00000014 UC WC WT WB 
       BootServicesCode 00006718b000          0x0 00000007 UC WC WT WB 
       BootServicesData 000067192000          0x0 00000007 UC WC WT WB 
       BootServicesCode 000067199000          0x0 0000000c UC WC WT WB 
       BootServicesData 0000671a5000          0x0 00000005 UC WC WT WB 
       BootServicesCode 0000671aa000          0x0 00000068 UC WC WT WB 
       BootServicesData 000067212000          0x0 00000010 UC WC WT WB 
       BootServicesCode 000067222000          0x0 00000002 UC WC WT WB 
       BootServicesData 000067224000          0x0 00000008 UC WC WT WB 
       BootServicesCode 00006722c000          0x0 00000004 UC WC WT WB 
       BootServicesData 000067230000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000067231000          0x0 00000001 UC WC WT WB 
       BootServicesData 000067232000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000067234000          0x0 000000bb UC WC WT WB 
       BootServicesData 0000672ef000          0x0 00000042 UC WC WT WB 
       BootServicesCode 000067331000          0x0 0000000a UC WC WT WB 
       BootServicesData 00006733b000          0x0 0000000a UC WC WT WB 
       BootServicesCode 000067345000          0x0 00000004 UC WC WT WB 
       BootServicesData 000067349000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006734a000          0x0 0000001e UC WC WT WB 
       BootServicesData 000067368000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000067369000          0x0 00000003 UC WC WT WB 
       BootServicesData 00006736c000          0x0 00000003 UC WC WT WB 
       BootServicesCode 00006736f000          0x0 00000009 UC WC WT WB 
       BootServicesData 000067378000          0x0 00000003 UC WC WT WB 
       BootServicesCode 00006737b000          0x0 0000000a UC WC WT WB 
       BootServicesData 000067385000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000067387000          0x0 00000005 UC WC WT WB 
       BootServicesData 00006738c000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006738d000          0x0 00000054 UC WC WT WB 
       BootServicesData 0000673e1000          0x0 00000004 UC WC WT WB 
       BootServicesCode 0000673e5000          0x0 00000004 UC WC WT WB 
       BootServicesData 0000673e9000          0x0 00000002 UC WC WT WB 
       BootServicesCode 0000673eb000          0x0 00000005 UC WC WT WB 
       BootServicesData 0000673f0000          0x0 00000003 UC WC WT WB 
       BootServicesCode 0000673f3000          0x0 00000008 UC WC WT WB 
       BootServicesData 0000673fb000          0x0 00000004 UC WC WT WB 
      ACPIReclaimMemory 0000673ff000          0x0 00000001 UC WC WT WB 
       BootServicesData 000067400000          0x0 00000084 UC WC WT WB 
       BootServicesCode 000067484000          0x0 00000128 UC WC WT WB 
    RuntimeServicesCode 0000675ac000   0x675ac000 000000ae UC WC WT WB RUNTIME
       BootServicesData 00006765a000          0x0 00000002 UC WC WT WB 
       BootServicesCode 00006765c000          0x0 00000035 UC WC WT WB 
       BootServicesData 000067691000          0x0 0000000b UC WC WT WB 
       BootServicesCode 00006769c000          0x0 00000010 UC WC WT WB 
       BootServicesData 0000676ac000          0x0 00000001 UC WC WT WB 
       BootServicesCode 0000676ad000          0x0 00000017 UC WC WT WB 
       BootServicesData 0000676c4000          0x0 00000008 UC WC WT WB 
       BootServicesCode 0000676cc000          0x0 0000000c UC WC WT WB 
       BootServicesData 0000676d8000          0x0 00000002 UC WC WT WB 
       BootServicesCode 0000676da000          0x0 0000000c UC WC WT WB 
       BootServicesData 0000676e6000          0x0 00000006 UC WC WT WB 
       BootServicesCode 0000676ec000          0x0 00000003 UC WC WT WB 
       BootServicesData 0000676ef000          0x0 00000014 UC WC WT WB 
       BootServicesCode 000067703000          0x0 00000003 UC WC WT WB 
       BootServicesData 000067706000          0x0 00000101 UC WC WT WB 
    RuntimeServicesCode 000067807000   0x67807000 0000007c UC WC WT WB RUNTIME
       BootServicesCode 000067883000          0x0 00000001 UC WC WT WB 
       BootServicesData 000067884000          0x0 0000001a UC WC WT WB 
       BootServicesCode 00006789e000          0x0 0000002f UC WC WT WB 
       BootServicesData 0000678cd000          0x0 00000006 UC WC WT WB 
       BootServicesCode 0000678d3000          0x0 0000001c UC WC WT WB 
       BootServicesData 0000678ef000          0x0 00000003 UC WC WT WB 
       BootServicesCode 0000678f2000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000678f4000          0x0 00000004 UC WC WT WB 
       BootServicesCode 0000678f8000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000678fa000          0x0 00000002 UC WC WT WB 
       BootServicesCode 0000678fc000          0x0 0000003a UC WC WT WB 
       BootServicesData 000067936000          0x0 00000003 UC WC WT WB 
       BootServicesCode 000067939000          0x0 00000006 UC WC WT WB 
       BootServicesData 00006793f000          0x0 00000004 UC WC WT WB 
       BootServicesCode 000067943000          0x0 00000017 UC WC WT WB 
       BootServicesData 00006795a000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006795b000          0x0 00000001 UC WC WT WB 
       BootServicesData 00006795c000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006795d000          0x0 00000001 UC WC WT WB 
       BootServicesData 00006795e000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006795f000          0x0 00000001 UC WC WT WB 
       BootServicesData 000067960000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000067961000          0x0 00000004 UC WC WT WB 
       BootServicesData 000067965000          0x0 000000be UC WC WT WB 
       BootServicesCode 000067a23000          0x0 0000000f UC WC WT WB 
       BootServicesData 000067a32000          0x0 00000004 UC WC WT WB 
       BootServicesCode 000067a36000          0x0 00000048 UC WC WT WB 
       BootServicesData 000067a7e000          0x0 00000006 UC WC WT WB 
      ACPIReclaimMemory 000067a84000          0x0 00000001 UC WC WT WB 
       BootServicesData 000067a85000          0x0 0000000d UC WC WT WB 
      ACPIReclaimMemory 000067a92000          0x0 00000003 UC WC WT WB 
       BootServicesData 000067a95000          0x0 00000031 UC WC WT WB 
       BootServicesCode 000067ac6000          0x0 00000024 UC WC WT WB 
       BootServicesData 000067aea000          0x0 00000006 UC WC WT WB 
       BootServicesCode 000067af0000          0x0 00000004 UC WC WT WB 
       BootServicesData 000067af4000          0x0 00000004 UC WC WT WB 
       BootServicesCode 000067af8000          0x0 00000004 UC WC WT WB 
       BootServicesData 000067afc000          0x0 00000004 UC WC WT WB 
       BootServicesCode 000067b00000          0x0 00000002 UC WC WT WB 
       BootServicesData 000067b02000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000067b04000          0x0 00000002 UC WC WT WB 
       BootServicesData 000067b06000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000067b07000          0x0 0000000b UC WC WT WB 
       BootServicesData 000067b12000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000067b14000          0x0 00000001 UC WC WT WB 
       BootServicesData 000067b15000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000067b17000          0x0 00000001 UC WC WT WB 
       BootServicesData 000067b18000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000067b19000          0x0 00000001 UC WC WT WB 
       BootServicesData 000067b1a000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000067b1b000          0x0 00000014 UC WC WT WB 
       BootServicesData 000067b2f000          0x0 00000004 UC WC WT WB 
       BootServicesCode 000067b33000          0x0 00000001 UC WC WT WB 
       BootServicesData 000067b34000          0x0 00000003 UC WC WT WB 
       BootServicesCode 000067b37000          0x0 00000007 UC WC WT WB 
       BootServicesData 000067b3e000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000067b40000          0x0 00000001 UC WC WT WB 
       BootServicesData 000067b41000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000067b42000          0x0 00000003 UC WC WT WB 
       BootServicesData 000067b45000          0x0 00000004 UC WC WT WB 
       BootServicesCode 000067b49000          0x0 00000001 UC WC WT WB 
       BootServicesData 000067b4a000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000067b4b000          0x0 0000000b UC WC WT WB 
       BootServicesData 000067b56000          0x0 00000005 UC WC WT WB 
       BootServicesCode 000067b5b000          0x0 00000003 UC WC WT WB 
       BootServicesData 000067b5e000          0x0 0000004a UC WC WT WB 
               Reserved 000067ba8000          0x0 00001000 UC WC WT WB 
       BootServicesCode 000068ba8000          0x0 00000021 UC WC WT WB 
       BootServicesData 000068bc9000          0x0 00000021 UC WC WT WB 
       BootServicesCode 000068bea000          0x0 00000002 UC WC WT WB 
       BootServicesData 000068bec000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000068bee000          0x0 00000009 UC WC WT WB 
       BootServicesData 000068bf7000          0x0 00000003 UC WC WT WB 
       BootServicesCode 000068bfa000          0x0 00000002 UC WC WT WB 
       BootServicesData 000068bfc000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000068bfe000          0x0 00000004 UC WC WT WB 
       BootServicesData 000068c02000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000068c03000          0x0 00000006 UC WC WT WB 
       BootServicesData 000068c09000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000068c0a000          0x0 00000002 UC WC WT WB 
       BootServicesData 000068c0c000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000068c0e000          0x0 00000006 UC WC WT WB 
       BootServicesData 000068c14000          0x0 00000003 UC WC WT WB 
       BootServicesCode 000068c17000          0x0 00000008 UC WC WT WB 
       BootServicesData 000068c1f000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000068c20000          0x0 00000003 UC WC WT WB 
       BootServicesData 000068c23000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000068c24000          0x0 00000001 UC WC WT WB 
       BootServicesData 000068c25000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000068c26000          0x0 00000004 UC WC WT WB 
       BootServicesData 000068c2a000          0x0 00000409 UC WC WT WB 
       BootServicesCode 000069033000          0x0 0000001b UC WC WT WB 
       BootServicesData 00006904e000          0x0 00000007 UC WC WT WB 
       BootServicesCode 000069055000          0x0 00000003 UC WC WT WB 
       BootServicesData 000069058000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000069059000          0x0 00000002 UC WC WT WB 
       BootServicesData 00006905b000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006905c000          0x0 0000000e UC WC WT WB 
       BootServicesData 00006906a000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006906b000          0x0 00000002 UC WC WT WB 
       BootServicesData 00006906d000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006906e000          0x0 00000002 UC WC WT WB 
       BootServicesData 000069070000          0x0 00000007 UC WC WT WB 
       BootServicesCode 000069077000          0x0 0000000c UC WC WT WB 
       BootServicesData 000069083000          0x0 00000005 UC WC WT WB 
       BootServicesCode 000069088000          0x0 00000003 UC WC WT WB 
       BootServicesData 00006908b000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006908c000          0x0 00000034 UC WC WT WB 
       BootServicesData 0000690c0000          0x0 0000000a UC WC WT WB 
       BootServicesCode 0000690ca000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000690cc000          0x0 00000002 UC WC WT WB 
       BootServicesCode 0000690ce000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000690d0000          0x0 00000002 UC WC WT WB 
       BootServicesCode 0000690d2000          0x0 00000011 UC WC WT WB 
       BootServicesData 0000690e3000          0x0 00000007 UC WC WT WB 
       BootServicesCode 0000690ea000          0x0 0000002c UC WC WT WB 
       BootServicesData 000069116000          0x0 00000020 UC WC WT WB 
       BootServicesCode 000069136000          0x0 00000065 UC WC WT WB 
       BootServicesData 00006919b000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006919c000          0x0 00000003 UC WC WT WB 
       BootServicesData 00006919f000          0x0 00000001 UC WC WT WB 
       BootServicesCode 0000691a0000          0x0 00000005 UC WC WT WB 
       BootServicesData 0000691a5000          0x0 00000004 UC WC WT WB 
       BootServicesCode 0000691a9000          0x0 0000002b UC WC WT WB 
       BootServicesData 0000691d4000          0x0 00000004 UC WC WT WB 
       BootServicesCode 0000691d8000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000691da000          0x0 00000004 UC WC WT WB 
       BootServicesCode 0000691de000          0x0 00000012 UC WC WT WB 
       BootServicesData 0000691f0000          0x0 00000002 UC WC WT WB 
       BootServicesCode 0000691f2000          0x0 00000003 UC WC WT WB 
       BootServicesData 0000691f5000          0x0 00000001 UC WC WT WB 
       BootServicesCode 0000691f6000          0x0 0000001d UC WC WT WB 
       BootServicesData 000069213000          0x0 00000006 UC WC WT WB 
       BootServicesCode 000069219000          0x0 00000002 UC WC WT WB 
       BootServicesData 00006921b000          0x0 00000003 UC WC WT WB 
       BootServicesCode 00006921e000          0x0 00000001 UC WC WT WB 
       BootServicesData 00006921f000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000069221000          0x0 0000000c UC WC WT WB 
       BootServicesData 00006922d000          0x0 0000000b UC WC WT WB 
       BootServicesCode 000069238000          0x0 00000001 UC WC WT WB 
       BootServicesData 000069239000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006923a000          0x0 0000000c UC WC WT WB 
       BootServicesData 000069246000          0x0 00000400 UC WC WT WB 
       BootServicesCode 000069646000          0x0 00000071 UC WC WT WB 
       BootServicesData 0000696b7000          0x0 00000001 UC WC WT WB 
       BootServicesCode 0000696b8000          0x0 00000007 UC WC WT WB 
       BootServicesData 0000696bf000          0x0 00000001 UC WC WT WB 
       BootServicesCode 0000696c0000          0x0 00000001 UC WC WT WB 
       BootServicesData 0000696c1000          0x0 00000001 UC WC WT WB 
       BootServicesCode 0000696c2000          0x0 00000002 UC WC WT WB 
       BootServicesData 0000696c4000          0x0 00000003 UC WC WT WB 
       BootServicesCode 0000696c7000          0x0 00000003 UC WC WT WB 
       BootServicesData 0000696ca000          0x0 00000001 UC WC WT WB 
       BootServicesCode 0000696cb000          0x0 00000003 UC WC WT WB 
       BootServicesData 0000696ce000          0x0 00000002 UC WC WT WB 
       BootServicesCode 0000696d0000          0x0 00000005 UC WC WT WB 
       BootServicesData 0000696d5000          0x0 00000005 UC WC WT WB 
       BootServicesCode 0000696da000          0x0 00000007 UC WC WT WB 
       BootServicesData 0000696e1000          0x0 00000001 UC WC WT WB 
       BootServicesCode 0000696e2000          0x0 00000003 UC WC WT WB 
       BootServicesData 0000696e5000          0x0 00000002 UC WC WT WB 
       BootServicesCode 0000696e7000          0x0 00000005 UC WC WT WB 
       BootServicesData 0000696ec000          0x0 00000001 UC WC WT WB 
       BootServicesCode 0000696ed000          0x0 0000000e UC WC WT WB 
       BootServicesData 0000696fb000          0x0 00000002 UC WC WT WB 
       BootServicesCode 0000696fd000          0x0 0000000c UC WC WT WB 
       BootServicesData 000069709000          0x0 00000002 UC WC WT WB 
       BootServicesCode 00006970b000          0x0 00000001 UC WC WT WB 
       BootServicesData 00006970c000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006970d000          0x0 00000007 UC WC WT WB 
       BootServicesData 000069714000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000069715000          0x0 00000002 UC WC WT WB 
       BootServicesData 000069717000          0x0 00000003 UC WC WT WB 
       BootServicesCode 00006971a000          0x0 00000002 UC WC WT WB 
       BootServicesData 00006971c000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006971d000          0x0 00000005 UC WC WT WB 
       BootServicesData 000069722000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000069723000          0x0 00000001 UC WC WT WB 
       BootServicesData 000069724000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000069726000          0x0 00000001 UC WC WT WB 
       BootServicesData 000069727000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000069728000          0x0 00000001 UC WC WT WB 
       BootServicesData 000069729000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006972a000          0x0 00000018 UC WC WT WB 
       BootServicesData 000069742000          0x0 00000005 UC WC WT WB 
       BootServicesCode 000069747000          0x0 00000007 UC WC WT WB 
       BootServicesData 00006974e000          0x0 00000007 UC WC WT WB 
       BootServicesCode 000069755000          0x0 00000002 UC WC WT WB 
       BootServicesData 000069757000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000069759000          0x0 00000014 UC WC WT WB 
       BootServicesData 00006976d000          0x0 00000001 UC WC WT WB 
       BootServicesCode 00006976e000          0x0 00000001 UC WC WT WB 
       BootServicesData 00006976f000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000069770000          0x0 00000001 UC WC WT WB 
       BootServicesData 000069771000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000069772000          0x0 00000002 UC WC WT WB 
       BootServicesData 000069774000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000069776000          0x0 00000002 UC WC WT WB 
       BootServicesData 000069778000          0x0 00000001 UC WC WT WB 
       BootServicesCode 000069779000          0x0 00000001 UC WC WT WB 
       BootServicesData 00006977a000          0x0 00000004 UC WC WT WB 
       BootServicesCode 00006977e000          0x0 00000003 UC WC WT WB 
       BootServicesData 000069781000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000069783000          0x0 00000003 UC WC WT WB 
       BootServicesData 000069786000          0x0 00000002 UC WC WT WB 
       BootServicesCode 000069788000          0x0 00000001 UC WC WT WB 
       BootServicesData 000069789000          0x0 00000004 UC WC WT WB 
       BootServicesCode 00006978d000          0x0 00000003 UC WC WT WB 
       BootServicesData 000069790000          0x0 00000e43 UC WC WT WB 
    RuntimeServicesData 00006a5d3000   0x6a5d3000 00000100 UC WC WT WB RUNTIME
    RuntimeServicesCode 00006a6d3000   0x6a6d3000 00000100 UC WC WT WB RUNTIME
               Reserved 00006a7d3000          0x0 00000100 UC WC WT WB 
          ACPIMemoryNVS 00006a8d3000          0x0 00000a30 UC WC WT WB 
      ACPIReclaimMemory 00006b303000          0x0 00000100 UC WC WT WB 
       BootServicesData 00006b403000          0x0 000000a3 UC WC WT WB 
       BootServicesCode 00006b4a6000          0x0 00000033 UC WC WT WB 
       BootServicesData 00006b4d9000          0x0 000034e4 UC WC WT WB 
       BootServicesCode 00006e9bd000          0x0 00000010 UC WC WT WB 
       BootServicesData 00006e9cd000          0x0 0000001e UC WC WT WB 
       BootServicesCode 00006e9eb000          0x0 00000008 UC WC WT WB 
       BootServicesData 00006e9f3000          0x0 0000022b UC WC WT WB 
       BootServicesCode 00006ec1e000          0x0 0000001c UC WC WT WB 
       BootServicesData 00006ec3a000          0x0 00000092 UC WC WT WB 
     ConventionalMemory 00006eccc000          0x0 00000e34 UC WC WT WB 
     ConventionalMemory 000100000000          0x0 02f40000 UC WC WT WB 
     ConventionalMemory 00ebc0000000          0x0 03000000 UC WC WT WB 
               Reserved 0000000a0000          0x0 00000060 
               Reserved 00006fb00000          0x0 00010500 
         MemoryMappedIO 000080000000   0x80000000 00010000 UC RUNTIME
         MemoryMappedIO 0000fe000000   0xfe000000 00000011 UC RUNTIME
       PersistentMemory 003040000000          0x0 0bb80000 UC WC WT WB 
       PersistentMemory 011bc0000000          0x0 0bb80000 UC WC WT WB 
         MemoryMappedIO 01d740000000 0x1d740000000 00060000 UC RUNTIME
hw.physmem: 410888404992

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
sys/amd64/amd64/pmap.c
2464 ↗(On Diff #48536)

Yes, it should be DMAP_MIN_ADDRESS, consistently.

sys/amd64/amd64/pmap.c
2465 ↗(On Diff #48738)

If spa is a physical address, this test should simply be: spa < dmaplimit.

2467 ↗(On Diff #48738)

I believe that this should be PHYS_TO_DMAP(MIN(dmaplimit, epa))

Otherwise, epa wouldn't be converted to a virtual address.

2468 ↗(On Diff #48738)

if (dmaplimit >= epa)

2470 ↗(On Diff #48738)

spa = dmaplimit;

8253 ↗(On Diff #48738)

Stray space after =.

8257 ↗(On Diff #48738)

mphys = *pdpe & PG_FRAME;

8261 ↗(On Diff #48738)

This variable isn't needed. The analogous code in the previous function doesn't use an _idx variable.

8282 ↗(On Diff #48738)

mphys = *pde & PG_FRAME;

8285–8286 ↗(On Diff #48738)

This is written differently from the previous two functions.

sys/amd64/amd64/pmap.c
8347 ↗(On Diff #48738)

Why is this lock necessary? The address range that you are setting up the page table for is implicitly private to this thread by virtue of the fact that vmem won't give the same address range to any other thread.

sys/amd64/amd64/pmap.c
8519–8521 ↗(On Diff #48738)

What if the direct map was used by pmap_large_map()?

kib marked 11 inline comments as done.Oct 5 2018, 5:26 PM
kib added inline comments.
sys/amd64/amd64/pmap.c
8347 ↗(On Diff #48738)

Address spaces are distinct, but the page table structures might be not. For instance, both callers might want to allocate page table page for the same pdpe.

Apparently I forgot to handle the race.

Handle dropped lm_lock during the page allocation.
In pmap_large_map_wb(), handle direct map case. While there, ifunc-ify flushes.
Correct phys/va confusion.

sys/amd64/amd64/pmap.c
2467 ↗(On Diff #48793)

You need to remove "DMAP_MIN_ADDRESS +" here. It turns dmaplimit into a virtual address.

Remove excessive DMAP_MIN_ADDRESS.

sys/amd64/amd64/pmap.c
8235 ↗(On Diff #48793)

"... & PG_FRAME;"

sys/amd64/amd64/pmap.c
2318–2325 ↗(On Diff #48863)

This snippet had the effect of bounding the time that we could spend executing this function, regardless of the size of the address range. Now, without it, do we need to call maybe_yield() below?

kib marked an inline comment as done.Oct 7 2018, 6:47 PM
kib added inline comments.
sys/amd64/amd64/pmap.c
2318–2325 ↗(On Diff #48863)

I do not think that this is feasible. First, existing callers really use the function on the limited ranges. The largest are DRM buffers, I believe, which should be of several MBs. Second, callers could own non-sleepable locks, which makes the call undesirable.

In other words, I do not think that we need to add manual preemption there.

sys/amd64/amd64/pmap.c
8347 ↗(On Diff #48738)

Yes, upon further reflection, l see what the lock is doing for you. Also, am I correct in assuming that allocations and deallocations will be infrequent?

sys/amd64/amd64/pmap.c
8323 ↗(On Diff #48865)

Why not the following?

return (pmap_change_attr(va, len, mattr));
kib marked an inline comment as done.Oct 7 2018, 7:12 PM
kib added inline comments.
sys/amd64/amd64/pmap.c
8347 ↗(On Diff #48738)

Yes, intent is that the allocations are infrequent, and in fact done only during setup/teardown.

Current user, the NVDIMM driver, does one allocation per region on attach, and one deallocation on detach. In other words, this lock is not used during the normal operations at all.

I think that the other user of the interface could be Non-Transparent Bridge driver, where the usage would be the same.

Simplify code, calling pmap_change_attr() in tail position.

sys/amd64/amd64/pmap.c
8256 ↗(On Diff #48865)

Setting PG_G is pointless (except for a (super)page mapping). See, for example Table 4-16 in the latest Intel Volume 3.

8283 ↗(On Diff #48865)

Ditto.

sys/amd64/amd64/pmap.c
8347 ↗(On Diff #48738)

I would then argue for just using the kernel pmap lock here. We similarly use the kernel pmap lock for operations like demotion on the DMAP.

sys/amd64/amd64/pmap.c
8300 ↗(On Diff #48866)

Given the infrequent calls, I would suggest using M_BESTFIT here. (Even if our current vmem_xalloc(M_BESTFIT) is actually implementing a first-fit policy. It's still potentially a better fit than our M_FIRSTFIT. :-))

kib marked 3 inline comments as done.

Drop unneeded PG_Gs.
Use M_BESTFIT for vmem allocations.
Use kernel_pmap' lock instead of lm_lock.

I'm done.

sys/amd64/amd64/pmap.c
2446 ↗(On Diff #48868)

This seems somewhat ad hoc. If pmap_force_invalidate_cache_range() is called instead, then there is no call to maybe_yield(). And, whichever approach is used, pmap_flush_cache_phys_range() is also calling maybe_yield() at a page granularity. Can we eliminate the redundancy?

2458–2461 ↗(On Diff #48868)

Add an explicit "can sleep" assert?

8189 ↗(On Diff #48868)

I would suggest a block comment along these lines:

"Large map page table pages are managed differently from either kernel or user page table pages. The pdp pages are permanently allocated at initialization time, and their wire count is permanently set to zero. In contrast, pd and pt pages are managed like user page table pages. They are dynamically allocated, and their wire count represents the number of valid entries within the page."

8208 ↗(On Diff #48868)

With the introduction of the retry loop in the two callers, this loop is now redundant. Do the vm_wait() if m == NULL and unconditionally return the value of m. Then, you won't need to ever free a page in the callers.

8254 ↗(On Diff #48868)

You might as well preset X86_PG_A, since you're already doing at the leaf level.

8281 ↗(On Diff #48868)

You might as well preset X86_PG_A, since you're already doing at the leaf level.

8296 ↗(On Diff #48868)

/* Large mappings are all but static. Consequently, so there is no point in waiting for an earlier allocation to be freed. */

8399 ↗(On Diff #48868)

Shouldn't this be <=?

8403 ↗(On Diff #48868)

Shouldn't sva + len < be sva + len <=?

8423–8424 ↗(On Diff #48868)

Swap the order of these statements for consistency with the next case.

8427 ↗(On Diff #48868)

More simply, pde = pmap_pdpe_to_pde(pdpe, va); would suffice. You've already asserted everything that pmap_pdpe_to_pde() expects.

8449 ↗(On Diff #48868)

pte = pmap_pde_to_pte(pde, va);

8466 ↗(On Diff #48868)

For consistency, put this immediately after the above pte_clear().

8468–8469 ↗(On Diff #48868)

As a rule, we do TLB invalidates before releasing the pmap lock. More importantly, len is not correct; it should be the end address.

8610–8611 ↗(On Diff #48868)

Two things:

  1. There are too many negations. Neither/nor can be either/or.
  1. "..., the other ..."
1460–1461 ↗(On Diff #48866)

The number of slots will have no impact on whether vmem_create() succeeds. The required resources inside vmem will be the same regardless of the number of slots.

sys/amd64/include/pmap.h
428 ↗(On Diff #48868)

It's curious that the two surrounding functions take a void *, but this function takes a vm_offset_t.

kib marked 18 inline comments as done.Oct 9 2018, 6:57 PM
kib added inline comments.
sys/amd64/amd64/pmap.c
2458–2461 ↗(On Diff #48868)

I removed rest of yields instead.

8189 ↗(On Diff #48868)

I added a sentence explaining why pdp pages are preallocated.

sys/amd64/include/pmap.h
428 ↗(On Diff #48868)

pmap_large_map_wb() is more like pmap_invalidate_cache_range() in its operations. But I changed this to void * as well, it removes one cast from the actual consumer of the interface.

kib marked an inline comment as done.

Handle last batch of review notes.

I thought about the yielding issue some more. I think that at the end I would need to add an explicit argument to allow/disallow the yield, to the functions which can potentially operate over the very large regions. For now it is good enough to not yield and get the actual feedback from the real consumers of this stuff.

sys/amd64/amd64/pmap.c
8190 ↗(On Diff #48947)

Change "pml4e elements" to "pml4 entries" and "that pages" to "those pages".

sys/amd64/amd64/pmap.c
8187 ↗(On Diff #48947)

Given the two-paragraph structure, I would suggest:

"Pdp pages for the large map are managed ...

8188 ↗(On Diff #48947)

Shorten to "pages. They are permanently ..."

sys/amd64/amd64/pmap.c
8255–8258 ↗(On Diff #48947)

Can't this simply be

m = pmap_large_map_getptp();
if (m == NULL)
        goto retry;

Then, you don't need the vm_page_free_toq(m) below.

8282–8285 ↗(On Diff #48947)

Ditto.

These are my last comments.

sys/amd64/amd64/pmap.c
8305 ↗(On Diff #48947)

Drop the "so". It's redundant.

8465–8466 ↗(On Diff #48947)

Please swap the order of these two statements just for consistency with the previous two cases of like code in this function.

kib marked 5 inline comments as done.Oct 15 2018, 5:32 PM
kib marked an inline comment as done.Oct 15 2018, 5:39 PM
kib added inline comments.
sys/amd64/amd64/pmap.c
8255–8258 ↗(On Diff #48947)

*pdpe might become non-zero after the allocation, since the kernel_pmap lock is potentially dropped in pmap_large_map_getptp(). I.e. we cannot blindly assign to *pdpe without rechecking.

sys/amd64/amd64/pmap.c
8255–8258 ↗(On Diff #48947)

It's only dropped when NULL is returned, and it appears to me that on a goto retry you repeat the *pdpe == 0 check. If another thread installed a page table page while you were sleeping without the pmap lock, you won't come down this branch again. What am I missing?

kib marked 2 inline comments as done.

Simplify retry case as suggested.

This revision is now accepted and ready to land.Oct 16 2018, 2:39 PM

My only remaining unarticulated concern is that an errant call to pmap_large_map_wb_large() could allocate page table pages. (I think that function's outer loop should look more like pmap_protect() or pmap_remove().) However, assuming no errant calls, this revision looks good.

This revision was automatically updated to reflect the committed changes.
This revision is now accepted and ready to land.Oct 18 2018, 6:48 PM