From 5a4571354b37d13562c9ef80451dca11a97e151d Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Sat, 19 Jul 2014 04:11:39 +0000 Subject: [PATCH] scst: Introduce scst_set_thr_cpu_mask() This patch does not change any functionality. Signed-off-by: Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@5685 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/include/scst.h | 3 +++ scst/src/scst_main.c | 20 ++++++++++++++++++++ scst/src/scst_sysfs.c | 16 ++++++---------- 3 files changed, 29 insertions(+), 10 deletions(-) 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) {