CVSROOT: /cvs Module name: src Changes by: m...@cvs.openbsd.org 2025/07/23 16:58:00
Modified files: sys/kern : kern_sysctl.c Log message: Remove sleeping malloc(9) from complicated locking sysctl(2) locks, but keep kernel lock only around sensordev_get() and sensor_find(). We do copyout() of local buffer, while we hold no global data so possible context switch is absolutely safe. No reason to grab `sysctl_lock' rwlock(9) and wire pages with uvm_vslock(). Only kernel lock required to find sensor and copy data to local buffer. On amd64 the size of `us' is 72 bytes and the size of `usd' is 116 bytes. The stack usage of following sensordev_get() and sensor_find() will never exceed the limit, so allocate temporary buffer on stack instead of malloc(9) it. Use union as local buffer to keep pressure on stack small. Discussed with deraadt. ok claudio bluhm