The following diff should allow most of utrace to run without kernel lock.
It makes utrace() less expensive if ktrace is not used.

-- 
:wq Claudio

Index: kern/kern_ktrace.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_ktrace.c,v
retrieving revision 1.110
diff -u -p -r1.110 kern_ktrace.c
--- kern/kern_ktrace.c  9 Feb 2023 08:00:31 -0000       1.110
+++ kern/kern_ktrace.c  15 Feb 2023 10:17:54 -0000
@@ -335,8 +335,11 @@ ktruser(struct proc *p, const char *id, 
                else
                        memp = stkbuf;
                error = copyin(addr, memp, len);
-               if (error == 0)
+               if (error == 0) {
+                       KERNEL_LOCK();
                        ktrwrite2(p, &kth, &ktp, sizeof(ktp), memp, len);
+                       KERNEL_UNLOCK();
+               }
                if (memp != stkbuf)
                        free(memp, M_TEMP, len);
        }
Index: kern/syscalls.master
===================================================================
RCS file: /cvs/src/sys/kern/syscalls.master,v
retrieving revision 1.243
diff -u -p -r1.243 syscalls.master
--- kern/syscalls.master        14 Feb 2023 08:34:49 -0000      1.243
+++ kern/syscalls.master        15 Feb 2023 10:28:02 -0000
@@ -370,7 +370,7 @@
 206    OBSOL           t32_futimes
 207    STD             { pid_t sys_getpgid(pid_t pid); }
 208    OBSOL           nnpfspioctl
-209    STD             { int sys_utrace(const char *label, const void *addr, \
+209    STD NOLOCK      { int sys_utrace(const char *label, const void *addr, \
                            size_t len); }
 ;
 ; Syscalls 210-219 were reserved for dynamically loaded syscalls

Reply via email to