From owner-freebsd-arch@FreeBSD.ORG Thu Nov 13 17:32:16 2014 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 65A5C76D; Thu, 13 Nov 2014 17:32:16 +0000 (UTC) Received: from mail-wg0-x22d.google.com (mail-wg0-x22d.google.com [IPv6:2a00:1450:400c:c00::22d]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 06CC2B75; Thu, 13 Nov 2014 17:32:16 +0000 (UTC) Received: by mail-wg0-f45.google.com with SMTP id x12so17516159wgg.32 for ; Thu, 13 Nov 2014 09:32:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=1d4Etc2EKwk9xH3/Ymn6pgYv7kHgLK4GQN7g+GRsh5E=; b=e5+xyvrl/aF6nnnq5ZTmudn4IAs1PuoRS8hOmyhPZ96odhC946fC8x57+ag4BxGAyr kX4ECfolJU0ZLRcrDiGHFnMwkpOoVKQrjRu7FkAEQl2agrlF2nw8YZIjoiARsfB3aEqS QI4bKrUNvX6iW7d2Ncoogrrbii8m1qiY9KC6QSxqO2wh6O1fwcX1zcmjVy3DTWmYTFe2 Fnjscy33Yp9S2OQm43Nw7Faj2GYX/kJygISAXrFWKE7nFpHkbtS5s50Cqu4QQbZt/7wf C1aITsMdWddPLo8vCRfoP0QvzKjZhCdqqLVGpF5qOXuAuySv875U6SMk3byoveUHz8kG 5RtA== MIME-Version: 1.0 X-Received: by 10.194.85.83 with SMTP id f19mr6392364wjz.20.1415899934503; Thu, 13 Nov 2014 09:32:14 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.216.106.136 with HTTP; Thu, 13 Nov 2014 09:32:14 -0800 (PST) In-Reply-To: <201411130948.23785.jhb@freebsd.org> References: <54647D1E.9010904@freebsd.org> <201411130948.23785.jhb@freebsd.org> Date: Thu, 13 Nov 2014 09:32:14 -0800 X-Google-Sender-Auth: vclANLH5MH5sDqDuN4Hi9l5_NQw Message-ID: Subject: Re: Questions about locking; turnstiles and sleeping threads From: Adrian Chadd To: John Baldwin Content-Type: text/plain; charset=UTF-8 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: Thu, 13 Nov 2014 17:32:16 -0000 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? -adrian