From owner-freebsd-current@FreeBSD.ORG Tue Aug 1 15:45:44 2006 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0B52416A4E0; Tue, 1 Aug 2006 15:45:44 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.FreeBSD.org (Postfix) with ESMTP id B3E8C43D6E; Tue, 1 Aug 2006 15:45:42 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k71FjeFM080313; Tue, 1 Aug 2006 11:45:40 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-current@freebsd.org Date: Tue, 1 Aug 2006 11:22:17 -0400 User-Agent: KMail/1.9.1 References: <20060726063636.GA58151@freefall.freebsd.org> <17610.836.663396.331448@jerusalem.litteratus.org> <44CE6C0A.50009@FreeBSD.org> In-Reply-To: <44CE6C0A.50009@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200608011122.18189.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Tue, 01 Aug 2006 11:45:40 -0400 (EDT) X-Virus-Scanned: ClamAV 0.87.1/1629/Tue Aug 1 07:19:34 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00, SUBJECT_EXCESS_QP autolearn=ham version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx Cc: Robert Huff , "Christian S.J. Peron" Subject: Re: LOR when booting CURRENT (ip_divert.c, PFil hook read/write mutex) [#181] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Aug 2006 15:45:44 -0000 On Monday 31 July 2006 16:46, Christian S.J. Peron wrote: > Robert Huff wrote: > > Yar Tikhiy writes: > > > > > >> FWIW, the LOR still is there. I was seeing it yesterday while > >> fiddling with the ipfw and natd rc.d scripts. > >> > >> lock order reversal: > >> 1st 0xc1a36090 inp (divinp) @ /usr/src/sys/modules/ipdivert/../../netinet/ip_divert.c:350 > >> 2nd 0xc0a51918 PFil hook read/write mutex (PFil hook read/write mutex) @ /usr/src/sys/net/pfil.c:73 > >> > > > > For the record, I'm (still) getting this also. > > > > > > Robert Huff > > _______________________________________________ > > freebsd-current@freebsd.org mailing list > > http://lists.freebsd.org/mailman/listinfo/freebsd-current > > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > > > > > > > > This appears to be similar to the LOR associated with IPFW and ucred > based rules, I think. Although this is a lock order reversal and it > probably isn't a false positive, it should be reasonably harmless, > because the pfil hook lock is a reader lock, thus different threads can > acquire it (at this point) con-currently, presumably preventing a dead > lock from actually occurring here. > > iirc witness it not aware of the reader/writer semantics, so it makes > sense that it will be dropping a warning here. But I can look at this in > further detail when I get a bit of time. No, a LOR is a LOR. Readers vs writers don't matter for ordering reasons. Talk yourself through it and you'll see. The reason is that a writer can always block on a reader, and a reader will block if there's a writer already holding the lock. While you can end up in some situations where a LOR might not deadlock at the time if both threads involved are getting read locks, at some point a thread will need to get a write lock (otherwise you wouldn't need a lock!) and then you can get a deadlock between the thread with the write lock and a thread acquiring the locks in reverse order even if that second thread is only getting a read lock. Specifically, given mtx A, and rwlock B, while it may be safe for a thread to rlock B and lock A while another thread does lock A and rlock B w/o triggering deadlock, if a thread does lock A and then wlock B, then when another tried tries to rlock B and then lock A you will get deadlock. -- John Baldwin