aboutsummaryrefslogtreecommitdiffstats
path: root/module/spl/spl-tsd.c
diff options
context:
space:
mode:
authorChunwei Chen <[email protected]>2015-12-02 14:52:46 -0800
committerBrian Behlendorf <[email protected]>2016-01-20 13:07:45 -0800
commit16522ac29023d94bc29e97761b01b252117cbbfe (patch)
treec05042fbea285fe0c73640afd915b3a3d69c8476 /module/spl/spl-tsd.c
parentde77e245902cc5bb6c22591d54e31c7647ff912f (diff)
Use tsd to store tq for taskq_member
To prevent taskq_member holding tq_lock and doing linear search, thus causing contention. We store the taskq pointer to which the thread belongs in tsd. This way taskq_member will not need to touch tq_lock, and tsd has per slot spinlock. So the contention should be reduced greatly. Signed-off-by: Chunwei Chen <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #500 Closes #504 Closes #505
Diffstat (limited to 'module/spl/spl-tsd.c')
-rw-r--r--module/spl/spl-tsd.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/module/spl/spl-tsd.c b/module/spl/spl-tsd.c
index 4d0800e5a..bf8235063 100644
--- a/module/spl/spl-tsd.c
+++ b/module/spl/spl-tsd.c
@@ -528,6 +528,33 @@ tsd_get(uint_t key)
EXPORT_SYMBOL(tsd_get);
/*
+ * tsd_get_by_thread - get thread specific data for specified thread
+ * @key: lookup key
+ * @thread: thread to lookup
+ *
+ * Caller must prevent racing tsd_create() or tsd_destroy(). This
+ * implementation is designed to be fast and scalable, it does not
+ * lock the entire table only a single hash bin.
+ */
+void *
+tsd_get_by_thread(uint_t key, kthread_t *thread)
+{
+ tsd_hash_entry_t *entry;
+
+ ASSERT3P(tsd_hash_table, !=, NULL);
+
+ if ((key == 0) || (key > TSD_KEYS_MAX))
+ return (NULL);
+
+ entry = tsd_hash_search(tsd_hash_table, key, thread->pid);
+ if (entry == NULL)
+ return (NULL);
+
+ return (entry->he_value);
+}
+EXPORT_SYMBOL(tsd_get_by_thread);
+
+/*
* tsd_create - create thread specific data key
* @keyp: lookup key address
* @dtor: destructor called during tsd_destroy() or tsd_exit()