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

Andriy Gapon avg at FreeBSD.org
Sat May 21 14:51:51 UTC 2016


Author: avg
Date: Sat May 21 14:51:49 2016
New Revision: 300372
URL: https://svnweb.freebsd.org/changeset/base/300372

Log:
  fix loss of taskqueue wakeups (introduced in r300113)
  
  Submitted by:	kmacy
  Tested by:	dchagin

Modified:
  head/sys/kern/subr_taskqueue.c
  head/sys/sys/_task.h
  head/sys/sys/taskqueue.h

Modified: head/sys/kern/subr_taskqueue.c
==============================================================================
--- head/sys/kern/subr_taskqueue.c	Sat May 21 11:40:41 2016	(r300371)
+++ head/sys/kern/subr_taskqueue.c	Sat May 21 14:51:49 2016	(r300372)
@@ -68,7 +68,6 @@ struct taskqueue {
 	TAILQ_HEAD(, taskqueue_busy) tq_active;
 	struct mtx		tq_mutex;
 	struct thread		**tq_threads;
-	struct thread		*tq_curthread;
 	int			tq_tcount;
 	int			tq_spin;
 	int			tq_flags;
@@ -222,7 +221,7 @@ taskqueue_enqueue_locked(struct taskqueu
 	 * Count multiple enqueues.
 	 */
 	if (task->ta_pending) {
-		if (task->ta_pending < UCHAR_MAX)
+		if (task->ta_pending < USHRT_MAX)
 			task->ta_pending++;
 		TQ_UNLOCK(queue);
 		return (0);
@@ -465,8 +464,7 @@ taskqueue_run_locked(struct taskqueue *q
 
 		TQ_LOCK(queue);
 		tb.tb_running = NULL;
-		if ((task->ta_flags & TASK_SKIP_WAKEUP) == 0)
-			wakeup(task);
+		wakeup(task);
 
 		TAILQ_REMOVE(&queue->tq_active, &tb, tb_link);
 		tb_first = TAILQ_FIRST(&queue->tq_active);
@@ -481,9 +479,7 @@ taskqueue_run(struct taskqueue *queue)
 {
 
 	TQ_LOCK(queue);
-	queue->tq_curthread = curthread;
 	taskqueue_run_locked(queue);
-	queue->tq_curthread = NULL;
 	TQ_UNLOCK(queue);
 }
 
@@ -716,7 +712,6 @@ taskqueue_thread_loop(void *arg)
 	tq = *tqp;
 	taskqueue_run_callback(tq, TASKQUEUE_CALLBACK_TYPE_INIT);
 	TQ_LOCK(tq);
-	tq->tq_curthread = curthread;
 	while ((tq->tq_flags & TQ_FLAGS_ACTIVE) != 0) {
 		/* XXX ? */
 		taskqueue_run_locked(tq);
@@ -730,7 +725,6 @@ taskqueue_thread_loop(void *arg)
 		TQ_SLEEP(tq, tq, &tq->tq_mutex, 0, "-", 0);
 	}
 	taskqueue_run_locked(tq);
-	tq->tq_curthread = NULL;
 	/*
 	 * This thread is on its way out, so just drop the lock temporarily
 	 * in order to call the shutdown callback.  This allows the callback
@@ -754,8 +748,7 @@ taskqueue_thread_enqueue(void *context)
 
 	tqp = context;
 	tq = *tqp;
-	if (tq->tq_curthread != curthread)
-		wakeup_one(tq);
+	wakeup_one(tq);
 }
 
 TASKQUEUE_DEFINE(swi, taskqueue_swi_enqueue, NULL,

Modified: head/sys/sys/_task.h
==============================================================================
--- head/sys/sys/_task.h	Sat May 21 11:40:41 2016	(r300371)
+++ head/sys/sys/_task.h	Sat May 21 14:51:49 2016	(r300372)
@@ -45,8 +45,7 @@ typedef void task_fn_t(void *context, in
 
 struct task {
 	STAILQ_ENTRY(task) ta_link;	/* (q) link for queue */
-	uint8_t	ta_pending;		/* (q) count times queued */
-	uint8_t	ta_flags;		/* (q) flags */
+	uint16_t ta_pending;		/* (q) count times queued */
 	u_short	ta_priority;		/* (c) Priority */
 	task_fn_t *ta_func;		/* (c) task handler */
 	void	*ta_context;		/* (c) argument for handler */

Modified: head/sys/sys/taskqueue.h
==============================================================================
--- head/sys/sys/taskqueue.h	Sat May 21 11:40:41 2016	(r300371)
+++ head/sys/sys/taskqueue.h	Sat May 21 14:51:49 2016	(r300372)
@@ -98,7 +98,6 @@ void	taskqueue_set_callback(struct taskq
 
 #define TASK_INITIALIZER(priority, func, context)	\
 	{ .ta_pending = 0,				\
-	  .ta_flags = 0,				\
 	  .ta_priority = (priority),			\
 	  .ta_func = (func),				\
 	  .ta_context = (context) }
@@ -114,7 +113,6 @@ void	taskqueue_thread_enqueue(void *cont
  */
 #define TASK_INIT(task, priority, func, context) do {	\
 	(task)->ta_pending = 0;				\
-	(task)->ta_flags = 0;				\
 	(task)->ta_priority = (priority);		\
 	(task)->ta_func = (func);			\
 	(task)->ta_context = (context);			\
@@ -224,7 +222,6 @@ int	taskqgroup_adjust(struct taskqgroup 
 
 #define GTASK_INIT(task, priority, func, context) do {	\
 	(task)->ta_pending = 0;				\
-	(task)->ta_flags = TASK_SKIP_WAKEUP;		\
 	(task)->ta_priority = (priority);		\
 	(task)->ta_func = (func);			\
 	(task)->ta_context = (context);			\


More information about the svn-src-head mailing list