mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-19 03:31:26 +00:00
scst: Speed up command thread creation
Avoid hitting a 50 ms delay during thread creation. Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6493 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -2271,6 +2271,7 @@ struct scst_cmd_threads {
|
||||
int io_context_refcnt;
|
||||
|
||||
bool io_context_ready;
|
||||
wait_queue_head_t ioctx_wq;
|
||||
|
||||
/* io_context_mutex protects io_context and io_context_refcnt. */
|
||||
struct mutex io_context_mutex;
|
||||
|
||||
@@ -4495,6 +4495,7 @@ struct scst_acg *scst_tgt_find_acg(struct scst_tgt *tgt, const char *name)
|
||||
static struct scst_tgt_dev *scst_find_shared_io_tgt_dev(
|
||||
struct scst_tgt_dev *tgt_dev)
|
||||
{
|
||||
struct scst_cmd_threads *a;
|
||||
struct scst_tgt_dev *res = NULL;
|
||||
struct scst_session *sess = tgt_dev->sess;
|
||||
struct scst_acg *acg = tgt_dev->acg_dev->acg;
|
||||
@@ -4566,21 +4567,16 @@ out:
|
||||
return res;
|
||||
|
||||
found:
|
||||
if (t->active_cmd_threads == &scst_main_cmd_threads) {
|
||||
res = t;
|
||||
res = t;
|
||||
a = t->active_cmd_threads;
|
||||
if (a == &scst_main_cmd_threads) {
|
||||
TRACE_DBG("Going to share async IO context %p (res %p, "
|
||||
"ini %s, dev %s, grouping type %d)",
|
||||
t->aic_keeper->aic, res, t->sess->initiator_name,
|
||||
t->dev->virt_name,
|
||||
t->acg_dev->acg->acg_io_grouping_type);
|
||||
} else {
|
||||
res = t;
|
||||
if (!*(volatile bool *)&res->active_cmd_threads->io_context_ready) {
|
||||
TRACE_DBG("IO context for t %p not yet "
|
||||
"initialized, waiting...", t);
|
||||
msleep(100);
|
||||
goto found;
|
||||
}
|
||||
wait_event(a->ioctx_wq, a->io_context_ready);
|
||||
smp_rmb();
|
||||
TRACE_DBG("Going to share IO context %p (res %p, ini %s, "
|
||||
"dev %s, cmd_threads %p, grouping type %d)",
|
||||
|
||||
@@ -1929,11 +1929,8 @@ out_wait:
|
||||
* Wait for io_context gets initialized to avoid possible races
|
||||
* for it from the sharing it tgt_devs.
|
||||
*/
|
||||
while (!*(volatile bool *)&cmd_threads->io_context_ready) {
|
||||
TRACE_DBG("Waiting for io_context for cmd_threads %p "
|
||||
"initialized", cmd_threads);
|
||||
msleep(50);
|
||||
}
|
||||
wait_event(cmd_threads->ioctx_wq,
|
||||
cmd_threads->io_context_ready);
|
||||
smp_rmb();
|
||||
}
|
||||
|
||||
@@ -2182,6 +2179,7 @@ void scst_init_threads(struct scst_cmd_threads *cmd_threads)
|
||||
spin_lock_init(&cmd_threads->cmd_list_lock);
|
||||
INIT_LIST_HEAD(&cmd_threads->active_cmd_list);
|
||||
init_waitqueue_head(&cmd_threads->cmd_list_waitQ);
|
||||
init_waitqueue_head(&cmd_threads->ioctx_wq);
|
||||
INIT_LIST_HEAD(&cmd_threads->threads_list);
|
||||
mutex_init(&cmd_threads->io_context_mutex);
|
||||
spin_lock_init(&cmd_threads->thr_lock);
|
||||
|
||||
@@ -5010,6 +5010,8 @@ int scst_cmd_thread(void *arg)
|
||||
|
||||
scst_ioctx_get(p_cmd_threads);
|
||||
|
||||
wake_up_all(&p_cmd_threads->ioctx_wq);
|
||||
|
||||
spin_lock_irq(&p_cmd_threads->cmd_list_lock);
|
||||
while (!kthread_should_stop()) {
|
||||
wait_event_locked(p_cmd_threads->cmd_list_waitQ,
|
||||
|
||||
Reference in New Issue
Block a user