From owner-freebsd-smp Wed Apr 24 4:14:36 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 AC8BE37B41F; Wed, 24 Apr 2002 04:14:16 -0700 (PDT) Received: from sohgo.carrots.uucp.r.dl.itc.u-tokyo.ac.jp (sohgo.carrots.uucp.r.dl.itc.u-tokyo.ac.jp [IPv6:3ffe:b80:5b0:3:200:e8ff:fe14:9f8a]) by rina.r.dl.itc.u-tokyo.ac.jp (8.12.2/3.7W-rina.r-Nankai-Koya) with ESMTP id g3OBCi0o088852 ; Wed, 24 Apr 2002 20:12:45 +0900 (JST) Received: from sohgo.carrots.uucp.r.dl.itc.u-tokyo.ac.jp (localhost [IPv6:::1]) by sohgo.carrots.uucp.r.dl.itc.u-tokyo.ac.jp (8.12.2/3.7W-carrots-Tokyu-Meguro) with ESMTP id g3OBChph026311 ; Wed, 24 Apr 2002 20:12:43 +0900 (JST) Received: (from root@localhost) by sohgo.carrots.uucp.r.dl.itc.u-tokyo.ac.jp (8.12.2/3.7W-submit-carrots-Tokyu-Meguro) with UUCP id g3OBCKeh026310 ; Wed, 24 Apr 2002 20:12:21 +0900 (JST) Received: from bunko.nkth.carrots.uucp.r.dl.itc.u-tokyo.ac.jp (localhost [127.0.0.1]) by bunko (8.12.2/3.7W-nkth.carrots-Saitama-Misono) with ESMTP id g3OB8u8t006194 ; Wed, 24 Apr 2002 20:10:16 +0900 (JST) Message-Id: <200204241110.g3OB8u8t006194@bunko> Date: Wed, 24 Apr 2002 20:08:56 +0900 From: Seigo Tanimura To: current@FreeBSD.org, smp@FreeBSD.org Subject: Locking down a socket, milestone 1 Cc: Seigo Tanimura 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 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. - Add a global sx sigio_lock to protect the pointer to the sigio object of a socket. This is to avoid lock order reversal caused by locking a process in pgsigio(). This lock should be applicable to a pipe as well. Although there are still lots of works to do, the patch has grown up quite a lot. so_options is the most notorious member in struct socket so far because it is used in almost all of the protocol stacks. I would therefore like to test, fix and merge the patch before it blows up. Comments are welcome. Thanks. -- Seigo Tanimura To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message