diff --git a/scst/README b/scst/README index fd1050744..dcc60a67e 100644 --- a/scst/README +++ b/scst/README @@ -855,6 +855,14 @@ Each sessions//lun subdirectory contains the following entries: (PIDs) of the kernel threads that process SCSI commands intended for lun in session . + - thread_index - thread index assigned by scst_add_threads(). + Can be used to look up which export thread is serving which target + since this index also appears in the export thread name. This + information then could be used to set CPU affinity for those threads + to improve performance. Has a value in the range 0..n-1 for + threads_pool_type per_initiator or -1 when using a shared thread pool + per LUN or the global thread pool. + Access and devices visibility management (LUN masking) ------------------------------------------------------ diff --git a/scst/README_in-tree b/scst/README_in-tree index 3b0f215eb..0b0731710 100644 --- a/scst/README_in-tree +++ b/scst/README_in-tree @@ -719,6 +719,14 @@ Each sessions//lun subdirectory contains the following entries: (PIDs) of the kernel threads that process SCSI commands intended for lun in session . + - thread_index - thread index assigned by scst_add_threads(). + Can be used to look up which export thread is serving which target + since this index also appears in the export thread name. This + information then could be used to set CPU affinity for those threads + to improve performance. Has a value in the range 0..n-1 for + threads_pool_type per_initiator or -1 when using a shared thread pool + per LUN or the global thread pool. + Access and devices visibility management (LUN masking) ------------------------------------------------------ diff --git a/scst/include/scst.h b/scst/include/scst.h index 28c99e4e4..4229decef 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -3247,6 +3247,16 @@ struct scst_tgt_dev { unsigned short tgt_dev_valid_sense_len; uint8_t tgt_dev_sense[SCST_SENSE_BUFFERSIZE]; + /* + * LUN thread index assigned by scst_add_threads(). Exported via + * sysfs. Can be used to look up which export thread is serving which + * target since this index also appears in the export thread name. Has + * a value in the range 0..n-1 for threads_pool_type per_initiator or + * -1 when using a shared thread pool per LUN or the global thread + * pool. + */ + int thread_index; + #ifndef CONFIG_SCST_PROC /* sysfs release completion */ struct completion *tgt_dev_kobj_release_cmpl; @@ -5666,6 +5676,7 @@ void scst_init_threads(struct scst_cmd_threads *cmd_threads); void scst_deinit_threads(struct scst_cmd_threads *cmd_threads); void scst_pass_through_cmd_done(void *data, char *sense, int result, int resid); + #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30) int scst_scsi_exec_async(struct scst_cmd *cmd, void *data, void (*done)(void *data, char *sense, int result, int resid)); diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 766205740..9622e0744 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -5037,6 +5037,8 @@ int scst_tgt_dev_setup_threads(struct scst_tgt_dev *tgt_dev) TRACE_ENTRY(); + tgt_dev->thread_index = -1; + if (dev->threads_num < 0) goto out; diff --git a/scst/src/scst_main.c b/scst/src/scst_main.c index 71d89acb5..bfae359bf 100644 --- a/scst/src/scst_main.c +++ b/scst/src/scst_main.c @@ -1923,6 +1923,7 @@ int scst_add_threads(struct scst_cmd_threads *cmd_threads, break; tgt_dev_num++; } + tgt_dev->thread_index = tgt_dev_num; nodeid = tgt_dev->dev->dev_numa_node_id; } else if (dev != NULL) diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 964cbf7d1..ba5c42e7f 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -4115,6 +4115,19 @@ out: ** Tgt_dev implementation **/ +static ssize_t scst_tgt_dev_thread_index_show(struct kobject *kobj, + struct kobj_attribute *attr, + char *buffer) +{ + struct scst_tgt_dev *tgt_dev = + container_of(kobj, struct scst_tgt_dev, tgt_dev_kobj); + + return sprintf(buffer, "%d\n", tgt_dev->thread_index); +} + +static struct kobj_attribute tgt_dev_thread_idx_attr = + __ATTR(thread_index, S_IRUGO, scst_tgt_dev_thread_index_show, NULL); + #ifdef CONFIG_SCST_MEASURE_LATENCY static char *scst_io_size_names[] = { @@ -4321,6 +4334,7 @@ static struct kobj_attribute tgt_dev_dif_checks_failed_attr = scst_tgt_dev_dif_checks_failed_store); static struct attribute *scst_tgt_dev_attrs[] = { + &tgt_dev_thread_idx_attr.attr, &tgt_dev_thread_pid_attr.attr, &tgt_dev_active_commands_attr.attr, #ifdef CONFIG_SCST_MEASURE_LATENCY