From owner-svn-src-head@freebsd.org Thu Mar 2 12:20:24 2017 Return-Path: Delivered-To: svn-src-head@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 C28F6CF171B; Thu, 2 Mar 2017 12:20:24 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 79CC4D0D; Thu, 2 Mar 2017 12:20:24 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v22CKNk9072751; Thu, 2 Mar 2017 12:20:23 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v22CKNCS072749; Thu, 2 Mar 2017 12:20:23 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201703021220.v22CKNCS072749@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Thu, 2 Mar 2017 12:20:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314553 - in head/sys: kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Mar 2017 12:20:24 -0000 Author: hselasky Date: Thu Mar 2 12:20:23 2017 New Revision: 314553 URL: https://svnweb.freebsd.org/changeset/base/314553 Log: Implement taskqueue_poll_is_busy() for use by the LinuxKPI. Refer to comment above function for a detailed description. Discussed with: kib @ MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/kern/subr_taskqueue.c head/sys/sys/taskqueue.h Modified: head/sys/kern/subr_taskqueue.c ============================================================================== --- head/sys/kern/subr_taskqueue.c Thu Mar 2 10:44:57 2017 (r314552) +++ head/sys/kern/subr_taskqueue.c Thu Mar 2 12:20:23 2017 (r314553) @@ -487,6 +487,23 @@ task_is_running(struct taskqueue *queue, return (0); } +/* + * Only use this function in single threaded contexts. It returns + * non-zero if the given task is either pending or running. Else the + * task is idle and can be queued again or freed. + */ +int +taskqueue_poll_is_busy(struct taskqueue *queue, struct task *task) +{ + int retval; + + TQ_LOCK(queue); + retval = task->ta_pending > 0 || task_is_running(queue, task); + TQ_UNLOCK(queue); + + return (retval); +} + static int taskqueue_cancel_locked(struct taskqueue *queue, struct task *task, u_int *pendp) Modified: head/sys/sys/taskqueue.h ============================================================================== --- head/sys/sys/taskqueue.h Thu Mar 2 10:44:57 2017 (r314552) +++ head/sys/sys/taskqueue.h Thu Mar 2 12:20:23 2017 (r314553) @@ -79,6 +79,7 @@ int taskqueue_start_threads_cpuset(struc int taskqueue_enqueue(struct taskqueue *queue, struct task *task); int taskqueue_enqueue_timeout(struct taskqueue *queue, struct timeout_task *timeout_task, int ticks); +int taskqueue_poll_is_busy(struct taskqueue *queue, struct task *task); int taskqueue_cancel(struct taskqueue *queue, struct task *task, u_int *pendp); int taskqueue_cancel_timeout(struct taskqueue *queue,