OpenBSD cvs log

created 2024-12-01T08:33:06Z
begin 2024-11-27T00:00:00Z
end 2024-11-28T00:00:00Z
path src/sys
commits 16

date 2024-11-27T01:02:03Z
author dlg
files src/sys/kern/kern_rwlock.c log diff annotate
src/sys/sys/rwlock.h log diff annotate
message rework rwlocks to reduce pressure on the scheduler and SCHED_LOCK

it's become obvious that heavily contended rwlocks put a lot of
pressure on the scheduler, and we have enough contended locks that
there's a benefit to changing rwlocks to try and mitigate against
that pressure.

when a thread is waiting on an rwlock, it sets a bit in the rwlock
to indicate that when the current owner of the rwlock leaves the
critical section, it should wake up the waiting thread to try and
take the lock. if there's no waiting thread, the owner can skip the
wakeup.

the problem is that rwlocks can't tell the difference between one
waiting thread and more than one waiting thread. so when the "there's
a thread waiting" bit is cleared, all the waiting threads are woken
up. one of these woken threads will take ownership of the lock, but
also importantly, the other threads will end up setting the "im
waiting" bit again, which is necessary for them to be woken up by
the 2nd thread that won the race to become the owner of the lock.

this is compounded by pending writers and readers waiting on the
same wait channel. an rwlock may have one pending writer trying to
take the lock, but many readers waiting for it too. it would make
sense to wake up only the writer so it can take the lock next, but
we end up waking the readers at the same time.

the result of this is that contended rwlocks wake up a lot of
threads, which puts a lot of pressure on the scheduler. this is
noticeable as a lot of contention on the scheduler lock, which
is a spinning lock that increases time used by the system. this is
a pretty classic thundering herd problem.

this change mitigates against these wakeups by adding counters
to rwlocks for the number threads waiting to take write and read
locks instead of relying on bits. when a thread needs to wait for
a rwlock it increments the relevant counter before sleeping. after
it is woken up and takes the lock it decrements that counter. this
means rwlocks know how many threads are waiting at all times without
having to wake everything up to rebuild state every time a thread
releases the lock.

pending writers and readers also wait on separate wchans. this
allows us to prioritise writers and to wake them up one at a time.
once there's no pending writers all pending readers can be woken
up in one go so they can share the lock as soon as possible.

if you are suffering a contended rwlock, this should reduce the
amount of time spent spinning on the sched lock, which in turn may
also reduce the wall clock time doing that work.

the only downside to this change in my opinion is that it grows
struct rwlock by 8 bytes. if we can reduce rwlock contention in the
future, i reckon i could shrink the rwlock struct again while still
avoiding some of the scheduler interactions.

work with claudio@
ok claudio@ mpi@ stsp@
testing by many including claudio@ landry@ stsp@ sthen@ phessler@ tb@
and mark patruck

date 2024-11-27T02:14:48Z
author jsg
files src/sys/dev/pv/xen.c log diff annotate
message zero attach args; return on missing properties will be removed

date 2024-11-27T02:38:35Z
author jsg
files src/sys/dev/pv/xen.c log diff annotate
message continue enumerating devices if a device is not matched

fixes xbf(4) and xnf(4) not attaching on XCP-ng 8.3/Xen 4.17
which has "device/9pfs/"

from Joel Knight

date 2024-11-27T02:40:53Z
author yasuoka
files src/sys/dev/pci/if_iavf.c log diff annotate
message Enable rx/tx checksum offloading on ivaf(4).
from Yuichiro NAITO and jan; test jan

ok jan jmatthew

date 2024-11-27T05:25:56Z
author anton
files src/sys/arch/amd64/amd64/process_machdep.c log diff annotate
message Add ptrace commands used to read/write the XSAVE area of a traced
process. Intended to give debuggers access to xmm/ymm registers.

Inspired by FreeBSD which exposes a similar set of ptrace commands.

ok kettenis@

date 2024-11-27T05:25:57Z
author anton
files src/sys/arch/amd64/include/ptrace.h log diff annotate
src/sys/kern/sys_process.c log diff annotate
message Add ptrace commands used to read/write the XSAVE area of a traced
process. Intended to give debuggers access to xmm/ymm registers.

Inspired by FreeBSD which exposes a similar set of ptrace commands.

ok kettenis@

date 2024-11-27T10:09:51Z
author mpi
files src/sys/arch/amd64/amd64/vmm_machdep.c log diff annotate
message Use uvm_fault_wire() for consistency and to keep VM_FAULT_WIRE usage in uvm/.

ok dv@, mlarkin@

date 2024-11-27T10:33:31Z
author jsg
files src/sys/arch/amd64/amd64/conf.c log diff annotate
src/sys/arch/i386/i386/conf.c log diff annotate
message remove #if 0'd entries for /dev/pcmcia functions removed in 1998

date 2024-11-27T10:41:38Z
author mpi
files src/sys/uvm/uvm_aobj.c log diff annotate
src/sys/uvm/uvm_vnode.c log diff annotate
message Change pgo_get() interface in preparation for running PGO_LOCKED in parallel.

- Do not allocate zero-fill'd pages in uao_get(), leave that for PGO_SYNCIO.
- Reduce cosmetic differences between uvn_get() and uao_get()

ok tb@

date 2024-11-27T10:58:07Z
author mpi
files src/sys/uvm/uvm_fault.c log diff annotate
message Neighbor (fault ahead) pages are never mapped with the wired attribute.

Wired faults are always "narrow". That means the fault handler do not try to
fault neighbor pages ahead. So do not propagate the `flt->wired' attribute to
the corresponding pmap_enter(9) calls and instead assert that it is false
whenever neighbor pages are entered in a memory space.

ok tb@

date 2024-11-27T11:37:23Z
author kirill
files src/sys/dev/usb/uvideo.c log diff annotate
message sys/uvideo: add missed abort of transfer pipe in uvideo_vs_close

A bulk transfer cannot timeout and must be aborted on close.

OK mpi@

date 2024-11-27T12:29:14Z
author jsg
files src/sys/kern/sys_process.c log diff annotate
message remove unneeded fpu.h include to unbreak the build on archs without it
already indirectly included by reg.h on amd64
ok sthen@

date 2024-11-27T13:26:42Z
author jan
files src/sys/dev/fdt/virtio_mmio.c log diff annotate
src/sys/dev/pci/virtio_pci.c log diff annotate
src/sys/dev/pv/if_vio.c log diff annotate
src/sys/dev/pv/virtio.c log diff annotate
src/sys/dev/pv/virtiovar.h log diff annotate
message Revert "vio: Unlock"

This causes some crashes. Revert for now

ok sf@

date 2024-11-27T15:23:58Z
author stsp
files src/sys/dev/pci/if_ice.c log diff annotate
message defer creation of ice(4) ifp until device attachment has succeeded

Otherwise we would crash when something goes wrong in ice_attach_hook().

problem found by bluhm@

date 2024-11-27T20:11:32Z
author miod
files src/sys/arch/sparc64/sparc64/locore.s log diff annotate
message Change getfp() to return an unBIASed stack pointer; this unbreaks
stackdump() which got broken in machdep.c 1.202.

It is much simpler to change getfp() than stackdump() which is its only
caller.

date 2024-11-27T20:30:15Z
author gkoehler
files src/sys/arch/powerpc64/powerpc64/pmap.c log diff annotate
message In powerpc64 pmap, when replacing a pte, put it in the correct pteg

In pte_insert(), if both the primary page table entry group and the
secondary pteg are full, then we delete an old pte and replace it with
the new pte. We might have set "idx" wrong and inserted the new pte
into the wrong pteg (with the wrong PTE_HID bit). This problem almost
never happened; it is rare for both ptegs to be full.

When the loop "for (try = 0; try < 16; try++)" looks for a slot for
the new pte, set "idx" to the new pte's primary pteg. Put it in the
primary pteg "idx" or secondary pteg "idx ^ pmap_ptab_mask". When we
delete the old pte, set "idx" to the old pte's primary pteg.

Eric Gosse reported a bug where the kernel crashed on an unexpected
fault. I suspect that a pte fell into the wrong "idx" and got lost.

ok kettenis@