Now that mpi has unlocked uvm's fault handler, we can unlock the mmap
syscall to handle MAP_ANON without the big lock.

sys_mmap() still protects the !MAP_ANON case, i.e. file based mappings,
with the KERNEL_LOCK() itself, which is why unlocking the syscall will
only change locking behaviour for anonymous mappings.

A previous to unlock file based mappings was reverted, see the following
from https://marc.info/?l=openbsd-tech&m=160155434212888&w=2 :

        commit 38802bc07455f2a4f8cdde272850a5eab5dfa6c8
        from: mpi <m...@openbsd.org>
        date: Wed Oct  7 12:26:20 2020 UTC

        Do not release the KERNEL_LOCK() when mmap(2)ing files.

        Previous attempt to unlock amap & anon exposed a race in vnode reference
        counting.  So be conservative with the code paths that we're not fully 
moving
        out of the KERNEL_LOCK() to allow us to concentrate on one area at a 
time.
        ...


So here's a first small step.  I've been running with this for months
on a few amd64, arm64 and sparc64 boxes without problems;   they've been
daily drivers and/or have been building releases and ports.

Feedback?  Objections?  OK?


Index: sys/kern/syscalls.master
===================================================================
RCS file: /cvs/src/sys/kern/syscalls.master,v
retrieving revision 1.221
diff -u -p -r1.221 syscalls.master
--- sys/kern/syscalls.master    23 Dec 2021 18:50:31 -0000      1.221
+++ sys/kern/syscalls.master    31 Dec 2021 09:14:00 -0000
@@ -126,7 +126,7 @@
                            struct sigaction *osa); }
 47     STD NOLOCK      { gid_t sys_getgid(void); }
 48     STD NOLOCK      { int sys_sigprocmask(int how, sigset_t mask); }
-49     STD             { void *sys_mmap(void *addr, size_t len, int prot, \
+49     STD NOLOCK      { void *sys_mmap(void *addr, size_t len, int prot, \
                            int flags, int fd, off_t pos); }
 50     STD             { int sys_setlogin(const char *namebuf); }
 #ifdef ACCOUNTING

Reply via email to