On 2021/04/22 15:38, Martin Pieuchot 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'd be interested to have this tested and see how much does that impact
> the build time of packages.
>
> We should be able to do the switch on an arch-by-arch basis. It's
> easier for me to develop & debug on these two architectures so I started
> with them. If you want to unlock another architecture and report back,
> I'd be glad.
i386 with the below diff has survived a ports bulk build; machines are
quad core but I only run builds on 3 concurrent to keep a cap on RAM use.
Hard to say if there's any change in build time as they're a bit variable
anyway; seems to be not much change either way. Perhaps this is more
important with larger numbers of cores though.
Index: arch/i386/i386/trap.c
===================================================================
RCS file: /cvs/src/sys/arch/i386/i386/trap.c,v
retrieving revision 1.151
diff -u -p -r1.151 trap.c
--- arch/i386/i386/trap.c 27 Oct 2020 19:17:12 -0000 1.151
+++ arch/i386/i386/trap.c 22 Apr 2021 20:20:58 -0000
@@ -126,10 +126,7 @@ upageflttrap(struct trapframe *frame, ui
union sigval sv;
int signal, sicode, error;
- KERNEL_LOCK();
error = uvm_fault(&p->p_vmspace->vm_map, va, 0, access_type);
- KERNEL_UNLOCK();
-
if (error == 0) {
uvm_grow(p, va);
return 1;
@@ -203,9 +200,7 @@ kpageflttrap(struct trapframe *frame, ui
if (curcpu()->ci_inatomic == 0 || map == kernel_map) {
onfault = pcb->pcb_onfault;
pcb->pcb_onfault = NULL;
- KERNEL_LOCK();
error = uvm_fault(map, va, 0, access_type);
- KERNEL_UNLOCK();
pcb->pcb_onfault = onfault;
if (error == 0 && map != kernel_map)