From 16522ac29023d94bc29e97761b01b252117cbbfe Mon Sep 17 00:00:00 2001 From: Chunwei Chen Date: Wed, 2 Dec 2015 14:52:46 -0800 Subject: 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 Signed-off-by: Brian Behlendorf Closes #500 Closes #504 Closes #505 --- module/spl/spl-tsd.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'module/spl/spl-tsd.c') 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 @@ -527,6 +527,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 -- cgit v1.2.3