From: Ross S. W. W. <RW...@me...> - 2010-04-22 20:21:36
|
This patch prevents continuous wake_ups from being called after the first. It also spreads the processing more evenly between threads by performing an 'if' instead of a 'while' in the processing loop. Signed-off-by: Ross Walker Index: kernel/wthread.c =================================================================== --- kernel/wthread.c (revision 328) +++ kernel/wthread.c (working copy) @@ -32,7 +32,8 @@ atomic_inc(&cmnd->conn->nr_busy_cmnds); - wake_up(&info->wthread_sleep); + if (!test_and_set_bit(D_DATA_READY, &info->flags)) + wake_up(&info->wthread_sleep); } static struct iscsi_cmnd * get_ready_cmnd(struct worker_thread_info *info) @@ -78,10 +79,13 @@ add_wait_queue(&info->wthread_sleep, &wait); - __set_current_state(TASK_RUNNING); do { - while (!list_empty(&info->work_queue) && - (cmnd = get_ready_cmnd(info))) { + set_current_state(TASK_INTERRUPTIBLE); + if (!test_and_clear_bit(D_DATA_READY, &info->flags)) + schedule(); + __set_current_state(TASK_RUNNING); + + if ((cmnd = get_ready_cmnd(info))) { conn = cmnd->conn; if (cmnd_tmfabort(cmnd)) cmnd_release(cmnd, 1); @@ -90,12 +94,6 @@ assert(conn); atomic_dec(&conn->nr_busy_cmnds); } - - set_current_state(TASK_INTERRUPTIBLE); - if (list_empty(&info->work_queue)) - schedule(); - - __set_current_state(TASK_RUNNING); } while (!kthread_should_stop()); remove_wait_queue(&info->wthread_sleep, &wait); Index: kernel/iscsi.h =================================================================== --- kernel/iscsi.h (revision 328) +++ kernel/iscsi.h (working copy) @@ -85,6 +85,7 @@ }; struct worker_thread_info { + unsigned long flags; spinlock_t wthread_lock; u32 nr_running_wthreads; @@ -97,6 +98,11 @@ struct io_context *wthread_ioc; }; +enum daemon_state_bit { + D_ACTIVE, + D_DATA_READY, +}; + struct iscsi_cmnd; struct target_type { Index: kernel/nthread.c =================================================================== --- kernel/nthread.c (revision 328) +++ kernel/nthread.c (working copy) @@ -15,11 +15,6 @@ #include "iscsi_dbg.h" #include "digest.h" -enum daemon_state_bit { - D_ACTIVE, - D_DATA_READY, -}; - void __nthread_wakeup(struct network_thread_info *info) { set_bit(D_DATA_READY, &info->flags); ______________________________________________________________________ This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail, you are hereby notified that any dissemination, distribution or copying of this e-mail, and any attachments thereto, is strictly prohibited. If you have received this e-mail in error, please immediately notify the sender and permanently delete the original and any copy or printout thereof. |