From owner-freebsd-hackers@FreeBSD.ORG Tue May 29 22:06:16 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5D328106564A; Tue, 29 May 2012 22:06:16 +0000 (UTC) (envelope-from vasanth.raonaik@gmail.com) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx1.freebsd.org (Postfix) with ESMTP id B87B48FC0A; Tue, 29 May 2012 22:06:15 +0000 (UTC) Received: by wibhn6 with SMTP id hn6so2571762wib.13 for ; Tue, 29 May 2012 15:06:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=8YNYLBysEGOp0xb8FZ6vMb1rrPncGs7LmuL6z/L9xbs=; b=UnbmM8tpTHdfslUYnsZa4CUr4jiCmeyxlGlJ9T6UPthwYwIyYyGk5OVIjaoMPuVk4C WQI12D++Q4ih5cIHb1vJNk6o/y+sh4FbhdCMrdc1NLvYCdMfF32B+12oDuy+ay0TVxEu ZMfFbFAIm6ukY/A2LmGpUwDJ4qa5RjVCDIpIz+vXa+/+aUX+mDCJOxXIVEaUvSLW14Ee 31axMxoC9k0UZmbsVRltYfNqFzBlruK81U5cNpDOnSjonOGNAInZbJLsdF/PH3EP0/Pb hubX7L+pmn5ecix/d0GlkPpnpkxSsLoSf07hcgVrNtwNDsOE3cDhI1Wpvj+0oNRXIxW8 NZlg== MIME-Version: 1.0 Received: by 10.216.139.73 with SMTP id b51mr9041541wej.72.1338329174734; Tue, 29 May 2012 15:06:14 -0700 (PDT) Received: by 10.180.146.37 with HTTP; Tue, 29 May 2012 15:06:14 -0700 (PDT) In-Reply-To: References: Date: Tue, 29 May 2012 18:06:14 -0400 Message-ID: From: vasanth rao naik sabavat To: Robert Watson Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: freebsd-hackers@freebsd.org Subject: Re: SMP: protocol control block protection for a multithreaded process (ex: udp). X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2012 22:06:16 -0000 Hello Robert, My main concern is about the protocol control block "inp", a reference in the socket structure. the udp_detach() free'es the inp but there is a potential for other thread running udp_* functions to get hold of the reference? Also, sofree() calls SOCK_UNLOCK() which potentially may allow other thread of the same process to enter into the udp_* functions? I am not sure if that is ever possible. Thanks, Vasanth On Tue, May 29, 2012 at 5:06 PM, Robert Watson wrote: > > On Tue, 29 May 2012, vasanth rao naik sabavat wrote: > > Can somebody please reply to this email. >> >> basically, can udp_detach() and udp_send() execute simultaneously for a >> process with multiple threads? if yes, then inp reference in udp_send() >> will be stale if udp_detach() free's the inp? >> > > You are confusing application-level close() with an actual close in the > socket implementation. The socket will remain allocated as long as there > are consumers using it, which is ensured through a reference count on the > socket, regardless of close(). That isn't to say that there aren't bugs -- > this stuff is pretty complex -- but the life cycle and synchronisation > models around sockets should prevent the scenario you are describing from > occurring. > > Robert > > >> Thanks, >> Vasanth >> >> >> >> On Tue, May 29, 2012 at 10:53 AM, vasanth rao naik sabavat < >> vasanth.raonaik@gmail.com> wrote: >> >> Hi, >>> >>> In case of a Multicore cpu system running a multithreaded process. >>> >>> For protocol control blocks there is no protection provided in the >>> FreeBSD >>> 9. For example, udp_close() and udp_send() access the inp before taking >>> the >>> lock. Couldn't this cause the inp inconsistency on a multithreaded >>> process >>> running on multicore cpu system? >>> >>> Say, If the two threads of a process are concurrently executing socket >>> send and socket close say on a udp connection (this can happen in case of >>> poorly written user code.). >>> udp_close() will access the inp on one cpu and udp_send() will access the >>> inp on another cpu. it is possible that udp_close() gets the locks first >>> and free's the inp before udp_send() has a chance to run? >>> >>> Am I missing anything? >>> >>> Thanks, >>> Vasanth >>> >>> >>> >>> >>> >>> ______________________________**_________________ >> freebsd-hackers@freebsd.org mailing list >> http://lists.freebsd.org/**mailman/listinfo/freebsd-**hackers >> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@** >> freebsd.org " >> >>