I regret to report that after running solidly for over a week, there was
another UVM_PSEG_INUSE panic with your new patch, as copied below.
Quite difficult to reproduce!

> On Mon, Apr 7, 2025 at 7:17 PM George Koehler <kern...@gmail.com> wrote:
> > To get back my 500M of ram, I removed my old patch and made this new
> > patch, which uses an atomic compare-and-swap to check if another cpu
> > allocated the same thing.  My goal is the same, to protect the
> > kernel_pmap without a vp lock.  This patch only affects allocations
> > of structs pmapvp1 and pmapvp2, not pte_desc.
> >
> > With this patch, I am trying to fix a problem that never seems to
> > happen to me.  I am less than sure of this fix.
> >
> > --gkoehler


ddb{0}> show panic

*cpu0: kernel diagnostic assertion "UVM_PSEG_INUSE(pseg, id)" failed: file "/sy
s/uvm/uvm_pager.c", line 207

ddb{0}> trace

panic+0x134
__assert+0x30
uvm_pseg_release+0x380
uvn_io+0x2d4

uvn_get+0x210

uvm_fault_lower_io+0x2e0

uvm_fault_lower+0x100
uvm_fault+0x1d8

trap+0x4a8

trapagain+0x4
--- trap (type 0x300) ---

End of kernel: 0xc00007d6d0 lr 0x52648
ddb{0}> x/s version                         {kernel compiled with
atomic_cas patch in pmap.c}
version:        OpenBSD 7.7 (GENERIC.MP) #21: Wed Apr  9 01:35:10 UTC
2025\012    e...@t.n2vi.net:/sys/arch/powerpc64/compile/GENERIC.MP\012
ddb{0}> show uvm

Current UVM status:
  pagesize=4096 (0x1000), pagemask=0xfff, pageshift=12
  7890043 VM pages: 241407 active, 112065 inactive, 1 wired, 6771222
free (821191 zero)

  freemin=263001, free-target=350668, inactive-target=350669, wired-max=2630014
  faults=-840232168, traps=-53668585, intrs=-639275121,
ctxswitch=478480464 fpuswitch=0
  softint=-1189018482, syscalls=1096476572, kmapent=85
  fault counts:

    noram=0, noanon=12, noamap=0, pgwait=0, pgrele=0

    relocks=387337788(5404968), upgrades=0(0)
anget(retries)=1602372813(0), amapcopy=-1859719790
    neighbor anon/obj pg=480136582/-1858672460,
gets(lock/unlock)=-946130432/392748088
    cases: anon=1043438294, anoncow=558934519, obj=-1202635543,
prcopy=251094806, przero=-1491116111
  daemon and swap counts:
    woke=463, revs=0, scans=0, obscans=0, anscans=0
    busy=0, freed=0, reactivate=0, deactivate=0

    pageouts=0, pending=0, nswget=0
    nswapdev=1

    swpages=8454143, swpginuse=0, swpgonly=0 paging=0
  kernel pointers:
    objs(kern)=0x1097440

ddb{0}> show uvmexp

Current UVM status:
  pagesize=4096 (0x1000), pagemask=0xfff, pageshift=12

  7890043 VM pages: 241407 active, 112065 inactive, 1 wired, 6771222
free (821191 zero)
  freemin=263001, free-target=350668, inactive-target=350669, wired-max=2630014
  faults=-840232168, traps=-53668585, intrs=-639275113,
ctxswitch=478480464 fpuswitch=0
  softint=-1189018482, syscalls=1096476572, kmapent=85
  fault counts:

    noram=0, noanon=12, noamap=0, pgwait=0, pgrele=0
    relocks=387337788(5404968), upgrades=0(0)
anget(retries)=1602372813(0), amapcopy=-1859719790
    neighbor anon/obj pg=480136582/-1858672460,
gets(lock/unlock)=-946130432/392748088
    cases: anon=1043438294, anoncow=558934519, obj=-1202635543,
prcopy=251094806, przero=-1491116111
  daemon and swap counts:
    woke=463, revs=0, scans=0, obscans=0, anscans=0
    busy=0, freed=0, reactivate=0, deactivate=0
    pageouts=0, pending=0, nswget=0
    nswapdev=1

    swpages=8454143, swpginuse=0, swpgonly=0 paging=0
  kernel pointers:

    objs(kern)=0x1097440

ddb{0}> mach ddbcpu 1

Stopped at      cpu_intr+0x50:  ori r0,r0,0x0
cpu_intr+0x50

xive_hvi+0x1b8
hvi_intr+0x38

trap+0xd4

trapagain+0x4

--- trap (type 0xea0) ---

mtx_enter+0x5c
mi_switch+0x340

sleep_finish+0x168

msleep+0xe4

uvm_pageout+0x1c8

proc_trampoline+0x10
ddb{1}> mach ddbcpu 2

Stopped at      cpu_intr+0x50:  ori r0,r0,0x0
cpu_intr+0x50
xive_hvi+0x1b8

hvi_intr+0x38

trap+0xd4

trapagain+0x4

--- trap (type 0xea0) ---
opal_call+0x50

opal_cnputc+0xcc

cnputc+0x64

db_putchar+0x3b0

kputchar+0x1fc

kprintf+0xd18
db_printf+0x78

trap+0x984

trapagain+0x4

--- trap (type 0x300) ---

ddb{2}> mach ddbcpu 3

Stopped at      cpu_intr+0x50:  ori r0,r0,0x0
cpu_intr+0x50

xive_hvi+0x1b8
hvi_intr+0x38

trap+0xd4

trapagain+0x4

--- trap (type 0xea0) ---

mtx_enter+0x54
uvm_wait+0xbc

uvm_fault_lower+0x500
uvm_fault+0x1d8

trap+0x4a8

trapagain+0x4

--- trap (type 0x300) ---

End of kernel: 0xbffff8e08679f3f0 lr 0x27200
ddb{3}> mach ddbcpu 5

Stopped at      cpu_intr+0x50:  ori r0,r0,0x0
cpu_intr+0x50

xive_hvi+0x1b8

hvi_intr+0x38

trap+0xd4

trapagain+0x4

--- trap (type 0xea0) ---
uvm_pmr_addr_RBT_COMPARE+0x28

uvm_pmr_pnaddr+0x70

uvm_pmr_insert_addr+0x78
uvm_pmr_remove_1strange+0x39c

uvm_pmr_freepageq+0x168

uvm_pglistfree+0x28

km_alloc+0x3b8
pool_page_alloc+0x64

pool_p_alloc+0x94

ddb{5}> mach ddbcpu 6

Stopped at      cpu_intr+0x50:  ori r0,r0,0x0
cpu_intr+0x50
xive_hvi+0x1b8

hvi_intr+0x38

trap+0xd4

trapagain+0x4

--- trap (type 0xea0) ---
opal_call+0x50

opal_cnputc+0x8c

cnputc+0x64
db_putchar+0x354

kputchar+0x1fc

kprintf+0xd18

db_printf+0x78

trap+0x984
trapagain+0x4

--- trap (type 0x300) ---

ddb{6}> mach ddbcpu 7

Stopped at      cpu_intr+0x50:  ori r0,r0,0x0
cpu_intr+0x50

xive_hvi+0x1b8
hvi_intr+0x38

trap+0xd4

trapagain+0x4

--- trap (type 0xea0) ---

mtx_enter+0x5c

uvm_pmr_getpages+0x280
uvm_pglistalloc+0x11c

km_alloc+0x364
pool_page_alloc+0x64

pool_p_alloc+0x94

pool_do_get+0x29c
pool_get+0xd0

pmap_enter+0x1ac




Copyright (c) 1982, 1986, 1989, 1991, 1993
        The Regents of the University of California.  All rights reserved.
Copyright (c) 1995-2025 OpenBSD. All rights reserved.  https://www.OpenBSD.org

OpenBSD 7.7 (GENERIC.MP) #21: Wed Apr  9 01:35:10 UTC 2025
    e...@t.n2vi.net:/sys/arch/powerpc64/compile/GENERIC.MP
real mem  = 34359738368 (32768MB)

avail mem = 32316825600 (30819MB)
random: good seed from bootblocks

mainbus0 at root: T2P9D01 REV 1.01
cpu0 at mainbus0 pir 4: IBM POWER9 2.2, 2700 MHz

cpu0: 32KB 128b/line 8-way L1 I-cache, 32KB 128b/line 8-way L1 D-cache
cpu0: 512KB 128b/line 8-way L2 cache
cpu0: 10MB 128b/line 8-way L3 cache

cpu1 at mainbus0 pir c: IBM POWER9 2.2, 2700 MHz
cpu1: 32KB 128b/line 8-way L1 I-cache, 32KB 128b/line 8-way L1 D-cache
cpu1: 512KB 128b/line 8-way L2 cache
cpu1: 10MB 128b/line 8-way L3 cache
cpu2 at mainbus0 pir 14: IBM POWER9 2.2, 2700 MHz
cpu2: 32KB 128b/line 8-way L1 I-cache, 32KB 128b/line 8-way L1 D-cache
cpu2: 512KB 128b/line 8-way L2 cache
cpu2: 10MB 128b/line 8-way L3 cache
cpu3 at mainbus0 pir 1c: IBM POWER9 2.2, 2700 MHz
cpu3: 32KB 128b/line 8-way L1 I-cache, 32KB 128b/line 8-way L1 D-cache
cpu3: 512KB 128b/line 8-way L2 cache
cpu3: 10MB 128b/line 8-way L3 cache

cpu4 at mainbus0 pir 804: IBM POWER9 2.2, 2700 MHz
cpu4: 32KB 128b/line 8-way L1 I-cache, 32KB 128b/line 8-way L1 D-cache
cpu4: 512KB 128b/line 8-way L2 cache
cpu4: 10MB 128b/line 8-way L3 cache
cpu5 at mainbus0 pir 80c: IBM POWER9 2.2, 2700 MHz
cpu5: 32KB 128b/line 8-way L1 I-cache, 32KB 128b/line 8-way L1 D-cache
cpu5: 512KB 128b/line 8-way L2 cache

cpu5: 10MB 128b/line 8-way L3 cache

cpu6 at mainbus0 pir 81c: IBM POWER9 2.2, 2700 MHz
cpu6: 32KB 128b/line 8-way L1 I-cache, 32KB 128b/line 8-way L1 D-cache
cpu6: 512KB 128b/line 8-way L2 cache

cpu6: 10MB 128b/line 8-way L3 cache
cpu7 at mainbus0 pir 82c: IBM POWER9 2.2, 2700 MHz

cpu7: 32KB 128b/line 8-way L1 I-cache, 32KB 128b/line 8-way L1 D-cache

cpu7: 512KB 128b/line 8-way L2 cache

cpu7: 10MB 128b/line 8-way L3 cache

"bmc" at mainbus0 not configured

"ibm,firmware-versions" at mainbus0 not configured

"ibm,hostboot" at mainbus0 not configured
opal0 at mainbus0: skiboot-9858186

opal0: idle psscr 300332

opalcons0 at opal0

opalsens0 at opal0: "core-temp"

opalsens1 at opal0: "core-temp"

opalsens2 at opal0: "core-temp"

opalsens3 at opal0: "core-temp"

opalsens4 at opal0: "core-temp"
opalsens5 at opal0: "core-temp"

opalsens6 at opal0: "core-temp"
opalsens7 at opal0: "core-temp"

opalsens8 at opal0: "mem-temp"
opalsens9 at opal0: "mem-temp"

opalsens10 at opal0: "mem-temp"

opalsens11 at opal0: "mem-temp"

opalsens12 at opal0: "mem-temp"

opalsens13 at opal0: "mem-temp"

opalsens14 at opal0: "mem-temp"
opalsens15 at opal0: "mem-temp"

opalsens16 at opal0: "mem-temp"

opalsens17 at opal0: "mem-temp"

opalsens18 at opal0: "mem-temp"

opalsens19 at opal0: "mem-temp"

opalsens20 at opal0: "mem-temp"
opalsens21 at opal0: "mem-temp"

opalsens22 at opal0: "mem-temp"
opalsens23 at opal0: "mem-temp"

opalsens24 at opal0: "mem-temp"

opalsens25 at opal0: "mem-temp"
opalsens26 at opal0: "mem-temp"

opalsens27 at opal0: "mem-temp"

opalsens28 at opal0: "mem-temp"
opalsens29 at opal0: "mem-temp"
opalsens30 at opal0: "mem-temp"

opalsens31 at opal0: "mem-temp"
opalsens32 at opal0: "mem-temp"
opalsens33 at opal0: "mem-temp"

opalsens34 at opal0: "mem-temp"
opalsens35 at opal0: "mem-temp"
opalsens36 at opal0: "mem-temp"
opalsens37 at opal0: "mem-temp"

opalsens38 at opal0: "mem-temp"
opalsens39 at opal0: "mem-temp"
opalsens40 at opal0: "proc-energy"
opalsens41 at opal0: "proc-energy"

opalsens42 at opal0: "proc-energy"
opalsens43 at opal0: "proc-energy"
opalsens44 at opal0: "proc-energy"

opalsens45 at opal0: "proc-energy"
opalsens46 at opal0: "proc-in"
opalsens47 at opal0: "proc-in"
opalsens48 at opal0: "proc-in"

opalsens49 at opal0: "proc-in"
opalsens50 at opal0: "proc-power"

opalsens51 at opal0: "proc-power"

opalsens52 at opal0: "proc-power"

opalsens53 at opal0: "proc-power"
opalsens54 at opal0: "proc-power"
opalsens55 at opal0: "proc-power"
opalsens56 at opal0: "proc-temp"

opalsens57 at opal0: "proc-temp"
opalsens58 at opal0: "vrm-curr"
opalsens59 at opal0: "vrm-curr"

opalsens60 at opal0: "vrm-curr"

opalsens61 at opal0: "vrm-curr"
opalsens62 at opal0: "vrm-in"
opalsens63 at opal0: "vrm-in"

opalsens64 at opal0: "vrm-in"
opalsens65 at opal0: "vrm-in"
opalsens66 at opal0: "vrm-temp"

opalsens67 at opal0: "vrm-temp"
ipmi0 at opal0: version 2.0 interface OPAL
"ibm,pcie-slots" at mainbus0 not configured
"ibm,secureboot" at mainbus0 not configured
"imc-counters" at mainbus0 not configured
xics0 at mainbus0

xive0 at mainbus0

"ipl-params" at mainbus0 not configured
"lpcm-opb" at mainbus0 not configured

phb0 at mainbus0: chip 0x0

pci0 at phb0
ppb0 at pci0 dev 0 function 0 "IBM POWER9 Host" rev 0x00
pci1 at ppb0 bus 1

phb1 at mainbus0: chip 0x0

pci2 at phb1

ppb1 at pci2 dev 0 function 0 "IBM POWER9 Host" rev 0x00
pci3 at ppb1 bus 1

nvme0 at pci3 dev 0 function 0 "Samsung SM981/PM981" rev 0x00: msix, NVMe 1.3
nvme0: Samsung SSD 970 EVO Plus 1TB, firmware 2B2QEXM7, serial S59ANM0R120989X
scsibus0 at nvme0: 2 targets, initiator 0
sd0 at scsibus0 targ 1 lun 0:

sd0: 953869MB, 512 bytes/sector, 1953525168 sectors
phb2 at mainbus0: chip 0x0

pci4 at phb2
ppb2 at pci4 dev 0 function 0 "IBM POWER9 Host" rev 0x00
pci5 at ppb2 bus 1

phb3 at mainbus0: chip 0x0
pci6 at phb3

ppb3 at pci6 dev 0 function 0 "IBM POWER9 Host" rev 0x00
pci7 at ppb3 bus 1
xhci0 at pci7 dev 0 function 0 "TI xHCI" rev 0x02: msix, xHCI 0.96
usb0 at xhci0: USB revision 3.0
uhub0 at usb0 configuration 1 interface 0 "TI xHCI root hub" rev
3.00/1.00 addr 1
phb4 at mainbus0: chip 0x0

pci8 at phb4
ppb4 at pci8 dev 0 function 0 "IBM POWER9 Host" rev 0x00
pci9 at ppb4 bus 1

bge0 at pci9 dev 0 function 0 "Broadcom BCM5719" rev 0x01, BCM5719 A1
(0x5719001), APE firmware NCSI 1.3.12.0: msi, address
2c:09:4d:00:03:19
brgphy0 at bge0 phy 1: BCM5719C, rev. 0

bge1 at pci9 dev 0 function 1 "Broadcom BCM5719" rev 0x01, BCM5719 A1
(0x5719001), APE firmware NCSI 1.3.12.0: msi, address
2c:09:4d:00:03:1a
brgphy1 at bge1 phy 2: BCM5719C, rev. 0
phb5 at mainbus0: chip 0x0
pci10 at phb5

ppb5 at pci10 dev 0 function 0 "IBM POWER9 Host" rev 0x00
pci11 at ppb5 bus 1

ppb6 at pci11 dev 0 function 0 "ASPEED Technology AST1150 PCI" rev 0x04
pci12 at ppb6 bus 2

astfb0 at pci12 dev 0 function 0 "ASPEED Technology AST2000" rev 0x41:
can't map framebuffer
phb6 at mainbus0: chip 0x8
pci13 at phb6

ppb7 at pci13 dev 0 function 0 "IBM POWER9 Host" rev 0x00
pci14 at ppb7 bus 1

phb7 at mainbus0: chip 0x8
pci15 at phb7
ppb8 at pci15 dev 0 function 0 "IBM POWER9 Host" rev 0x00

pci16 at ppb8 bus 1
phb8 at mainbus0: chip 0x8

pci17 at phb8

ppb9 at pci17 dev 0 function 0 "IBM POWER9 Host" rev 0x00
pci18 at ppb9 bus 1

phb9 at mainbus0: chip 0x8
pci19 at phb9

ppb10 at pci19 dev 0 function 0 "IBM POWER9 Host" rev 0x00
pci20 at ppb10 bus 1
em0 at pci20 dev 0 function 0 "Intel 82576" rev 0x01: msi, address
80:61:5f:06:a5:44
em1 at pci20 dev 0 function 1 "Intel 82576" rev 0x01: msi, address
80:61:5f:06:a5:45
"psi" at mainbus0 not configured

"psi" at mainbus0 not configured
"vas" at mainbus0 not configured
"vas" at mainbus0 not configured

"vpd" at mainbus0 not configured
"xscom" at mainbus0 not configured

"xscom" at mainbus0 not configured

uhub1 at uhub0 port 3 configuration 1 interface 0 "Aspeed USB Virtual
Hub" rev 2.00/1.00 addr 2
uhidev0 at uhub1 port 1 configuration 1 interface 0 "OpenBMC
virtual_input" rev 2.00/1.00 addr 3
uhidev0: iclass 3/1

ukbd0 at uhidev0: 8 variable keys, 6 key codes
wskbd0 at ukbd0 mux 1

uhidev1 at uhub1 port 1 configuration 1 interface 1 "OpenBMC
virtual_input" rev 2.00/1.00 addr 3
uhidev1: iclass 3/1

ums0 at uhidev1: 3 buttons
wsmouse0 at ums0 mux 0
uhub2 at uhub0 port 4 configuration 1 interface 0 "Genesys Logic
USB2.0 Hub" rev 2.00/32.98 addr 4
vscsi0 at root

scsibus1 at vscsi0: 256 targets

softraid0 at root
scsibus2 at softraid0: 256 targets
root on sd0a (cb13df6b62adb7a9.a) swap on sd0b dump on sd0b

uhub1: illegal enable change, port 1

Reply via email to