tech-kern archive

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

Revamping lwp_park()



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