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: d8894cbd11 ("scst.h: Refactor wait_event_locked() to enhance usability and clarity")
This commit is contained in:
Gleb Chesnokov
2023-06-27 16:10:12 +03:00
parent 1d6ab4aa72
commit bdf867ffd1
5 changed files with 43 additions and 53 deletions

View File

@@ -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);

View File

@@ -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_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_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) \
({ \
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);

View File

@@ -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

View File

@@ -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);

View File

@@ -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,