CVS: cvs.openbsd.org: src

2024-10-02 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/10/02 04:36:33

Modified files:
sys/uvm: uvm_pdaemon.c 

Log message:
Modify uvmpd_scan_inactive() to access `uvmexp.pdfreed' only once.

ok kettenis@



CVS: cvs.openbsd.org: src

2024-10-02 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/10/02 04:17:28

Modified files:
sys/uvm: uvm_pmemrange.c uvm_pmemrange.h 

Log message:
Return number of freed pages in uvm_pmr_cache_drain().

ok kettenis@



CVS: cvs.openbsd.org: src

2024-09-30 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/09/30 02:09:39

Modified files:
sys/uvm: uvm_pdaemon.c 
sys/dev/pci/drm: drm_linux.c 

Log message:
Return the number of freed pages and handle SHRINK_STOP in drmbackoff().

ok jsg@



CVS: cvs.openbsd.org: src

2024-09-06 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/09/06 02:21:21

Modified files:
sys/kern   : kern_exit.c 

Log message:
Remove incorrect increment of the context switch counter.

>From Christian Ludwig.

ok claudio@



CVS: cvs.openbsd.org: src

2024-09-06 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/09/06 02:00:36

Modified files:
regress/usr.sbin/btrace: Makefile multismts.bt 
Added files:
regress/usr.sbin/btrace: printf.bt printf.ok 

Log message:
Regression for '%c'.

>From Christian Ludwig.



CVS: cvs.openbsd.org: src

2024-09-06 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/09/06 01:58:50

Modified files:
usr.sbin/btrace: printf.c 

Log message:
Interpret the argument of '%c' as an integer instead of a string.

>From Christian Ludwig.



CVS: cvs.openbsd.org: src

2024-08-24 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/08/24 04:46:43

Modified files:
sys/uvm: uvm_extern.h uvm_km.c 

Log message:
Place uvm_km_zalloc(9) under #ifdef __i386__.

This allocator is only used by a single pmap which will be hopefully
converted.

Suggested by guenther@



CVS: cvs.openbsd.org: src

2024-08-24 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/08/24 04:38:44

Modified files:
sys/uvm: uvm_extern.h uvm_km.c 

Log message:
Kill uvm_km_alloc(9) and uvm_km_alloc1(9).

ok guenther@



CVS: cvs.openbsd.org: src

2024-08-21 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/08/21 03:27:37

Modified files:
sys/dev/dt : dt_dev.c 

Log message:
Read events from all PCBs as long as there's no error.

>From Christian Ludwig.



CVS: cvs.openbsd.org: src

2024-08-18 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/08/18 02:23:58

Modified files:
sys/dev/dt : dt_dev.c 

Log message:
Get rid of intermediate copy before passing events to userland.

>From Christian Ludwig with some tweaks.



CVS: cvs.openbsd.org: src

2024-08-18 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/08/18 02:18:49

Modified files:
sys/uvm: uvm_pmemrange.c 

Log message:
Do not cache pages belonging to memory ranges with a `use' count.

Such pages belong to the DMA or ISA memory ranges and caching them
accelerate their exhaustion.  On amd64, at least, the kernel relies
on having low pages available at any time and cannot recover from
their exhaustion.

Should prevent livelocks reported by jsg@ and tb@ on amd64.

ok deraadt@



CVS: cvs.openbsd.org: src

2024-08-18 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/08/18 02:01:03

Modified files:
sys/kern   : subr_hibernate.c 

Log message:
Remove outdated comment about UVM_PLA_WAITOK and the pagedaemon.

ok miod@, mlarkin@



CVS: cvs.openbsd.org: src

2024-08-17 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/08/17 07:35:01

Modified files:
sys/arch/mips64/mips64: cpu.c 

Log message:
Use km_alloc(9) to allocate USPACE instead of uvm_pglistalloc(9).

ok miod@



CVS: cvs.openbsd.org: src

2024-08-16 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/08/16 10:19:03

Modified files:
sys/kern   : kern_exit.c kern_fork.c 

Log message:
Atomically modify `nthreads' and move proc_free() out of KERNEL_LOCK().

ok jca@



CVS: cvs.openbsd.org: src

2024-07-24 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/07/24 06:18:10

Modified files:
sys/uvm: uvm_pager.c 

Log message:
Remove workaround for lock ordering issue in uvm_pseg_get().

Now that uvm_unmap_detach() no longer grab the KERNEL_LOCK() it should be
safe to call it with the `uvm_pseg_lck' mutex held via uvm_km_valloc_try().

ok jca@, claudio@



CVS: cvs.openbsd.org: src

2024-07-24 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/07/24 06:17:31

Modified files:
sys/kern   : kern_exit.c 
sys/uvm: uvm_extern.h uvm_map.c 

Log message:
Move uvm_exit() outside of the KERNEL_LOCK() in the reaper.

Use atomic operations to reference count VM spaces.

Tested by claudio@, bluhm@, sthen@, jca@

ok jca@, claudio@



CVS: cvs.openbsd.org: src

2024-07-24 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/07/24 06:16:21

Modified files:
sys/uvm: uvm_vnode.c 

Log message:
Grab the kernel lock in preparation for unlocking most of uvm_unmap_detach().

ok jca@, claudio@



CVS: cvs.openbsd.org: src

2024-07-24 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/07/24 06:15:55

Modified files:
sys/uvm: uvm_device.c 

Log message:
Remove assertion in udv_detach(), the function is already mpsafe.

ok jca@, claudio@



CVS: cvs.openbsd.org: src

2024-07-09 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/07/09 10:08:30

Modified files:
usr.sbin/btrace: btrace.c 

Log message:
Read the whole buffer, not its size minus one.

>From Christian Ludwig cludwig at genua.de.



CVS: cvs.openbsd.org: src

2024-07-08 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/07/08 10:15:42

Modified files:
sys/kern   : kern_sched.c 

Log message:
Remove the KASSERT() in sched_unpeg_curproc().

This fix rebooting a GENERIC.MP kernel on SP machines because unpeg is out
of the loop in smr_thread().



CVS: cvs.openbsd.org: src

2024-07-08 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/07/08 08:46:47

Modified files:
sys/arch/amd64/amd64: identcpu.c 
sys/dev: kstat.c 
sys/kern   : kern_sched.c kern_smr.c 
sys/sys: sched.h 

Log message:
Introduce sched_unpeg_curproc() to abstract the current implementation.

ok kettenis@, mlarkin@, miod@, claudio@



CVS: cvs.openbsd.org: src

2024-05-30 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/05/30 04:56:24

Modified files:
sys/arch/i386/i386: pmapae.c 

Log message:
Ensure pmap_create() waits in case kernel virtual space shortage.

Prevents a panic in pmap_pinit_pd_pae() when applying a lot of memory
pressure and the kernel needs time to recover while swapping.

Reported and fix tested by mvs@, also tested by sthen@

ok mlarkin@, mvs@, kettenis@



CVS: cvs.openbsd.org: src

2024-05-01 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/05/01 06:54:27

Modified files:
sys/arch/amd64/include: cpu.h 
sys/arch/arm64/include: cpu.h 
sys/arch/i386/include: cpu.h 
sys/uvm: uvm_page.c uvm_pdaemon.c uvm_percpu.h 
 uvm_pmemrange.c uvm_pmemrange.h uvmexp.h 
usr.bin/systat : uvm.c 
usr.bin/vmstat : vmstat.c 

Log message:
Add per-CPU caches to the pmemrange allocator.

The caches are used primarily to reduce contention on uvm_lock_fpageq() during
concurrent page faults.  For the moment only uvm_pagealloc() tries to get a
page from the current CPU's cache.  So on some architectures the caches are
also used by the pmap layer.

Each cache is composed of two magazines, design is borrowed from jeff bonwick
vmem's paper and the implementation is similar to the one of pool_cache from
dlg@.  However there is no depot layer and magazines are refilled directly by
the pmemrange allocator.

This version includes splvm()/splx() dances because the buffer cache flips
buffers in interrupt context.  So we have to prevent recursive accesses to
per-CPU magazines.

Tested by naddy@, solene@, krw@, robert@, claudio@ and Laurence Tratt.

ok claudio@, kettenis@



CVS: cvs.openbsd.org: src

2024-04-19 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/04/19 04:22:51

Modified files:
sys/arch/amd64/include: cpu.h 
sys/arch/arm64/include: cpu.h 
sys/arch/i386/include: cpu.h 
sys/uvm: uvm_page.c uvm_pdaemon.c uvm_percpu.h 
 uvm_pmemrange.c uvm_pmemrange.h uvmexp.h 
usr.bin/systat : uvm.c 
usr.bin/vmstat : vmstat.c 

Log message:
Revert per-CPU caches a double-free has been found by naddy@.



CVS: cvs.openbsd.org: src

2024-04-17 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/04/17 07:17:31

Modified files:
sys/uvm: uvm_amap.c 

Log message:
Remove a micro optimization to free pages in batch in amap_wipeout().

The contention on uvm_lock_fpageq() is now reduced by using per-CPU caches,
so we want to put pages on the cache and not give them back directly to the
allocator.

ok kettenis@



CVS: cvs.openbsd.org: src

2024-04-17 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/04/17 07:12:58

Modified files:
usr.bin/systat : uvm.c 
usr.bin/vmstat : vmstat.c 
sys/arch/amd64/include: cpu.h 
sys/arch/arm64/include: cpu.h 
sys/arch/i386/include: cpu.h 
sys/uvm: uvm_page.c uvm_pdaemon.c uvm_pmemrange.c 
 uvm_pmemrange.h uvmexp.h 
Added files:
sys/uvm: uvm_percpu.h 

Log message:
Add per-CPU caches to the pmemrange allocator.

The caches are used primarily to reduce contention on uvm_lock_fpageq() during
concurrent page faults.  For the moment only uvm_pagealloc() tries to get a
page from the current CPU's cache.  So on some architectures the caches are
also used by the pmap layer.

Each cache is composed of two magazines, design is borrowed from jeff bonwick
vmem's paper and the implementation is similar to the one of pool_cache from
dlg@.  However there is no depot layer and magazines are refilled directly by
the pmemrange allocator.

Tested by robert@, claudio@ and Laurence Tratt.

ok kettenis@



CVS: cvs.openbsd.org: src

2024-04-16 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/04/16 02:53:02

Modified files:
sys/uvm: uvm_amap.c 

Log message:
Prevent a NULL dereference in error code path.

Under memory pressure allocating an amap chunk can fail.  In such case it
is not possible to call amap_wipeout() because the newly allocated amap
isn't yet on the global list.

Issue reported by bluhm@, ok jsg@



CVS: cvs.openbsd.org: src

2024-04-10 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/04/10 09:38:11

Modified files:
sys/arch/alpha/alpha: cpu.c 

Log message:
Use km_alloc(9) to allocate USPACE instead of uvm_pglistalloc(9).

ok miod@



CVS: cvs.openbsd.org: src

2024-04-10 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/04/10 09:26:18

Modified files:
sys/uvm: uvm_pdaemon.c 

Log message:
Use uvmpd_dropswap() in the case of swap shortage.

ok kn@, kettenis@, miod@



CVS: cvs.openbsd.org: src

2024-04-10 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/04/10 09:25:14

Modified files:
sys/uvm: uvm_aobj.c 

Log message:
Call uao_dropswap() instead of rerolling it.

ok kn@, kettenis@, miod@



CVS: cvs.openbsd.org: src

2024-04-06 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/04/06 05:18:02

Modified files:
sys/dev/dt : dt_dev.c dt_prov_kprobe.c dt_prov_profile.c 
 dt_prov_static.c dt_prov_syscall.c dtvar.h 

Log message:
Remove (unused) in-kernel event filtering, it's currently dead code.

All events are currently exported to userland in order to support complex
filters.  If this becomes a bottleneck it should be possible to translate
(some) user-land filters to in-kernel fitlers.

Prodded by a diff from Christian Ludwig to also trace the tracing program.

ok claudio@



CVS: cvs.openbsd.org: src

2024-04-06 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/04/06 04:59:52

Modified files:
sys/uvm: uvm_anon.c 

Log message:
Prevent accounting bug when an anon w/ swap slot is passed to uvm_anon_release()

uvm_anon_release() is always called for anon that have an associated page so
decrementing `uvmexp.swpgonly' is incorrect.  This happened because the page
was cleared before calling uvm_anfree().

Reported by many including mvs@, miod@ and robert@

ok kettenis@, miod@



CVS: cvs.openbsd.org: src

2024-03-30 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/03/30 07:33:21

Modified files:
sys/kern   : kern_sig.c kern_synch.c sched_bsd.c 
 sys_process.c 
sys/dev/pci/drm: drm_linux.c 
sys/sys: proc.h 

Log message:
Prevent a recursion inside wakeup(9) when scheduler tracepoints are enabled.

Tracepoints like "sched:enqueue" and "sched:unsleep" were called from inside
the loop iterating over sleeping threads as part of wakeup_proc().  When such
tracepoints were enabled they could result in another wakeup(9) possibly
corrupting the sleepqueue.

Rewrite wakeup(9) in two stages, first dequeue threads from the sleepqueue then
call setrunnable() and possible tracepoints for each of them.

This requires moving unsleep() outside of setrunnable() because it messes with
the sleepqueue.

ok claudio@



CVS: cvs.openbsd.org: src

2024-03-30 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/03/30 06:47:47

Modified files:
sys/uvm: uvm.h 

Log message:
Document that pmemrange control data are protected by `uvm.fpageqlock'.



CVS: cvs.openbsd.org: src

2024-03-30 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/03/30 01:41:45

Modified files:
usr.sbin/btrace: bt_parse.y bt_parser.h btrace.c 
regress/usr.sbin/btrace: if.bt if.ok 

Log message:
Implement else branching logic including 'else if'.

Statement lists for if & else conditions are now wrapped in a new
'struct bt_cond'.  Handling B_AC_TEST statements moved to stmt_eval()
to handle nested conditional statements.

>From Christian Ludwig christian_ludwig at genua.de



CVS: cvs.openbsd.org: src

2024-03-24 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/03/24 04:29:35

Modified files:
sys/uvm: uvmexp.h uvm_pdaemon.c 

Log message:
Cleanup uvmpd_tune() & document global variable ownership.

- Stop calling uvmpd_tune() inside uvm_pageout().  OpenBSD currently doesn't
support adding RAM. `uvmexp.npages' is immutable after boot.

- Document that `uvmexp.freemin' and `uvmexp.freetarg' are immutable.

- Reduce the scope of the `uvm_pageq_lock' lock.  It serializes accesses
to `uvmexp.active' and `uvmexp.inactive'.

ok kettenis@



CVS: cvs.openbsd.org: src

2024-02-28 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/02/28 06:43:44

Modified files:
sys/kern   : kern_sched.c 

Log message:
No need to kick a CPU twice when putting a thread on its runqueue.

>From Christian Ludwig, ok claudio@



CVS: cvs.openbsd.org: src

2024-02-27 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/02/27 05:50:33

Modified files:
usr.sbin/btrace: btrace.h 
regress/usr.sbin/btrace: str.args str.bt str.ok 

Log message:
Printing large tuples require more than 64 chars, bump the string limit.



CVS: cvs.openbsd.org: src

2024-02-27 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/02/27 05:38:12

Modified files:
usr.sbin/btrace: btrace.c 

Log message:
Make it possible to check for existing string in maps.



CVS: cvs.openbsd.org: src

2024-02-24 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/02/24 12:42:54

Modified files:
usr.sbin/btrace: btrace.c 

Log message:
Check for builtins used inside tuple to ask the kernel to copyout specific data.

Allow to save stacktrace and process name in tuples.



CVS: cvs.openbsd.org: src

2024-02-24 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/02/24 10:05:59

Modified files:
usr.sbin/btrace: btrace.c 

Log message:
Implement 'store' for maps.

A current limitation is the value read from a map is converted to an
integer.  To preserve the original type we have to make maps aware of
the type of its elements.



CVS: cvs.openbsd.org: src

2024-02-24 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/02/24 09:19:49

Modified files:
usr.sbin/btrace: btrace.c 

Log message:
Implement 'store' for all builtins, they are either string or integer.



CVS: cvs.openbsd.org: src

2024-02-12 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/02/12 08:12:09

Modified files:
usr.sbin/btrace: btrace.c 

Log message:
Fix tuple & string comparisons in maps.



CVS: cvs.openbsd.org: src

2024-02-12 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/02/12 08:11:06

Modified files:
usr.sbin/btrace: bt_parse.y 

Log message:
Trailing spaces



CVS: cvs.openbsd.org: src

2024-02-07 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/02/07 12:07:42

Modified files:
usr.sbin/btrace: bt_parse.y 

Log message:
Prevent tuples to be used as map key, associative array is what we want.



CVS: cvs.openbsd.org: src

2024-02-05 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/02/05 08:34:11

Modified files:
regress/usr.sbin/btrace: filters.bt mapoverwrite.bt 
 multiprobe.bt 

Log message:
Increase interval's rate to speed up tests.



CVS: cvs.openbsd.org: src

2024-02-05 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/02/05 08:30:04

Modified files:
regress/usr.sbin/btrace: Makefile 
Added files:
regress/usr.sbin/btrace: argn.bt argn.ok 

Log message:
Regress test for undefined probe arguments fixed in in btrace.c,v 1.83.

Adapted from a submission from Christian Ludwig.



CVS: cvs.openbsd.org: src

2024-02-05 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/02/05 08:18:19

Modified files:
regress/usr.sbin/btrace: map.bt map.ok 

Log message:
Adapt map regress test to cover associated arrays fixed in btrace.c r1.82.

>From Christian Ludwig.



CVS: cvs.openbsd.org: src

2024-02-05 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/02/05 08:11:35

Modified files:
usr.sbin/btrace: btrace.c 

Log message:
Print statistics on stderr to be able to redirect bt(5) script output.

>From Christian Ludwig.



CVS: cvs.openbsd.org: src

2024-01-25 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/01/25 13:50:58

Modified files:
usr.sbin/btrace: btrace.c 

Log message:
Return 0 when accessing an argument not defined in a probe.

Adapted from a fix from Christian Ludwig.



CVS: cvs.openbsd.org: src

2024-01-23 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2024/01/23 15:04:15

Modified files:
usr.sbin/btrace: btrace.c 

Log message:
Consider the whole tuple when reading a map entry whose key is that tuple.

Previously only the first element of the tuple was considered.  This led to
the introduction of new map entries.

Reported by Christian Ludwig.



CVS: cvs.openbsd.org: src

2023-10-27 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/10/27 13:18:53

Modified files:
sys/uvm: uvm_pdaemon.c uvm_swap.c uvm_swap.h uvmexp.h 

Log message:
Make out-of-swap checks more robust.

Consider that the swap space is full when 99% of it is filled with pages that
are no longer present in memory.  This prevents deadlocks when out-of-swap if
some swap ranges had I/O errors and have been marked as 'bad', or if some
pages are unreachable by the pagedaemon and still holding some slots.

Also introduce uvm_swapisfilled() to check if there are some free slots in
the swap.  Note that we consider the swap space completly filled if it is not
possible to write a full cluster.  This prevents deadlocks if a few slots are
never allocated.

ok miod@



CVS: cvs.openbsd.org: src

2023-10-27 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/10/27 13:13:51

Modified files:
sys/uvm: uvm_anon.c 

Log message:
Do not decrement the swap counter if the anon is associated to a "bad" slot.

When such anon is freed its content is obviously not living in swap.

ok miod@



CVS: cvs.openbsd.org: src

2023-10-24 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/10/24 04:00:22

Modified files:
sys/uvm: uvm_pdaemon.c 

Log message:
Merge two equivalent if blocks.

No functional change, ok tb@



CVS: cvs.openbsd.org: www

2023-10-24 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:www
Changes by: m...@cvs.openbsd.org2023/10/24 03:35:58

Modified files:
.  : support.html 

Log message:
I relocated to the south of France a couple of years ago.



CVS: cvs.openbsd.org: src

2023-10-16 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/10/16 05:32:54

Modified files:
sys/uvm: uvm_pdaemon.c 

Log message:
Consider required constraint when moving pages from active to inactive lists.

Make sure low pages are deactivated first when there is a shortage of inactive
pages.  Without this the system can have a ton of high pages on the active list
and never swapout anything if there's a shortage of low pages.

This prevents a deadlock on amd64 reported and tested by bluhm@.

ok kettenis@



CVS: cvs.openbsd.org: src

2023-09-16 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/09/16 03:33:28

Modified files:
sys/kern   : kern_sysctl.c subr_evcount.c subr_percpu.c 
sys/net: pfkeyv2_convert.c if_pfsync.c if_etherip.c if.c 
 pipex.c rtsock.c 
sys/netinet: igmp.c ip_carp.c ip_divert.c ip_icmp.c 
 ip_input.c ip_ipip.c ipsec_input.c tcp_usrreq.c 
 udp_usrreq.c 
sys/netinet6   : icmp6.c ip6_divert.c ip6_input.c raw_ip6.c 
sys/sys: percpu.h 
sys/uvm: uvm_meter.c 
share/man/man9 : counters_alloc.9 

Log message:
Allow counters_read(9) to take an optional scratch buffer.

Using a scratch buffer makes it possible to take a consistent snapshot of
per-CPU counters without having to allocate memory.

Makes ddb(4) show uvmexp command work in OOM situations.

ok kn@, mvs@, cheloha@



CVS: cvs.openbsd.org: src

2023-09-13 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/09/13 07:47:58

Modified files:
usr.sbin/btrace: btrace.c 

Log message:
Properly evaluate variables when inserting them into a map.

Somehow missed in previous, regression reported by anton@.



CVS: cvs.openbsd.org: src

2023-09-11 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/09/11 13:03:53

Modified files:
regress/usr.sbin/btrace: Makefile 
Added files:
regress/usr.sbin/btrace: tuple.bt tuple.ok tupleeval.bt 
 tupleeval.ok vareval.bt vareval.ok 

Log message:
Regressions for tuples and evaluating variables.



CVS: cvs.openbsd.org: src

2023-09-11 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/09/11 13:01:26

Modified files:
usr.sbin/btrace: bt_parse.y bt_parser.h btrace.h btrace.c map.c 

Log message:
Implement tuples, needed to export per-CPU scheduling data.

It is now possible to save and print immutable arrays as below:

..$t = (1, 42, "something");
..printf("%d %s\n", $t.1, $t.2);

Also add support for evaluating builtin in order to save them in variables
(required by tuples)



CVS: cvs.openbsd.org: src

2023-09-03 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/09/03 04:26:35

Modified files:
usr.sbin/btrace: map.c 

Log message:
Let builtin process names be stored in maps as string.

ok dv@



CVS: cvs.openbsd.org: src

2023-09-02 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/09/02 02:24:40

Modified files:
sys/uvm: uvm_anon.c uvm_fault.c 

Log message:
Zap anon pages mappings in uvm_anon_release() instead of in the fault handler.

This makes all code paths deactivating or freeing anons consistent.

No objection from the usual suspects.



CVS: cvs.openbsd.org: src

2023-08-14 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/08/14 02:33:24

Modified files:
sys/dev/dt : dt_prov_static.c 
sys/kern   : kern_fork.c kern_sched.c kern_synch.c 
 sched_bsd.c 

Log message:
Extend scheduler tracepoints to follow CPU jumping.

- Add two new tracpoints sched:fork & sched:steal
- Include selected CPU number in sched:wakeup
- Add sched:unsleep corresponding to sched:sleep which matches add/removal
of threads on the sleep queue

ok claudio@



CVS: cvs.openbsd.org: src

2023-08-13 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/08/13 03:52:47

Modified files:
usr.sbin/btrace: btrace.c 

Log message:
Add support for storing builtin TID and PID in variables.



CVS: cvs.openbsd.org: src

2023-08-13 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/08/13 03:49:47

Modified files:
regress/usr.sbin/btrace: Makefile 
Added files:
regress/usr.sbin/btrace: mapoverwrite.bt mapoverwrite.ok 

Log message:
Regression test for the use-after-free in map insertion



CVS: cvs.openbsd.org: src

2023-08-13 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/08/13 03:48:27

Modified files:
usr.sbin/btrace: map.c 

Log message:
Prevent user-after/double free in map insertion.

Freeing arguments tied to statements is not an option because rules are
parsed multiple times.  Always make a copy of them if they are assigned
to a key in a map.



CVS: cvs.openbsd.org: src

2023-08-12 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/08/12 01:22:56

Modified files:
sys/uvm: uvm_page.c 

Log message:
Add sanity checks in uvm_pagelookup().

ok kettenis@



CVS: cvs.openbsd.org: src

2023-08-11 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/08/11 11:53:22

Modified files:
sys/uvm: uvm_pager.c 

Log message:
Kill unused variable in uvm_aio_aiodone_pages().



CVS: cvs.openbsd.org: src

2023-08-02 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/08/02 03:19:47

Modified files:
sys/uvm: uvm_map.c uvm_map.h 

Log message:
Remove unused vm_map_upgrade() & vm_map_downgrade().

Upgrade/downgrade operations on a `vmmaplk' are no longer necessary since
vm_map_busy() completely unlocks it (r1.318 of uvm/uvm_map.c).

ok kettenis@



CVS: cvs.openbsd.org: src

2023-05-20 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/05/20 06:48:36

Modified files:
sys/uvm: uvm_map.c uvm_map.h 

Log message:
Do not grab the `vmmaplk' recursively, prevent a self-deadlock.

Change the semantic of vm_map_busy() to be able to completely unlock the
`vmmaplk' instead of downgrading it to a read lock in mlock(2).  This is
necessary because uvm_fault_wire() tries to re-grab the same lock.

We now keep track of the thread currently holding the vmmap busy to ensure
it can relock & unbusy the vmmap.  The new pattern becomes:

vm_map_lock(map);
vm_map_busy(map); /* prevent other threads to grab an exclusive lock */
vm_map_unlock(map);

/*
 * Do some stuff generally requiring a tsleep(9).
 */

vm_map_lock(map);
vm_map_unbusy(map); /* allow other threads to make progress after unlock */
vm_map_unlock(map);

Fix adapted from NetBSD's r1.249 of uvm/uvm_map.c.  Issue reported by
Jacqueline Jolicoeur exposed by a "wallet refresh" of the Monero App.
Panic hand-copied below:

sleep_finish()
rw_enter()
uvmfault_lookup()
uvm_fault_check()
uvm_fault()
uvm_fault_wire()
uvm_map_pageable_wire()
sys_mlock()

This version skips bumping the map's timestamp if the lock is acquired by the
thread marked the VM map busy.  This prevents a KASSERT() reported by bluhm@
triggered by regress/misc/posixtestsuite conformance/interfaces/mmap/18-1

ok kettenis@



CVS: cvs.openbsd.org: src

2023-05-13 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/05/13 03:24:59

Modified files:
sys/uvm: uvm_aobj.c uvm_aobj.h uvm_page.c uvm_pager.c 

Log message:
Put back in the simplification of the aiodone daemon.

Previous "breakage" of the swap on arm64 has been found to be an issue
on one machine the rockpro/arm64 related to a deadlock built into the
sdmmc(4) stack interacting with swapping code both running under
KERNEL_LOCK().

This issue is easily reproducible on -current and entering swap when
building LLVM on a rockpro crashes the machine by memory corruption.

Tested by mlarkin@ on octeon & i386, by myself on amd64 & arm64 and by
sthen@ on i386 port bulk.

ok beck@ some time ago.

Previous commit message:

Simplify the aiodone daemon which is only used for async writes.

- Remove unused support for asynchronous read, including error conditions

- Grab the proper lock for each page that has been written to swap.  This
allows to enable an assertion in uvm_page_unbusy().

- Move the uvm_anon_release() call outside of uvm_page_unbusy() and
assert for the different anon cases.

ok beck@, kettenis@



CVS: cvs.openbsd.org: src

2023-04-25 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/04/25 06:36:30

Modified files:
sys/uvm: uvm_map.c uvm_map.h 

Log message:
Do not grab the `vmmaplk' recursively, prevent a self-deadlock.

Change the semantic of vm_map_busy() to be able to completely unlock the
`vmmaplk' instead of downgrading it to a read lock in mlock(2).  This is
necessary because uvm_fault_wire() tries to re-grab the same lock.

We now keep track of the thread currently holding the vmmap busy to ensure
it can relock & unbusy the vmmap.  The new pattern becomes:

vm_map_lock(map);
vm_map_busy(map); /* prevent other threads to grab an exclusive lock */
vm_map_unlock(map);

/*
 * Do some stuff generally requiring a tsleep(9).
 */

vm_map_lock(map);
vm_map_unbusy(map); /* allow other threads to make progress after unlock */
vm_map_unlock(map);

Fix adapted from NetBSD's r1.249 of uvm/uvm_map.c.  Issue reported by
Jacqueline Jolicoeur exposed by a "wallet refresh" of the Monero App.
Panic hand-copied below:

sleep_finish()
rw_enter()
uvmfault_lookup()
uvm_fault_check()
uvm_fault()
uvm_fault_wire()
uvm_map_pageable_wire()
sys_mlock()

ok kettenis@



CVS: cvs.openbsd.org: src

2023-02-24 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2023/02/24 08:17:48

Modified files:
sys/uvm: uvm_map.c 

Log message:
Do not held the vm_map lock while flushing pages in msync(2) and madvise(2).

Mark the VM map as busy instead to prevent any sibling thread to request an
exclusive version of the vm_map.  This is necessary to let any PG_BUSY page,
found in the UVM vnode object, to be released by a sibling in the middle of
a page-fault.

Note: the page-fault handler releases & re-grab a shared version of the
vm_map lock and expect it to be available to make progress.

Prevent a 3-Threads deadlock between msync(2), page-fault and mmap(2).  The
deadlock reported on bugs@ by many occured as follow:

..ThreadA faults & grabs the shared `vmmaplk' then release it before calling
..uvn_get() which might sleep to allocate pages and mark them as PG_BUSY.

..Once the lock is released, threadB calls uvn_flush().  It sees at least a
..PG_BUSY page and sleeps on the `vmmaplk' waiting for threadA to un-busy
..the page.

..At the same time threadC asked for an exclusive version of the lock and
..sleeps until all reader are done with it.  This prevents threadA to
..acquire a shared-version of the lock and finish the page fault.

This issue is similar to NetBSD's PR #56952 and the fix is from Chuck Silvers.

Tested by many on bugs@, thanks!

ok kettenis@



CVS: cvs.openbsd.org: src

2022-11-12 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/11/12 07:19:08

Modified files:
usr.sbin/btrace: bt_parse.y btrace.c 
regress/usr.sbin/btrace: Makefile 
Added files:
regress/usr.sbin/btrace: filters.bt filters.ok 

Log message:
Add support for string comparison in filters.

It is now possible to filter by process name, like:

syscall:mmap:entry
/comm == "ld"/
{
...
}

Currently the parser treats C-string like any other expression member even
if arithmetic operations do no apply to strings.



CVS: cvs.openbsd.org: src

2022-11-11 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/11/11 15:43:09

Modified files:
usr.sbin/btrace: btrace.c 

Log message:
Add support for storing builtins arguments into local variables.



CVS: cvs.openbsd.org: src

2022-11-11 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/11/11 15:40:42

Modified files:
usr.sbin/btrace: bt_parse.y btrace.c 
regress/usr.sbin/btrace: if.bt if.ok 

Log message:
Add support for multiple statements in if () blocks.



CVS: cvs.openbsd.org: src

2022-11-11 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/11/11 03:51:39

Modified files:
usr.sbin/btrace: btrace.c 

Log message:
typo



CVS: cvs.openbsd.org: src

2022-11-09 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/11/09 03:27:01

Modified files:
sys/kern   : init_sysent.c syscalls.c 
sys/sys: syscall.h syscallargs.h 

Log message:
regen



CVS: cvs.openbsd.org: src

2022-11-09 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/11/09 03:26:28

Modified files:
sys/kern   : syscalls.master 

Log message:
Mark sched_yield(2) as NOLOCK.

All the fields accessed in this syscall are protected by the SCHED_LOCK()
so it isn't necessary to wait for another CPU to release the KERNEL_LOCK()
before that.

ok claudio@



CVS: cvs.openbsd.org: src

2022-11-08 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/11/08 04:06:41

Modified files:
sys/kern   : init_sysent.c syscalls.c 
sys/sys: syscall.h syscallargs.h 

Log message:
Regen



CVS: cvs.openbsd.org: src

2022-11-08 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/11/08 04:05:57

Modified files:
sys/kern   : syscalls.master 

Log message:
Mark mmap(2), munmap(2) and mprotect(2) as NOLOCK.

Accesses to data structures used by these syscalls are serialized by the
VM map lock with the exception of file mappings which are still protected
by the KERNEL_LOCK().

Unlocking this set of syscalls improves most of userland workloads.

Tested by many including robert@ (since 2 years), mlarkin@, kn@, sdk@,
jca@, aoyama@, naddy@, Scott Bennett and others. Thanks to all!

Joint work with kn@.

ok robert@, aja@, kettenis@, kn@, deraadt@, beck@



CVS: cvs.openbsd.org: src

2022-11-07 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/11/07 02:43:04

Modified files:
sys/arch/arm64/arm64: db_interface.c pmap.c trap.c 
sys/arch/arm64/include: pmap.h 

Log message:
Implement db_write_text/bytes() which add support for ddb(4)'s breakpoints.

Based on a diff from gerhard@, ok kettenis@



CVS: cvs.openbsd.org: src

2022-11-04 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/11/04 03:36:45

Modified files:
sys/uvm: uvm_addr.c uvm_fault.c uvm_map.c uvm_map.h 

Log message:
Assert the VM map lock is held in function used by mmap/mprotect/munmap.

Also grab the lock in uvm_map_teardown() and uvm_map_deallocate() to
satisfy the assertions.  Grabbing the lock there shouldn't be strictly
necessary, because no other reference to the map should exist when the
reaper is holding it, but it doesn't hurt and makes our life easier.

Inputs & tests from Ivo van der Sangen, tb@, gnezdo@, kn@

kettenis@ and tb@ agree with the direction, ok kn@



CVS: cvs.openbsd.org: src

2022-10-31 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/10/31 04:46:24

Modified files:
sys/uvm: uvm_map.c 

Log message:
Fix VMMAP_DEBUG code to compile with not-so-recent changes.

If enabled the debug code currently panic the kernel.  To investigate.



CVS: cvs.openbsd.org: src

2022-10-20 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/10/20 07:31:52

Modified files:
sys/uvm: uvm_vnode.c uvm_vnode.h 

Log message:
Access to `u_flags' should be serialized by the `vmobjlock'.

This complete previous fix from gnezdo@.  The uvm_vnp_sync() still
requires some love and isn't addressed by this diff.

Document which lock is protecting vnode variables.

ok gnezdo@



CVS: cvs.openbsd.org: src

2022-10-02 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/10/02 05:56:43

Modified files:
usr.bin/ctfconv: ctfconv.c 

Log message:
Remove unused DEBUG_LINE define.



CVS: cvs.openbsd.org: src

2022-09-21 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/09/21 01:32:59

Modified files:
sys/uvm: uvm_vnode.c uvm_vnode.h 

Log message:
Revert UVM_VNODE_CANPERSIST removal, it exposes an issue on arm64.

Found the hardway by miod@ and deraadt@.



CVS: cvs.openbsd.org: src

2022-09-18 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/09/18 08:41:54

Modified files:
sys/dev/ofw: fdt.c 

Log message:
Revert previous it prevents the PinebookPro and the Rockpro64 to reach userland.

Found by kn@ and myself, ok deraadt@



CVS: cvs.openbsd.org: src

2022-09-10 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/09/10 10:14:36

Modified files:
sys/uvm: uvm_vnode.c uvm_vnode.h 

Log message:
Get rid of the extra vnode reference known as UVM_VNODE_CANPERSIST.

Back in the 4.4BSD days the VM subystem had a OBJ_CANPERSIST flag to
enter objects in a global cached list.  Some of this logic seem to have
been copied to UVM but without the global list.

Unfortunately keeping UVM vnode objects alive after munmap(2)ing the
corresponding region without incrementing the reference count of the
related vnode led to many bugs when the vnode was recycled and/or when
it data where written back to disk (via the page daemon).

The problem is that VM pages might have a non-accounted reference to a
vnode via `pg->uobject'.

Fix "vref used where vget required" panic reported by bluhm@, gkoehler@
and Andrew Krasavinseen on bugs@.

Thanks a lot to semarie@ for co-debugging this issue!

Tested by bluhm@, tb@, miod@.

ok kettenis@, semarie@



CVS: cvs.openbsd.org: src

2022-08-31 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/08/31 03:26:04

Modified files:
sys/uvm: uvm_pdaemon.c 

Log message:
Introduce a function to trylock a page instead of duplicating the logic.

Stolen from NetBSD.

ok jsg@



CVS: cvs.openbsd.org: src

2022-08-30 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/08/30 02:30:58

Modified files:
sys/uvm: uvm_pdaemon.c 

Log message:
Move duplicated code to free swap resources into its own function.

ok mlarkin@



CVS: cvs.openbsd.org: src

2022-08-29 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/08/29 05:09:31

Modified files:
sys/uvm: uvm_swap.c uvmexp.h 

Log message:
Use a rwlock and a mutex to serialize access to global swap variables.

Adapted from NetBSD by tb@.

ok tb@, kn@



CVS: cvs.openbsd.org: src

2022-08-22 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/08/22 06:03:32

Modified files:
sys/uvm: uvm_pdaemon.c 

Log message:
Simplify locking by using an intermediate lock variable.

While here get rid of the unused returned value of uvmpd_scan_inactive().

ok jsg@, kn@



CVS: cvs.openbsd.org: src

2022-08-18 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/08/18 23:53:19

Modified files:
sys/uvm: uvm_pager.c 

Log message:
Grab the mutex before iterating on the global list.

Prevent race reported some months ago.

ok mlarkin@, jsg@, kn@



CVS: cvs.openbsd.org: src

2022-08-02 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/08/02 08:04:06

Modified files:
sys/uvm: uvm_pager.c 

Log message:
Bring back the direct map optimization when PMAP_PREFER isn't defined.

PMAP_PREFER is checked to prevent cache aliasing issues when the physical
page is mapped at different virtual addresses.

This speeds up file-based mmap faults.

ok kettenis@



CVS: cvs.openbsd.org: src

2022-08-01 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/08/01 08:15:46

Modified files:
sys/uvm: uvm_amap.c uvm_aobj.c uvm_km.c uvm_page.c 
 uvm_page.h uvm_vnode.c 

Log message:
Introduce and use uvm_pagewait() where PG_WANTED is set.

No change in behavior.

ok kn@, semarie@, kettenis@



CVS: cvs.openbsd.org: src

2022-07-24 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/07/24 05:00:22

Modified files:
sys/uvm: uvm_aobj.c uvm_aobj.h uvm_page.c uvm_pager.c 

Log message:
Revert simplification of the aiodone daemon it breaks swap on arm64.

Found the hard way by mlarkin@ and deraadt@.



CVS: cvs.openbsd.org: src

2022-07-11 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/07/11 05:33:18

Modified files:
sys/uvm: uvm_aobj.c uvm_aobj.h uvm_page.c uvm_pager.c 

Log message:
Simplify the aiodone daemon which is only used for async writes.

- Remove unused support for asynchronous read, including error conditions

- Grab the proper lock for each page that has been written to swap.  This
allows to enable an assertion in uvm_page_unbusy().

- Move the uvm_anon_release() call outside of uvm_page_unbusy() and
assert for the different anon cases.

ok beck@, kettenis@



CVS: cvs.openbsd.org: src

2022-07-11 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/07/11 05:29:11

Modified files:
sys/uvm: uvm_swap.c 

Log message:
Remove asynchronous read support in uvm_swap_get().

Reading pages from swap is always done synchronously.  The fault handler
needs to sleep and PGO_SYNCIO is already asserted a couple of lines above.

ok beck@, kettenis@ as part of a larger diff.



CVS: cvs.openbsd.org: src

2022-07-07 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/07/07 07:52:20

Modified files:
sys/uvm: uvm_vnode.c 

Log message:
Revert previous attempt at serializing `uo_refs'.

It is incorrect to look at/modify `uo_refs' without lock in uvm_vnp_sync().
However sleeping is not possible and spinning introduces a deadlock with the
KERNEL_LOCK() when another thread faults on a mmaped region related to a
vnode we're currently synching.

A proper fix should be investigated.  For now a kown a race, mostly safe due
to the KERNEL_LOCK(), is better than a possible deadlock.

Issue reported by caspar@

Discussed with and ok semarie@



  1   2   3   4   5   6   7   8   9   10   >