svn commit: r314553 - in head/sys: kern sys

Hans Petter Selasky hselasky at FreeBSD.org
Thu Mar 2 12:20:24 UTC 2017


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,


More information about the svn-src-head mailing list