svn commit: r208715 - in head/sys: kern sys
Zachary Loafman
zml at FreeBSD.org
Tue Jun 1 16:04:02 UTC 2010
Author: zml
Date: Tue Jun 1 16:04:01 2010
New Revision: 208715
URL: http://svn.freebsd.org/changeset/base/208715
Log:
Revert taskqueue(9) related commits until mdf@ is approved and can
resolve issues.
This reverts commits r207439, r208623, r208624
Modified:
head/sys/kern/subr_taskqueue.c
head/sys/sys/_task.h
Modified: head/sys/kern/subr_taskqueue.c
==============================================================================
--- head/sys/kern/subr_taskqueue.c Tue Jun 1 15:51:31 2010 (r208714)
+++ head/sys/kern/subr_taskqueue.c Tue Jun 1 16:04:01 2010 (r208715)
@@ -51,13 +51,12 @@ struct taskqueue {
const char *tq_name;
taskqueue_enqueue_fn tq_enqueue;
void *tq_context;
+ struct task *tq_running;
struct mtx tq_mutex;
struct thread **tq_threads;
int tq_tcount;
int tq_spin;
int tq_flags;
- int tq_tasks_running;
- int tq_task_waiters;
};
#define TQ_FLAGS_ACTIVE (1 << 0)
@@ -234,15 +233,14 @@ taskqueue_run(struct taskqueue *queue)
STAILQ_REMOVE_HEAD(&queue->tq_queue, ta_link);
pending = task->ta_pending;
task->ta_pending = 0;
- queue->tq_tasks_running++;
+ queue->tq_running = task;
TQ_UNLOCK(queue);
task->ta_func(task->ta_context, pending);
TQ_LOCK(queue);
- queue->tq_tasks_running--;
- if (queue->tq_task_waiters > 0)
- wakeup(task);
+ queue->tq_running = NULL;
+ wakeup(task);
}
/*
@@ -258,21 +256,15 @@ taskqueue_drain(struct taskqueue *queue,
{
if (queue->tq_spin) { /* XXX */
mtx_lock_spin(&queue->tq_mutex);
- while (task->ta_pending != 0 || queue->tq_tasks_running > 0) {
- queue->tq_task_waiters++;
+ while (task->ta_pending != 0 || task == queue->tq_running)
msleep_spin(task, &queue->tq_mutex, "-", 0);
- queue->tq_task_waiters--;
- }
mtx_unlock_spin(&queue->tq_mutex);
} else {
WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, __func__);
mtx_lock(&queue->tq_mutex);
- while (task->ta_pending != 0 || queue->tq_tasks_running > 0) {
- queue->tq_task_waiters++;
+ while (task->ta_pending != 0 || task == queue->tq_running)
msleep(task, &queue->tq_mutex, PWAIT, "-", 0);
- queue->tq_task_waiters--;
- }
mtx_unlock(&queue->tq_mutex);
}
}
Modified: head/sys/sys/_task.h
==============================================================================
--- head/sys/sys/_task.h Tue Jun 1 15:51:31 2010 (r208714)
+++ head/sys/sys/_task.h Tue Jun 1 16:04:01 2010 (r208715)
@@ -36,19 +36,15 @@
* taskqueue_run(). The first argument is taken from the 'ta_context'
* field of struct task and the second argument is a count of how many
* times the task was enqueued before the call to taskqueue_run().
- *
- * List of locks
- * (c) const after init
- * (q) taskqueue lock
*/
typedef void task_fn_t(void *context, int pending);
struct task {
- STAILQ_ENTRY(task) ta_link; /* (q) link for queue */
- u_short 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 */
+ STAILQ_ENTRY(task) ta_link; /* link for queue */
+ u_short ta_pending; /* count times queued */
+ u_short ta_priority; /* Priority */
+ task_fn_t *ta_func; /* task handler */
+ void *ta_context; /* argument for handler */
};
#endif /* !_SYS__TASK_H_ */
More information about the svn-src-head
mailing list