From owner-freebsd-stable@FreeBSD.ORG Thu May 1 05:15:56 2008 Return-Path: Delivered-To: stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 263CF10656D1; Thu, 1 May 2008 05:15:56 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id 128768FC1D; Thu, 1 May 2008 05:15:55 +0000 (UTC) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id 325491A4D82; Wed, 30 Apr 2008 21:57:36 -0700 (PDT) Date: Wed, 30 Apr 2008 21:57:36 -0700 From: Alfred Perlstein To: gnn@freebsd.org Message-ID: <20080501045736.GU30325@elvis.mu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Cc: stable@freebsd.org Subject: Re: Some odd behaviour of vmstat and vmtotal... X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 May 2008 05:15:56 -0000 * gnn@freebsd.org [080430 18:13] wrote: > Howdy, > > In deploying 7.0 at work we were finding a persistent problem when > running "vmstat 1" on systems. The problem shows up as a 10ms "pause" > in processing, usually packet stamping and forwarding by a user level > process. This is due to the fact that vmstat calls the vmtotal() > routine which in turn does a whole lot of locking. The vmtotal call > locks and walks the VM object list twice in a mark and sweep > operation. > > So, the question is, "What is the right way to fix this?" I could > remove the locking since the O_ACTIVE bit is not used by any other > routine besides vmtotal, but I'm not too happy about that. > > The relevant code can be found in src/sys/vm/vm_meter.c in vmtotal(). > > Thoughts? Can you _really_ remove the locking? I don't think that would be safe if the list is being manipulated, but I haven't checked. Typically one uses a sentinal to get around such problems. Basically insert a dummy object that no one should touch other than you, then drop the lock periodically and insert it into the list, then resume. -- - Alfred Perlstein