From owner-freebsd-arch@FreeBSD.ORG Mon Jul 7 23:15:26 2008 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 32FB91065683 for ; Mon, 7 Jul 2008 23:15:26 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from cyrus.watson.org (cyrus.watson.org [209.31.154.42]) by mx1.freebsd.org (Postfix) with ESMTP id 0BEF38FC0C for ; Mon, 7 Jul 2008 23:15:25 +0000 (UTC) (envelope-from rwatson@FreeBSD.org) Received: from fledge.watson.org (fledge.watson.org [209.31.154.41]) by cyrus.watson.org (Postfix) with ESMTP id 9869D46C81; Mon, 7 Jul 2008 19:15:24 -0400 (EDT) Date: Tue, 8 Jul 2008 00:15:24 +0100 (BST) From: Robert Watson X-X-Sender: robert@fledge.watson.org To: Sergey Babkin In-Reply-To: <22395548.214801215451968131.JavaMail.root@vms227.mailsrvcs.net> Message-ID: <20080708000701.R63144@fledge.watson.org> References: <22395548.214801215451968131.JavaMail.root@vms227.mailsrvcs.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: arch@freebsd.org Subject: Re: Re: Re: Proposal: a revoke() system call X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jul 2008 23:15:26 -0000 On Mon, 7 Jul 2008, Sergey Babkin wrote: >> Well, fixing this is easy -- instead of holding a reference to the file >> descriptor over the system call, hold a reference to the socket. The >> problem with that is that it creates a lot more contention on the socket >> locks when the reference count is dropped, not to mention more locking >> operations. This can be fixed but requires quite a lot of work, whereas >> this rather minor semantic issue is a non-problem in practice. I do have >> dealing with this > > I can't comment much without actually looking at the code, but why would the > contention on close() be such an issue? Close() is not called that often, > compared for example to read(), so there should not be much contention to > start with. And why not just call the shutdown() logic from inside close() > implementation? This is a fairly complex issue, and one that doesn't lend itself to in-depth discussion without first looking at the code. To direct your reading, I recommend starting with the socket reference model -- you can find a high-level summary in the comments at the head of uipc_socket.c, and the comments on sofree(9). The question you're getting at indirectly has to do with the differences between fdrop(9), which drops a reference to a file descriptor, and fputsock(9), which drops a reference to a socket. You'll also find it useful to do a bit of reading regarding the difference between close(2), which releases a reference to a file descriptor from userspace, and fo_close(9), which is invoked in-kernel when the last reference to a file descriptor goes away. Robert N M Watson Computer Laboratory University of Cambridge