tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Revamping lwp_park()



Updated diff:

- use the tree for lookup of zombies and fix a bug in _lwp_wait()
  (ESRCH -> EINVAL when waiting on a detached LWP)

- use the tree to allocate/compact LIDs for new LWPs.

- fix problems encountered compiling rust (first LWP is not always LID 1)

	http://www.netbsd.org/~ad/2020/lwp_park2.diff

Andrew

On Sun, Jan 26, 2020 at 08:16:39PM +0000, Andrew Doran wrote:
> There have been hangs with threaded tests recently so I took the opportunity
> to go back and see if the kernel side of this could be simplified.  What I
> have done is:
> 
> - Gotten rid of the hashed sleep queues for parking LWPs.
> 
> - Added a per-process RW lock and radix tree for looking up LWPs by ID (due
>   to a nice property of our radix tree implementation this doesn't allocate
>   any memory in the single-threaded case).
> 
> - Added a function to radixtree, for waiting for memory (radixtree was
>   designed for use in the VM system where the caller would eventually do a
>   uvm_wait() if there was an ENOMEM, this is a new kind of application).
> 
> - Made the sleep locked by the per-CPU spc_lwplock so it's kind of
>   optimistically per-CPU as far as the scheduler goes.
> 
> It works better than the hashed sleep queues but what I like personally is
> that the code is a lot simpler.  Any comments, thoughts?
> 
> Thanks,
> Andrew
> 
> 
> Diff including a change to radixtree.c/.h:
> 
> 	http://www.netbsd.org/~ad/2020/lwp_park.diff
> 
> sys_lwp.c in case it's easier to read:
> 
> 	http://www.netbsd.org/~ad/2020/sys_lwp.c
> 
> Kernel lock contention before and after on a pthread_mutex stress test:
> 
> 	http://www.netbsd.org/~ad/2020/stressor-before.txt
> 	http://www.netbsd.org/~ad/2020/stressor-after.txt


Home | Main Index | Thread Index | Old Index