diff --git a/scst/include/scst.h b/scst/include/scst.h index 0ab09b9eb..505a724f9 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -1914,6 +1914,9 @@ struct scst_cmd_threads { struct list_head lists_list_entry; }; +int scst_set_thr_cpu_mask(struct scst_cmd_threads *cmd_threads, + cpumask_t *cpu_mask); + /* * Used to execute cmd's in order of arrival, honoring SCSI task attributes */ diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 209e9ce54..678bb9aef 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -1992,6 +1992,26 @@ out: return; } +/* scst_mutex supposed to be held */ +int scst_set_thr_cpu_mask(struct scst_cmd_threads *cmd_threads, + cpumask_t *cpu_mask) +{ + struct scst_cmd_thread_t *thr; + int rc = 0; + + lockdep_assert_held(&scst_mutex); + + list_for_each_entry(thr, &cmd_threads->threads_list, + thread_list_entry) { + rc = set_cpus_allowed_ptr(thr->cmd_thread, cpu_mask); + if (rc) + break; + } + + return rc; +} +EXPORT_SYMBOL(scst_set_thr_cpu_mask); + /* The activity supposed to be suspended and scst_mutex held */ void scst_stop_dev_threads(struct scst_device *dev) { diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 88e714933..1e6a84e04 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -1916,18 +1916,14 @@ static int __scst_acg_process_cpu_mask_store(struct scst_tgt *tgt, struct list_head *head = &sess->sess_tgt_dev_list[i]; list_for_each_entry(tgt_dev, head, sess_tgt_dev_list_entry) { - struct scst_cmd_thread_t *thr; + int rc; + if (tgt_dev->active_cmd_threads != &tgt_dev->tgt_dev_cmd_threads) continue; - list_for_each_entry(thr, - &tgt_dev->active_cmd_threads->threads_list, - thread_list_entry) { - int rc; - rc = set_cpus_allowed_ptr(thr->cmd_thread, cpu_mask); - if (rc != 0) - PRINT_ERROR("Setting CPU " - "affinity failed: %d", rc); - } + rc = scst_set_thr_cpu_mask(tgt_dev->active_cmd_threads, cpu_mask); + if (rc != 0) + PRINT_ERROR("Setting CPU affinity" + " failed: %d", rc); } } if (tgt->tgtt->report_aen != NULL) {