From owner-freebsd-hackers Tue May 18 3:14:49 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from nomad.dataplex.net (nomad.dataplex.net [216.140.184.132]) by hub.freebsd.org (Postfix) with ESMTP id 1791514CFF for ; Tue, 18 May 1999 03:14:35 -0700 (PDT) (envelope-from rkw@dataplex.net) Received: from localhost (rkw@localhost) by nomad.dataplex.net (8.9.2/8.9.3) with ESMTP id FAA06416; Tue, 18 May 1999 05:14:23 -0500 (CDT) (envelope-from rkw@dataplex.net) X-Authentication-Warning: nomad.dataplex.net: rkw owned process doing -bs Date: Tue, 18 May 1999 05:14:23 -0500 (CDT) From: Richard Wackerbarth Reply-To: rkw@dataplex.net To: Marc Slemko Cc: hackers@FreeBSD.ORG Subject: Re: libkvm sucks In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, 17 May 1999, Marc Slemko wrote: > The reasoning: reading from kernel data structures without any locking has > obvious race conditions. [...] > This is why netstat will often bail out in the middle with kvm errors on a > busy machine with lots of TCP connections, especially if you slow it down > by doing hostname lookups. I agree that locking, in one form or another, is required to traverse dynamic chains. However, this applies to the functionality wherever it is implemented. Moving the formatting to the kernel does not change anything. If you are concerned about the time that it takes to do hostname lookups, that time is not any shorter in the kernel. There are two fundamental approaches that work. 1) Lock the structure Make a snapshot copy Unlock the structure Generate the report from the copy Destroy the copy This technique can be used in either userland or kernel implementation. Even without the structure locks, the failure window is considerably smaller for those operations that require a long time to format the report. 2) Use list traversal protocols that prevent the actual deletes from occurring while there is another list reader in that portion of the list. Again, the only requirement in the kernel is the ability set and clear the lock. The remainder of the formatting can occur outside the kernel because the structures being viewed and not destroyed during the traversal. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message