scst: add thread_index sysfs attribute

This attribute exports per LUN thread index assigned by
scst_add_threads(). It 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.



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7076 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2016-12-20 06:27:38 +00:00
parent bdb23b8923
commit 283b30f603
6 changed files with 44 additions and 0 deletions
+8
View File
@@ -855,6 +855,14 @@ Each sessions/<sess>/lun<X> subdirectory contains the following entries:
(PIDs) of the kernel threads that process SCSI commands intended for
lun<X> in session <sess>.
- 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)
------------------------------------------------------
+8
View File
@@ -719,6 +719,14 @@ Each sessions/<sess>/lun<X> subdirectory contains the following entries:
(PIDs) of the kernel threads that process SCSI commands intended for
lun<X> in session <sess>.
- 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)
------------------------------------------------------
+11
View File
@@ -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));
+2
View File
@@ -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;
+1
View File
@@ -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)
+14
View File
@@ -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