From owner-freebsd-smp Thu Apr 25 1:19:12 2002 Delivered-To: freebsd-smp@freebsd.org Received: from rina.r.dl.itc.u-tokyo.ac.jp (rina.r.dl.itc.u-tokyo.ac.jp [133.11.199.247]) by hub.freebsd.org (Postfix) with ESMTP id 511BF37B41D; Thu, 25 Apr 2002 01:19:01 -0700 (PDT) Received: from rina.r.dl.itc.u-tokyo.ac.jp (localhost [127.0.0.1]) by rina.r.dl.itc.u-tokyo.ac.jp (8.12.2/3.7W-rina.r-Nankai-Koya) with ESMTP id g3P8J00o013784 ; Thu, 25 Apr 2002 17:19:00 +0900 (JST) Message-Id: <200204250819.g3P8J00o013784@rina.r.dl.itc.u-tokyo.ac.jp> Date: Thu, 25 Apr 2002 17:19:00 +0900 From: Seigo Tanimura To: John Baldwin Cc: Seigo Tanimura , smp@FreeBSD.org, current@FreeBSD.org Subject: Re: Locking down a socket, milestone 1 In-Reply-To: References: <200204241110.g3OB8u8t006194@bunko> User-Agent: Wanderlust/2.8.1 (Something) SEMI/1.14.3 (Ushinoya) FLIM/1.14.3 (=?ISO-8859-1?Q?Unebigory=F2mae?=) APEL/10.3 MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386--freebsd) Organization: Digital Library Research Division, Information Techinology Centre, The University of Tokyo MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Wed, 24 Apr 2002 10:18:01 -0400 (EDT), John Baldwin said: jhb> On 24-Apr-2002 Seigo Tanimura wrote: >> I am now working on locking down a socket. (I have heard that Jeffrey >> Hsu is also doing that, but I have never seen his patch. Has anyone >> seen that?) My first milestone patch is now available at: >> >> >> http://people.FreeBSD.org/~tanimura/patches/socket_milestone1.diff.gz >> >> >> The works I have done so far are: >> >> >> - Determine the lock required to protect each of the members in struct >> socket. >> >> - Add mutexes to each of the sockbufs in a socket as BSD/OS does. >> >> - Lock down so_count, so_options, so_linger and so_state. >> >> - Add a global mutex socq_lock to protect the connection queues of a >> listening socket. Lock socq_lock to lock two sockets at once, >> followed by enqueuing or dequeuing a socket, or moving a socket across >> queues. socq_lock is not an sx lock because we usually have to lock >> two sockets to modify them. jhb> Do you actually lock two sockets at once or do you lock one at a time while jhb> holding socq_lock. If you do lock two at once, what is the defined locking jhb> order? At the moment, I lock two sockets at once. This is required, eg in soisconnected() to move an accepting socket across the connection queues of a listening socket. The lock order is: 1. socq_lock 2. an accepting socket 3. a listening socket (in so_head of the accepting socket) -- Seigo Tanimura To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message