From owner-freebsd-net@FreeBSD.ORG Fri Mar 25 21:01:36 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 06D5F106564A; Fri, 25 Mar 2011 21:01:36 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id D26F98FC08; Fri, 25 Mar 2011 21:01:35 +0000 (UTC) Received: from bigwig.baldwin.cx (66.111.2.69.static.nyinternet.net [66.111.2.69]) by cyrus.watson.org (Postfix) with ESMTPSA id 832FD46B09; Fri, 25 Mar 2011 17:01:35 -0400 (EDT) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 195D38A01B; Fri, 25 Mar 2011 17:01:35 -0400 (EDT) From: John Baldwin To: freebsd-net@freebsd.org Date: Fri, 25 Mar 2011 17:01:34 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110311; KDE/4.5.5; amd64; ; ) References: In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201103251701.34576.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.6 (bigwig.baldwin.cx); Fri, 25 Mar 2011 17:01:35 -0400 (EDT) Cc: Jim , Robert Watson Subject: Re: why use INP_WLOCK instead of INP_RLOCK X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Mar 2011 21:01:36 -0000 On Tuesday, February 01, 2011 12:54:33 am Jim wrote: > Hi All, > > I am not sure if anybody has asked it before. I could not find answer by > doing rough search on Internet, if it is duplicate question, sorry in > advance. > > My question is that, for getting socket options in tcp_ctloutput() in > tcp_usrreq.c, why do we need to do lock with INP_WLOCK(inp) as setting > socket options does. Why do we just use INP_RLOCK(inp), as it looks not > changing anything in tcp control block? > > Thank you for your kindly answer. I think mostly it is just because no one has bothered to change it. Realistically it probably won't make any noticable difference unless your workload consists of doing lots of calls to getsockopt() but not sending any actual traffic on the associated sockets. :) (Almost all of the other operations on a TCP connection require a write lock on the pcb.) -- John Baldwin