|
From: Gleb C. <lna...@ya...> - 2023-06-27 14:11:39
|
Commit: bdf867f GitHub URL: https://github.com/SCST-project/scst/commit/bdf867ffd18a8781ccf344f1ef39ebb29c412897 Author: Gleb Chesnokov Date: 2023-06-27T17:11:13+03:00 Log Message: ----------- scst: Use scst_wait_event_...() with INTERRUPTIBLE sleep This patch changes the processing threads to use INTERRUPTIBLE sleep states in the scst_wait_event_...() functions. This aims to avoid warnings from the hung task detection checker and to prevent unnecessary load counting. Fixes: d8894cbd1157 ("scst.h: Refactor wait_event_locked() to enhance usability and clarity") Modified Paths: -------------- iscsi-scst/kernel/nthread.c | 4 +- scst/include/scst.h | 64 ++++++--------- scst/src/dev_handlers/scst_user.c | 10 +-- scst/src/scst_sysfs.c | 4 +- scst/src/scst_targ.c | 16 ++-- 5 files changed, 44 insertions(+), 54 deletions(-) =================================================================== diff --git a/iscsi-scst/kernel/nthread.c b/iscsi-scst/kernel/nthread.c index fb4e93a..593d7ee 100644 --- a/iscsi-scst/kernel/nthread.c +++ b/iscsi-scst/kernel/nthread.c @@ -960,7 +960,7 @@ int istrd(void *arg) spin_lock_bh(&p->rd_lock); while (!kthread_should_stop()) { - scst_wait_event_lock_bh(p->rd_waitQ, test_rd_list(p), p->rd_lock); + scst_wait_event_interruptible_lock_bh(p->rd_waitQ, test_rd_list(p), p->rd_lock); scst_do_job_rd(p); } spin_unlock_bh(&p->rd_lock); @@ -1612,7 +1612,7 @@ int istwr(void *arg) spin_lock_bh(&p->wr_lock); while (!kthread_should_stop()) { - scst_wait_event_lock_bh(p->wr_waitQ, test_wr_list(p), p->wr_lock); + scst_wait_event_interruptible_lock_bh(p->wr_waitQ, test_wr_list(p), p->wr_lock); scst_do_job_wr(p); } spin_unlock_bh(&p->wr_lock); diff --git a/scst/include/scst.h b/scst/include/scst.h index 91258d1..781aabb 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -5485,31 +5485,20 @@ prepare_to_wait_exclusive_head(struct wait_queue_head *wq_head, __out: __ret; \ }) -#define __scst_wait_event_lock(wq_head, condition, lock) \ - (void)___scst_wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, \ - spin_unlock(&lock); \ - schedule(); \ - spin_lock(&lock)) - -#define scst_wait_event_lock(wq_head, condition, lock) \ -do { \ - if (condition) \ - break; \ - __scst_wait_event_lock(wq_head, condition, lock); \ -} while (0) - -#define __scst_wait_event_lock_bh(wq_head, condition, lock) \ - (void)___scst_wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, \ - spin_unlock_bh(&lock); \ - schedule(); \ - spin_lock_bh(&lock)) - -#define scst_wait_event_lock_bh(wq_head, condition, lock) \ -do { \ - if (condition) \ - break; \ - __scst_wait_event_lock_bh(wq_head, condition, lock); \ -} while (0) +#define __scst_wait_event_interruptible_lock(wq_head, condition, lock) \ + ___scst_wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, \ + spin_unlock(&lock); \ + schedule(); \ + spin_lock(&lock)) + +#define scst_wait_event_interruptible_lock(wq_head, condition, lock) \ +({ \ + int __ret = 0; \ + if (!(condition)) \ + __ret = __scst_wait_event_interruptible_lock(wq_head, \ + condition, lock); \ + __ret; \ +}) #define __scst_wait_event_interruptible_lock_bh(wq_head, condition, lock) \ ___scst_wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, \ @@ -5526,19 +5515,20 @@ do { \ __ret; \ }) +#define __scst_wait_event_interruptible_lock_irq(wq_head, condition, lock) \ + ___scst_wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, \ + spin_unlock_irq(&lock); \ + schedule(); \ + spin_lock_irq(&lock)) -#define __scst_wait_event_lock_irq(wq_head, condition, lock) \ - (void)___scst_wait_event(wq_head, condition, TASK_UNINTERRUPTIBLE, 0, \ - spin_unlock_irq(&lock); \ - schedule(); \ - spin_lock_irq(&lock)) - -#define scst_wait_event_lock_irq(wq_head, condition, lock) \ -do { \ - if (condition) \ - break; \ - __scst_wait_event_lock_irq(wq_head, condition, lock); \ -} while (0) +#define scst_wait_event_interruptible_lock_irq(wq_head, condition, lock) \ +({ \ + int __ret = 0; \ + if (!(condition)) \ + __ret = __scst_wait_event_interruptible_lock_irq(wq_head, \ + condition, lock);\ + __ret; \ +}) #if defined(CONFIG_SCST_DEBUG) || defined(CONFIG_SCST_TRACING) const char *scst_get_opcode_name(struct scst_cmd *cmd); diff --git a/scst/src/dev_handlers/scst_user.c b/scst/src/dev_handlers/scst_user.c index e41b3ba..fcf2d90 100644 --- a/scst/src/dev_handlers/scst_user.c +++ b/scst/src/dev_handlers/scst_user.c @@ -2233,9 +2233,9 @@ static int dev_user_get_next_cmd(struct scst_user_dev *dev, TRACE_ENTRY(); while (1) { - scst_wait_event_lock_irq(dev->udev_cmd_threads.cmd_list_waitQ, - test_cmd_threads(dev, can_block), - dev->udev_cmd_threads.cmd_list_lock); + scst_wait_event_interruptible_lock_irq(dev->udev_cmd_threads.cmd_list_waitQ, + test_cmd_threads(dev, can_block), + dev->udev_cmd_threads.cmd_list_lock); dev_user_process_scst_commands(dev); @@ -4053,8 +4053,8 @@ static int dev_user_cleanup_thread(void *arg) spin_lock(&cleanup_lock); while (!kthread_should_stop()) { - scst_wait_event_lock(cleanup_list_waitQ, test_cleanup_list(), - cleanup_lock); + scst_wait_event_interruptible_lock(cleanup_list_waitQ, test_cleanup_list(), + cleanup_lock); /* * We have to poll devices, because commands can go from SCST diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 1ed7227..f21362d 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -470,8 +470,8 @@ static int sysfs_work_thread_fn(void *arg) while (!kthread_should_stop()) { if (one_time_only && !test_sysfs_work_list()) break; - scst_wait_event_lock(sysfs_work_waitQ, test_sysfs_work_list(), - sysfs_work_lock); + scst_wait_event_interruptible_lock(sysfs_work_waitQ, test_sysfs_work_list(), + sysfs_work_lock); scst_process_sysfs_works(); } spin_unlock(&sysfs_work_lock); diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 2593cc0..70e212e 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -4510,9 +4510,9 @@ int scst_init_thread(void *arg) spin_lock_irq(&scst_init_lock); while (!kthread_should_stop()) { - scst_wait_event_lock_irq(scst_init_cmd_list_waitQ, - test_init_cmd_list(), - scst_init_lock); + scst_wait_event_interruptible_lock_irq(scst_init_cmd_list_waitQ, + test_init_cmd_list(), + scst_init_lock); scst_do_job_init(); } spin_unlock_irq(&scst_init_lock); @@ -6794,9 +6794,9 @@ int scst_tm_thread(void *arg) spin_lock_irq(&scst_mcmd_lock); while (!kthread_should_stop()) { - scst_wait_event_lock_irq(scst_mgmt_cmd_list_waitQ, - test_mgmt_cmd_list(), - scst_mcmd_lock); + scst_wait_event_interruptible_lock_irq(scst_mgmt_cmd_list_waitQ, + test_mgmt_cmd_list(), + scst_mcmd_lock); while (!list_empty(&scst_active_mgmt_cmd_list)) { int rc; @@ -7610,8 +7610,8 @@ int scst_global_mgmt_thread(void *arg) spin_lock_irq(&scst_mgmt_lock); while (!kthread_should_stop()) { - scst_wait_event_lock_irq(scst_mgmt_waitQ, test_mgmt_list(), - scst_mgmt_lock); + scst_wait_event_interruptible_lock_irq(scst_mgmt_waitQ, test_mgmt_list(), + scst_mgmt_lock); while (!list_empty(&scst_sess_init_list)) { sess = list_first_entry(&scst_sess_init_list, |