From owner-freebsd-current@freebsd.org Thu Jul 2 07:08:39 2015 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B7296992B02 for ; Thu, 2 Jul 2015 07:08:39 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::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 2C61E2AC9 for ; Thu, 2 Jul 2015 07:08:38 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id t6278WP7076283 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Thu, 2 Jul 2015 10:08:32 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua t6278WP7076283 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id t6278SBV076282; Thu, 2 Jul 2015 10:08:28 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 2 Jul 2015 10:08:28 +0300 From: Konstantin Belousov To: Ryan Stone Cc: Jack Vogel , FreeBSD Current Subject: Re: How should a driver shutdown a taskqueue on detach? Message-ID: <20150702070828.GH2080@kib.kiev.ua> References: <20150701213241.GG2080@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.20 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: Thu, 02 Jul 2015 07:08:39 -0000 On Wed, Jul 01, 2015 at 06:28:49PM -0400, Ryan Stone wrote: > On Wed, Jul 1, 2015 at 5:32 PM, Konstantin Belousov > wrote: > > > Do you mean, you want some KPI like > > boolean taskqueue_is_draining(struct taskqueue *p); > > so that e.g. executed task could see if it is executing in the > > shutdown state ? > > > I'd prefer a KPI that stops a taskqueue from accepting new tasks (and drops > attempts to enqueue on the floor). Then I could do something like: > > taskqueue_stop() > disable_interrupts() > taskqueue_drain_all() > taskqueue_free() Having taskqueue_enqueue() which could silently (?) not enqueue the given task is huge and IMO risky change to the KPI. If doing it, I think that there should be a new function to enqueue, which is allowed to fail, unlike taskqueue_enqueue(). BTW, the man page for taskqueue(9) is wrong, taskqueue_enqueue(9) always succeed now and always returns 0 (ignoring the ushort overflow).