From owner-freebsd-net@FreeBSD.ORG Wed Dec 19 19:42:59 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 CCE024B7 for ; Wed, 19 Dec 2012 19:42:59 +0000 (UTC) (envelope-from nparhar@gmail.com) Received: from mail-pb0-f54.google.com (mail-pb0-f54.google.com [209.85.160.54]) by mx1.freebsd.org (Postfix) with ESMTP id 967BB8FC0A for ; Wed, 19 Dec 2012 19:42:59 +0000 (UTC) Received: by mail-pb0-f54.google.com with SMTP id wz12so1433157pbc.13 for ; Wed, 19 Dec 2012 11:42:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=ERXM3BhhsugJArqLwEi/7Cd2EhaphWTwvD8X/3qExPI=; b=vaK29a1PsH5AY7Cpw0omYIA62WN0KPnFOUTc1VXe6h24T3RMkDtxLKJKRTM4U2yQZq fxI//QuVJ4wyO/AmTnGMEe1g2NAQDPWLQbAoiW0UKluJ/fdlCtXDdKRBC9N4Tee4MpVe HdNETJ6JbSSA57Y+SInBUDZ5A7OGQQnIZCKzgWI7bVMKcL4koObvV0garHnELNR2Zzb3 nss46I4r2BU+n/CAh6OFizCqILUP0tmTYpLnZCrGIEMfgmHlBU2Wl2tZwBumLNGln8IU govyBCah13rK/3KhU0qn9/2UGClNQ7/AfTgwhHIwvB+4nytm35VTxbU+4s3Tueop71AS nN4A== X-Received: by 10.68.227.41 with SMTP id rx9mr21569835pbc.121.1355946173743; Wed, 19 Dec 2012 11:42:53 -0800 (PST) Received: from [10.192.166.0] (stargate.chelsio.com. [67.207.112.58]) by mx.google.com with ESMTPS id ip8sm3587089pbc.36.2012.12.19.11.42.51 (version=SSLv3 cipher=OTHER); Wed, 19 Dec 2012 11:42:52 -0800 (PST) Sender: Navdeep Parhar Message-ID: <50D218BA.7080301@FreeBSD.org> Date: Wed, 19 Dec 2012 11:42:50 -0800 From: Navdeep Parhar User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Vijay Singh Subject: Re: use of V_tcbinfo lock for TCP syncache References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-net@freebsd.org 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:42:59 -0000 On 12/19/12 11:31, 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()? Holding the pcbinfo lock prevents races between syncache_socket() and accept(). See rwatson's comment just above tcp_usr_accept. I noted this too (the comment above tod->tod_offload_socket() in tcp_syncache.c) back when I updated the TOE code in the kernel. Regards, Navdeep