From owner-freebsd-current@FreeBSD.ORG Mon Apr 17 13:08:25 2006 Return-Path: X-Original-To: current@freebsd.org Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 30AA616A405; Mon, 17 Apr 2006 13:08:25 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id A41D043D45; Mon, 17 Apr 2006 13:08:24 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from zion.baldwin.cx (zion.baldwin.cx [192.168.0.7]) (authenticated bits=0) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k3HD8NJT071664; Mon, 17 Apr 2006 09:08:23 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Kris Kennaway Date: Mon, 17 Apr 2006 09:08:21 -0400 User-Agent: KMail/1.8.3 References: <20060414224318.GA8716@xor.obsecurity.org> <20060414231759.GA9342@xor.obsecurity.org> In-Reply-To: <20060414231759.GA9342@xor.obsecurity.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200604170908.22599.jhb@freebsd.org> X-Virus-Scanned: ClamAV 0.87.1/1403/Sun Apr 16 05:44:45 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.0 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx Cc: current@freebsd.org, davidxu@freebsd.org Subject: Re: Spinlock thrashing with libthr X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Apr 2006 13:08:25 -0000 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). =2D-=20 John Baldwin =A0<>< =A0http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" =A0=3D =A0http://www.FreeBSD.org