On Thu, 22 Apr 2021 15:38:53 +0200 Martin Pieuchot <m...@openbsd.org> wrote:
> Diff below remove the KERNEL_LOCK()/UNLOCK() dance from uvm_fault() for > both amd64 and sparc64. That means the kernel lock will only be taken > for lower faults and some amap/anon code will now run without it. I made a similar diff, below, for macppc and powerpc64. In my small trials, the build times were about the same on my 4-core powerpc64 and slightly faster on my 2-core macppc. My macppc kernel had a problem: it froze at boot, but the problem went away after I reordered the kernel. In my guess, this unlocking diff isn't the cause of the problem, because the freeze was too early (before copyright); the other cpu wouldn't have entered the kernel, so the kernel lock wouldn't prevent the freeze. My powerpc64 trial was "make -j4" in src/gnu/usr.bin/clang on 4-core POWER9 in Talos II. Before diff: 117m45.96s real 361m58.87s user 68m44.66s system After diff: 115m24.53s real 362m02.65s user 58m40.99s system I see that system time went down by 10 minutes, but real time is about the same (down by 2 minutes). My macppc trial was "dpb devel/cmake" on 2-cpu Power Mac G5. Before diff: 03:44:50 After diff: 03:33:44 Real time went down by 11 minutes. Maybe the unlocking diff works better on a 2-core machine, or maybe the unlocking diff does nothing and I saved 11 minutes by random luck. --George Index: arch/powerpc/powerpc/trap.c =================================================================== RCS file: /cvs/src/sys/arch/powerpc/powerpc/trap.c,v retrieving revision 1.119 diff -u -p -r1.119 trap.c --- arch/powerpc/powerpc/trap.c 11 Mar 2021 11:16:59 -0000 1.119 +++ arch/powerpc/powerpc/trap.c 28 Apr 2021 02:49:44 -0000 @@ -282,9 +282,7 @@ trap(struct trapframe *frame) else ftype = PROT_READ; - KERNEL_LOCK(); error = uvm_fault(map, trunc_page(va), 0, ftype); - KERNEL_UNLOCK(); if (error == 0) return; @@ -318,10 +316,8 @@ trap(struct trapframe *frame) } else vftype = ftype = PROT_READ; - KERNEL_LOCK(); error = uvm_fault(&p->p_vmspace->vm_map, trunc_page(frame->dar), 0, ftype); - KERNEL_UNLOCK(); if (error == 0) { uvm_grow(p, frame->dar); @@ -343,10 +339,8 @@ trap(struct trapframe *frame) ftype = PROT_READ | PROT_EXEC; - KERNEL_LOCK(); error = uvm_fault(&p->p_vmspace->vm_map, trunc_page(frame->srr0), 0, ftype); - KERNEL_UNLOCK(); if (error == 0) { uvm_grow(p, frame->srr0); Index: arch/powerpc64/powerpc64/trap.c =================================================================== RCS file: /cvs/src/sys/arch/powerpc64/powerpc64/trap.c,v retrieving revision 1.49 diff -u -p -r1.49 trap.c --- arch/powerpc64/powerpc64/trap.c 9 Jan 2021 13:14:02 -0000 1.49 +++ arch/powerpc64/powerpc64/trap.c 24 Apr 2021 03:21:02 -0000 @@ -126,9 +126,7 @@ trap(struct trapframe *frame) access_type = PROT_READ | PROT_WRITE; else access_type = PROT_READ; - KERNEL_LOCK(); error = uvm_fault(map, trunc_page(va), 0, access_type); - KERNEL_UNLOCK(); if (error == 0) return; @@ -237,9 +235,7 @@ trap(struct trapframe *frame) access_type = PROT_READ | PROT_WRITE; else access_type = PROT_READ; - KERNEL_LOCK(); error = uvm_fault(map, trunc_page(va), 0, access_type); - KERNEL_UNLOCK(); if (error == 0) uvm_grow(p, va); @@ -284,9 +280,7 @@ trap(struct trapframe *frame) map = &p->p_vmspace->vm_map; va = frame->srr0; access_type = PROT_READ | PROT_EXEC; - KERNEL_LOCK(); error = uvm_fault(map, trunc_page(va), 0, access_type); - KERNEL_UNLOCK(); if (error == 0) uvm_grow(p, va);