From owner-freebsd-arch@FreeBSD.ORG Fri Nov 14 23:19:32 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2521975D; Fri, 14 Nov 2014 23:19:32 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F0A96C4; Fri, 14 Nov 2014 23:19:31 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-70-85-31.nwrknj.fios.verizon.net [173.70.85.31]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 314DEB97F; Fri, 14 Nov 2014 18:19:30 -0500 (EST) From: John Baldwin To: Adrian Chadd Subject: Re: Questions about locking; turnstiles and sleeping threads Date: Fri, 14 Nov 2014 18:18:55 -0500 Message-ID: <1473017.e3PtKgPIoc@ralph.baldwin.cx> User-Agent: KMail/4.14.2 (FreeBSD/10.1-PRERELEASE; KDE/4.14.2; amd64; ; ) In-Reply-To: References: <201411130948.23785.jhb@freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 14 Nov 2014 18:19:30 -0500 (EST) Cc: Hans Petter Selasky , Alfred Perlstein , "freebsd-arch@freebsd.org" X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Nov 2014 23:19:32 -0000 On Thursday, November 13, 2014 09:32:14 AM Adrian Chadd wrote: > On 13 November 2014 06:48, John Baldwin wrote: > > On Thursday, November 13, 2014 4:52:50 am Adrian Chadd wrote: > >> Hm, the more I dig into this, the more I realise it's not a 1:45am > >> question to ask. > >> > >> Specifically, callout_stop_safe() takes 'safe', which says "are we > >> waiting around for this callout to finish if it started". Ie, > >> callout_drain() is callout_stop_safe(c, 1) ; callout_stop() is > >> callout_stop_safe(c, 0). > >> > >> If safe is 1, then it'll potentially put the current thread to sleep > >> in order to wait for it to synchronise with the callout that's > >> running. It's sleeping with cc_lock which is the per-callwheel lock > >> and it's doing that with whatever other locks are held. That's the > >> situation which is tripping things up. > >> > >> The manpage says that no locks should be held that the callout may > >> block on, which isn't the case here at all - I'm trying to grab a lock > >> in another thread that the caller _into_ the callout subsystem holds. > >> The manpage doesn't mention anything about this. Sniffle. > > > > It should just say "no sleepable locks at all". And yes, callout_stop() > > is > > perfectly fine to call with locks held. It is only callout_drain() that > > should not be called, same as with bus_teardown_intr() and > > taskqueue_drain() (other routines that can sleep while ensuring that an > > asynchronous task run by another thread is stopped). > > so, we should add WITNESS_WARN() to those as well? Sure. For bus_teardown_intr() the right place to do it is in the intr_event_*() that eventually gets called in kern_intr.c. -- John Baldwin