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@



CVS: cvs.openbsd.org: src

2022-06-30 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/06/30 14:28:42

Modified files:
sys/uvm: uvm_pager.c 

Log message:
Reduce allocations and possible failures in uvm_pagermapin/out().

. If a direct map exists use it to map single-page allocations
. Use pmap_kenter_pa() instead of pmap_enter() in all other cases.

This speeds up file-based mmap up to 75% when I/O are performed and it
also reduces possible allocations failtures in the page daemon making
it more stable in OOM situations.

ok kettenis@, beck@



CVS: cvs.openbsd.org: src

2022-06-30 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/06/30 07:54:37

Modified files:
sys/uvm: uvm_swap.c 

Log message:
Remove an incorrect KASSERT() introduced in previous.

If uvm_pagermapin() fails that doesn't mean the emergency pages aren't
in use.  In OOM situation, a single segment can still be held by an
asynchronous write so the second call to uvm_pagermapin() can fail.



Re: CVS: cvs.openbsd.org: src

2022-06-29 Thread Martin Pieuchot
On 29/06/22(Wed) 07:02, Anton Lindqvist wrote:
> On Tue, Jun 28, 2022 at 06:08:18AM -0600, Claudio Jeker wrote:
> > CVSROOT:/cvs
> > Module name:src
> > Changes by: clau...@cvs.openbsd.org 2022/06/28 06:08:18
> > 
> > Modified files:
> > sys/kern   : kern_sig.c 
> > 
> > Log message:
> > Cleanup the sleep loop in single_thread_check_locked(). The deep checks
> > only matter on entry and the pr->ps_single check is done in the while body.
> > With and OK mpi@
> 
> syzkaller just found a reproducer for the following panic. Is it related
> to this commit?

I believe it is.  If there's a race between SINGLE_SUSPEND and
PS_SINGLEEXIT the deep check should be re-done.

The problem reported by syzkaller is a lock ordering issue.  The SCHED_LOCK()
is held when trying to grab the KERNEL_LOCK().  This can only happen if
a thread is calling exit1() inside single_thread_check_locked() but that
should only be possible at the boundary of the kernel not in the middle
of a sleep.

So I believe this change was wrong and we should revert it.  Thanks!

> > syzbot has found a reproducer for the following issue on:
> > 
> > HEAD commit:37c734d33dee constify miscellaneous arm64 pin and clock ta..
> > git tree:   openbsd
> > console output: https://syzkaller.appspot.com/x/log.txt?x=1397129808
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=7058272de1526588
> > dashboard link: https://syzkaller.appspot.com/bug?extid=f7634539e73108238c2a
> > syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=17fe7ac008
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=1625358808
> > 
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+f7634539e73108238...@syzkaller.appspotmail.com
> > 
> > panic: kernel diagnostic assertion "__mp_lock_held(_lock, curcpu()) 
> > == 0" failed: file 
> > "/syzkaller/managers/setuid/kernel/sys/kern/kern_lock.c", line 63
> > Stopped at  db_enter+0x18:  addq$0x8,%rsp
> > TIDPIDUID PRFLAGS PFLAGS  CPU  COMMAND
> > *226148  13902  0  0x1802  0x40800801  syz-executor2883823057
> > db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:437
> > panic(8259bd82) at panic+0x177 sys/kern/subr_prf.c:202
> > __assert(8261504d,8261b5a3,3f,8264d4fb) at 
> > __assert+0x25 sys/kern/subr_prf.c:161
> > _kernel_lock() at _kernel_lock+0xb2 sys/kern/kern_lock.c:63
> > single_thread_check_locked(800021232548,1,c) at 
> > single_thread_check_locked+0x1f6 sys/kern/kern_sig.c:2037
> > single_thread_check(800021232548,1) at single_thread_check+0x4b 
> > sys/kern/kern_sig.c:2057
> > sleep_finish(8000212c2550,1) at sleep_finish+0x75 sleep_signal_check 
> > sys/kern/kern_synch.c:464 [inline]
> > sleep_finish(8000212c2550,1) at sleep_finish+0x75 
> > sys/kern/kern_synch.c:400
> > rwsleep(800021232548,82957750,120,82595e88,0) at 
> > rwsleep+0xd5 sys/kern/kern_synch.c:314
> > futex_wait(bc96a93640,1,0,2) at futex_wait+0x13c sys/kern/sys_futex.c:260
> > sys_futex(800021232548,8000212c26e0,8000212c2740) at 
> > sys_futex+0xf8 sys/kern/sys_futex.c:111
> > syscall(8000212c27b0) at syscall+0x484 mi_syscall 
> > sys/sys/syscall_mi.h:102 [inline]
> > syscall(8000212c27b0) at syscall+0x484 sys/arch/amd64/amd64/trap.c:585
> > Xsyscall() at Xsyscall+0x128
> > end of kernel
> > end trace frame: 0xbcc5099500, count: 3
> > https://www.openbsd.org/ddb.html describes the minimum info required in bug
> > reports.  Insufficient info makes it difficult to find and fix bugs.
> > ddb{1}> 
> > ddb{1}> set $lines = 0
> > ddb{1}> set $maxwidth = 0
> > ddb{1}> show panic
> > *cpu1: kernel diagnostic assertion "__mp_lock_held(_lock, curcpu()) 
> > == 0" failed: file 
> > "/syzkaller/managers/setuid/kernel/sys/kern/kern_lock.c", line 63
> > ddb{1}> trace
> > db_enter() at db_enter+0x18 sys/arch/amd64/amd64/db_interface.c:437
> > panic(8259bd82) at panic+0x177 sys/kern/subr_prf.c:202
> > __assert(8261504d,8261b5a3,3f,8264d4fb) at 
> > __assert+0x25 sys/kern/subr_prf.c:161
> > _kernel_lock() at _kernel_lock+0xb2 sys/kern/kern_lock.c:63
> > single_thread_check_locked(800021232548,1,c) at 
> > single_thread_check_locked+0x1f6 sys/kern/kern_sig.c:2037
> > single_thread_check(800021232548,1) at single_thread_check+0x4b 
> > sys/kern/kern_sig.c:2057
> > sleep_finish(8000212c2550,1) at sleep_finish+0x75 sleep_signal_check 
> > sys/kern/kern_synch.c:464 [inline]
> > sleep_finish(8000212c2550,1) at sleep_finish+0x75 
> > sys/kern/kern_synch.c:400
> > rwsleep(800021232548,82957750,120,82595e88,0) at 
> > rwsleep+0xd5 sys/kern/kern_synch.c:314
> > futex_wait(bc96a93640,1,0,2) at futex_wait+0x13c sys/kern/sys_futex.c:260
> > sys_futex(800021232548,8000212c26e0,8000212c2740) at 
> > sys_futex+0xf8 sys/kern/sys_futex.c:111
> > 

CVS: cvs.openbsd.org: src

2022-06-28 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/06/28 13:39:54

Modified files:
sys/uvm: uvm_swap.c 

Log message:
Make sure uvm_swap_get() always sleep and do not return and error.

If no memory was immediately available to decrypt (bounce) a page from swap
an error was returned to the fault handler which would result in processes
dying when a lot of memory pressure was applied to a system.

Note that reading from swap is always done synchronously.

ok beck@, kettenis@



CVS: cvs.openbsd.org: src

2022-06-28 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/06/28 13:31:30

Modified files:
sys/uvm: uvm_pdaemon.c 

Log message:
Consider pmemrange regions when trying to free pages from the inactive list.

Instead of starting with the first page on the inactive list pick the first
one that fits in the range of a given pmemrange region.

Fix an issue where the page daemon would be hogging a CPU without freeing any
page because the global limits are satisfied.

The algorithm could certainly be revisited, the LRU is not really working and
there is a huge delay before recovering when the first pages need to be swapped 
and the system is in OOM situation but at least there is no starvation and the
system now recovers.

ok beck@, kettenis@



CVS: cvs.openbsd.org: src

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

Modified files:
sys/uvm: uvm_pdaemon.c 

Log message:
Use new & shiny define for the maximum number of pages of a swap cluster.

ok beck@, kettenis@



CVS: cvs.openbsd.org: src

2022-06-28 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/06/28 13:19:34

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

Log message:
Pre-allocate pages in DMA-reachable region to ensure progress in the swapper.

Currently swap encryption is not done in place and some architectures need to
bounce pages into a DMA-reachable region for I/Os, for that uvm_swap_io() needs
to allocate at most 64K to write a swap cluster to disk.  Pre-allocate such
amount of memory to be sure the page daemon can make progress in OOM situation.

Also introduce a sleeping point to wait for the previous asynchronous I/O
holding the pre-allocated pages, there's no point in building clusters if no
progress can be made.

ok beck@, kettenis@



CVS: cvs.openbsd.org: src

2022-06-28 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/06/28 13:07:40

Modified files:
sys/uvm: uvm_pager.c 

Log message:
Reserve a second segment for the page daemon.

This ensures uvm_swap_io() can succeeds even in OOM situations because two
uvm_pagermapin() allocations, requiring a segment each, are needed to bounce
or encrypt a swap cluster.

ok beck@, kettenis@



CVS: cvs.openbsd.org: src

2022-06-28 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/06/28 06:10:37

Modified files:
sys/uvm: uvm_pager.c 

Log message:
Move the guts of uvm_aio_aiodone() into a separate function.

This will help dealing with error cases.

No functionnal changes.



CVS: cvs.openbsd.org: src

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

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

Log message:
Do not clean PG_BUSY before calling uvm_anon_release().

Fix an assertion reported by gkoehler@.

ok kettenis@



CVS: cvs.openbsd.org: src

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

Modified files:
sys/uvm: uvm_fault.c 

Log message:
Do not consider adjacent pages when doing a CoW.

Those pages should already be entered, this speeds up CoW faults.

Stolen from NetBSD.

ok miod@, kettenis@



CVS: cvs.openbsd.org: src

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

Modified files:
sys/nfs: nfs_serv.c 

Log message:
Call uvm_vnp_uncache() before VOP_RENAME().

ok kettenis@



CVS: cvs.openbsd.org: src

2022-05-12 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/05/12 06:49:31

Modified files:
sys/uvm: uvm_pdaemon.c 

Log message:
Consider BUFPAGES_DEFICIT in swap_shortage.

ok beck@



CVS: cvs.openbsd.org: src

2022-05-12 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/05/12 06:48:36

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

Log message:
Introduce uvm_pagedequeue() to reduce code duplication.

ok kettenis@



CVS: cvs.openbsd.org: src

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

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

Log message:
Merge swap-backed and object-backed inactive page lists.

ok millert@, kettenis@



CVS: cvs.openbsd.org: src

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

Modified files:
sys/uvm: uvm_pdaemon.c 

Log message:
Recheck PG_BUSY after locking the page.

Another thread can set the bit if we sleep during rw_enter(9) in which case
the page shouldn't be touched.

ok semarie@



Re: CVS: cvs.openbsd.org: src

2022-04-28 Thread Martin Pieuchot
On 28/04/22(Thu) 12:12, Martin Pieuchot wrote:
> CVSROOT:  /cvs
> Module name:  src
> Changes by:   m...@cvs.openbsd.org2022/04/28 12:12:33
> 
> Modified files:
>   sys/uvm: uvm_vnode.c 
> 
> Log message:
> Always acquire the `vmobjlock' before incrementing an object's reference.

With and ok semarie.



CVS: cvs.openbsd.org: src

2022-04-28 Thread Martin Pieuchot
CVSROOT:/cvs
Module name:src
Changes by: m...@cvs.openbsd.org2022/04/28 12:12:33

Modified files:
sys/uvm: uvm_vnode.c 

Log message:
Always acquire the `vmobjlock' before incrementing an object's reference.



  1   2   3   4   5   6   7   8   9   10   >