Re: Spinlock thrashing with libthr

From: John Baldwin <jhb_at_freebsd.org>
Date: Mon, 17 Apr 2006 09:08:21 -0400
On Friday 14 April 2006 07:17 pm, Kris Kennaway wrote:
> On Fri, Apr 14, 2006 at 06:43:18PM -0400, Kris Kennaway wrote:
> > I ran a modified version of the thr1 stress test on a quad amd64,
> > which spawns 256 threads (using libthr), each of which loops doing
> > getpid() 10000 times.  The system spends essentially 100% of the time
> > in the kernel.  Profiling with hwpmc shows that the system is spending
> > about 60% time in _mtx_lock_spin().
>
> Turns out this is because of contention for the PROC_LOCK, which means
> lots of processes sleeping.  Using getuid() instead (which doesn't
> acquire locks) does not show contention.  Thanks to rwatson for
> figuring it out.

Or drop COMPAT_43 from your kernel config so getpid() doesn't try to
read the parent process' pid.  Still, I might be able to make this better
by redoing the adaptive spinning to happen before we grab the turnstile
lock (there are some other reasons this would be beneficial, such as
simplifying the rwlock adaptive code for example).

-- 
John Baldwin <jhb_at_FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org
Received on Mon Apr 17 2006 - 11:08:25 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:55 UTC