Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Mar 2017 12:20:23 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r314553 - in head/sys: kern sys
Message-ID:  <201703021220.v22CKNCS072749@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703021220.v22CKNCS072749>