From owner-freebsd-net@FreeBSD.ORG Wed Dec 19 19:50:34 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 677A2622 for ; Wed, 19 Dec 2012 19:50:34 +0000 (UTC) (envelope-from fodillemlinkarim@gmail.com) Received: from mail-ie0-f171.google.com (mail-ie0-f171.google.com [209.85.223.171]) by mx1.freebsd.org (Postfix) with ESMTP id 235908FC12 for ; Wed, 19 Dec 2012 19:50:33 +0000 (UTC) Received: by mail-ie0-f171.google.com with SMTP id 17so3404185iea.16 for ; Wed, 19 Dec 2012 11:50:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=t9yoInCx4wO/sSNMFei8Iy7IItxqbfV0PKupac2Wzho=; b=YVNYXySiCu2PlmxPKQ/xr99KikgNrBSLvEw+vFtkFgt4YdLtYuVJnR/YYR0PlzP3wG 92wOeveIU9pXw3DHfNjggu2r/Sx3kXilImlldZcuMf8YqSDqEhzebMCjYZwqqvNASnK4 5ouplCFNQOWYEAbsFjfrxXL8nkcZFYCy+wPbyJr1+ef/u9k7Am6NRgBcS+zF7RnjFfg5 a3MAtkgwlRzYGAY9nT8O5fGTzslKJ3//0puUshdNnuB0VMd0xbXduwO1P9MSx7PdsR3D 92uyAXehiQFMmC8Bi03+BiDA44JKNbyvIH5LgMPMxSYA8ygC9WSmITn7ZXz/CX4APaOQ e+Mw== X-Received: by 10.50.161.169 with SMTP id xt9mr8238046igb.62.1355946627134; Wed, 19 Dec 2012 11:50:27 -0800 (PST) Received: from [192.168.1.73] ([208.85.112.101]) by mx.google.com with ESMTPS id yf6sm4950719igb.0.2012.12.19.11.50.25 (version=SSLv3 cipher=OTHER); Wed, 19 Dec 2012 11:50:25 -0800 (PST) Message-ID: <50D21A75.1020403@gmail.com> Date: Wed, 19 Dec 2012 14:50:13 -0500 From: Karim Fodil-Lemelin User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: freebsd-net@freebsd.org Subject: Re: use of V_tcbinfo lock for TCP syncache References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Dec 2012 19:50:34 -0000 On 19/12/2012 2:31 PM, Vijay Singh wrote: > As it is today, a socket upcall on a listener socket is made with the > V_tcbinfo lock held. [tcp_input -> syncache_socket -> sonewconn -> > sowakeup]. > > I feel that the use of the V_tcbinfo is not consistent in the syncache code. > > In syncache_add(), we drop the lock before doing the lookup: > > INP_WUNLOCK(inp); > INP_INFO_WUNLOCK(&V_tcbinfo); > [..snip..] > sc = syncache_lookup(inc, &sch); /* returns locked entry */ > > However, when going through syncache_expand() or syncache_chkrst() we > keep the V_tcbinfo lock. > > Since the syncache has its own lock, do we need to hold the V_tcbinfo > lock when calling syncache_socket()? > > Every time the list of TCP control blocks (tcbinfo) is manipulated, a write lock must be held to protect it. syncache_expand() is responsible for 'expanding' the listening socket into a full blown accepted socket, including creating its associated control block in the process. By the way I don't think V_tcbinfo lock is held for syncache_chkrst() or needed for that matter but I could be wrong since I'm looking at 7.x code. Karim.