On Thu, Apr 22, 2021 at 03:38:53PM +0200, 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.

Full regress test on amd64 successful.

http://bluhm.genua.de/regress/results/regress-ot6.html
When you click on custom, you see the diff that was tested.

bluhm

> 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.
> 
> Thanks,
> Martin
> 
> Index: arch/amd64/amd64/trap.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/amd64/amd64/trap.c,v
> retrieving revision 1.87
> diff -u -p -r1.87 trap.c
> --- arch/amd64/amd64/trap.c   22 Oct 2020 13:41:51 -0000      1.87
> +++ arch/amd64/amd64/trap.c   22 Apr 2021 13:06:54 -0000
> @@ -176,10 +176,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;
> @@ -261,9 +258,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)
> Index: arch/sparc64/sparc64/trap.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/sparc64/sparc64/trap.c,v
> retrieving revision 1.108
> diff -u -p -r1.108 trap.c
> --- arch/sparc64/sparc64/trap.c       11 Mar 2021 11:17:00 -0000      1.108
> +++ arch/sparc64/sparc64/trap.c       22 Apr 2021 13:06:54 -0000
> @@ -773,10 +773,7 @@ data_access_fault(struct trapframe64 *tf
>               if (!(addr & TLB_TAG_ACCESS_CTX)) {
>                       /* CTXT == NUCLEUS */
>  
> -                     KERNEL_LOCK();
>                       error = uvm_fault(kernel_map, va, 0, access_type);
> -                     KERNEL_UNLOCK();
> -
>                       if (error == 0)
>                               return;
>                       goto kfault;
> @@ -792,9 +789,7 @@ data_access_fault(struct trapframe64 *tf
>  
>       onfault = (vaddr_t)p->p_addr->u_pcb.pcb_onfault;
>       p->p_addr->u_pcb.pcb_onfault = NULL;
> -     KERNEL_LOCK();
>       error = uvm_fault(&p->p_vmspace->vm_map, (vaddr_t)va, 0, access_type);
> -     KERNEL_UNLOCK();
>       p->p_addr->u_pcb.pcb_onfault = (void *)onfault;
>  
>       /*
> @@ -959,9 +954,7 @@ text_access_fault(struct trapframe64 *tf
>           uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial))
>               goto out;
>  
> -     KERNEL_LOCK();
>       error = uvm_fault(&p->p_vmspace->vm_map, va, 0, access_type);
> -     KERNEL_UNLOCK();
>  
>       /*
>        * If this was a stack access we keep track of the maximum
> @@ -1055,9 +1048,7 @@ text_access_error(struct trapframe64 *tf
>           uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial))
>               goto out;
>  
> -     KERNEL_LOCK();
>       error = uvm_fault(&p->p_vmspace->vm_map, va, 0, access_type);
> -     KERNEL_UNLOCK();
>  
>       /*
>        * If this was a stack access we keep track of the maximum

Reply via email to