Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 May 1999 05:14:23 -0500 (CDT)
From:      Richard Wackerbarth <rkw@dataplex.net>
To:        Marc Slemko <marcs@znep.com>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: libkvm sucks
Message-ID:  <Pine.BSF.4.05.9905180456530.6225-100000@nomad.dataplex.net>
In-Reply-To: <Pine.BSF.4.05.9905172057160.24565-100000@alive.znep.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9905180456530.6225-100000>