kthread_worker: reorganize to prepare for flush_kthread_work() reimplementation
Make the following two non-functional changes. * Separate out insert_kthread_work() from queue_kthread_work(). * Relocate struct kthread_flush_work and kthread_flush_work_fn() definitions above flush_kthread_work(). v2: Added lockdep_assert_held() in insert_kthread_work() as suggested by Andy Walls. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: Andy Walls <awalls@md.metrocast.net>
This commit is contained in:
@@ -378,6 +378,19 @@ repeat:
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(kthread_worker_fn);
|
EXPORT_SYMBOL_GPL(kthread_worker_fn);
|
||||||
|
|
||||||
|
/* insert @work before @pos in @worker */
|
||||||
|
static void insert_kthread_work(struct kthread_worker *worker,
|
||||||
|
struct kthread_work *work,
|
||||||
|
struct list_head *pos)
|
||||||
|
{
|
||||||
|
lockdep_assert_held(&worker->lock);
|
||||||
|
|
||||||
|
list_add_tail(&work->node, pos);
|
||||||
|
work->queue_seq++;
|
||||||
|
if (likely(worker->task))
|
||||||
|
wake_up_process(worker->task);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* queue_kthread_work - queue a kthread_work
|
* queue_kthread_work - queue a kthread_work
|
||||||
* @worker: target kthread_worker
|
* @worker: target kthread_worker
|
||||||
@@ -395,10 +408,7 @@ bool queue_kthread_work(struct kthread_worker *worker,
|
|||||||
|
|
||||||
spin_lock_irqsave(&worker->lock, flags);
|
spin_lock_irqsave(&worker->lock, flags);
|
||||||
if (list_empty(&work->node)) {
|
if (list_empty(&work->node)) {
|
||||||
list_add_tail(&work->node, &worker->work_list);
|
insert_kthread_work(worker, work, &worker->work_list);
|
||||||
work->queue_seq++;
|
|
||||||
if (likely(worker->task))
|
|
||||||
wake_up_process(worker->task);
|
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&worker->lock, flags);
|
spin_unlock_irqrestore(&worker->lock, flags);
|
||||||
@@ -406,6 +416,18 @@ bool queue_kthread_work(struct kthread_worker *worker,
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(queue_kthread_work);
|
EXPORT_SYMBOL_GPL(queue_kthread_work);
|
||||||
|
|
||||||
|
struct kthread_flush_work {
|
||||||
|
struct kthread_work work;
|
||||||
|
struct completion done;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void kthread_flush_work_fn(struct kthread_work *work)
|
||||||
|
{
|
||||||
|
struct kthread_flush_work *fwork =
|
||||||
|
container_of(work, struct kthread_flush_work, work);
|
||||||
|
complete(&fwork->done);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flush_kthread_work - flush a kthread_work
|
* flush_kthread_work - flush a kthread_work
|
||||||
* @work: work to flush
|
* @work: work to flush
|
||||||
@@ -436,18 +458,6 @@ void flush_kthread_work(struct kthread_work *work)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(flush_kthread_work);
|
EXPORT_SYMBOL_GPL(flush_kthread_work);
|
||||||
|
|
||||||
struct kthread_flush_work {
|
|
||||||
struct kthread_work work;
|
|
||||||
struct completion done;
|
|
||||||
};
|
|
||||||
|
|
||||||
static void kthread_flush_work_fn(struct kthread_work *work)
|
|
||||||
{
|
|
||||||
struct kthread_flush_work *fwork =
|
|
||||||
container_of(work, struct kthread_flush_work, work);
|
|
||||||
complete(&fwork->done);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flush_kthread_worker - flush all current works on a kthread_worker
|
* flush_kthread_worker - flush all current works on a kthread_worker
|
||||||
* @worker: worker to flush
|
* @worker: worker to flush
|
||||||
|
Reference in New Issue
Block a user