From owner-freebsd-stable@FreeBSD.ORG Thu May 1 15:59:09 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 109381065675 for ; Thu, 1 May 2008 15:59:09 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from ebb.errno.com (ebb.errno.com [69.12.149.25]) by mx1.freebsd.org (Postfix) with ESMTP id D8F608FC19 for ; Thu, 1 May 2008 15:59:08 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from trouble.errno.com (trouble.errno.com [10.0.0.248]) (authenticated bits=0) by ebb.errno.com (8.13.6/8.12.6) with ESMTP id m41FcOZq064942 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 1 May 2008 08:38:25 -0700 (PDT) (envelope-from sam@freebsd.org) Message-ID: <4819E3F0.9040308@freebsd.org> Date: Thu, 01 May 2008 08:38:24 -0700 From: Sam Leffler Organization: FreeBSD Project User-Agent: Thunderbird 2.0.0.9 (X11/20071125) MIME-Version: 1.0 To: Alfred Perlstein References: <20080501045736.GU30325@elvis.mu.org> In-Reply-To: <20080501045736.GU30325@elvis.mu.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-DCC-dcc1-Metrics: ebb.errno.com; whitelist Cc: gnn@freebsd.org, 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 15:59:09 -0000 Alfred Perlstein wrote: > * 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. > > net80211 uses a scan generation # to walk it's node lists. No sentinel. Sam