Lines Matching full:table

26  *  Thread specific data has implemented using a hash table, this avoids
31 * The majority of the entries in the hash table are for specific tsd
38 * By default the hash table is sized to 512 bins which is expected to
41 * The hash table contains two additional type of entries. They first
93 * tsd_hash_search - searches hash table for tsd_hash_entry
94 * @table: hash table
99 tsd_hash_search(tsd_hash_table_t *table, uint_t key, pid_t pid) in tsd_hash_search() argument
106 hash = hash_long((ulong_t)key * (ulong_t)pid, table->ht_bits); in tsd_hash_search()
107 bin = &table->ht_bins[hash]; in tsd_hash_search()
145 * tsd_hash_add - adds an entry to hash table
146 * @table: hash table
151 * already exist in the hash table. This possible because all entries
154 * links to the dtor and pid entries the entire table is locked.
157 tsd_hash_add(tsd_hash_table_t *table, uint_t key, pid_t pid, void *value) in tsd_hash_add() argument
164 ASSERT3P(tsd_hash_search(table, key, pid), ==, NULL); in tsd_hash_add()
178 spin_lock(&table->ht_lock); in tsd_hash_add()
181 dtor_entry = tsd_hash_search(table, entry->he_key, DTOR_PID); in tsd_hash_add()
186 pid_entry = tsd_hash_search(table, PID_KEY, entry->he_pid); in tsd_hash_add()
189 hash = hash_long((ulong_t)key * (ulong_t)pid, table->ht_bits); in tsd_hash_add()
190 bin = &table->ht_bins[hash]; in tsd_hash_add()
199 spin_unlock(&table->ht_lock); in tsd_hash_add()
205 * tsd_hash_add_key - adds a destructor entry to the hash table
206 * @table: hash table
213 * will be set to the next available key for the hash table.
216 tsd_hash_add_key(tsd_hash_table_t *table, uint_t *keyp, dtor_func_t dtor) in tsd_hash_add_key() argument
223 ASSERT3P(table, !=, NULL); in tsd_hash_add_key()
231 spin_lock(&table->ht_lock); in tsd_hash_add_key()
234 if (table->ht_key++ > TSD_KEYS_MAX) in tsd_hash_add_key()
235 table->ht_key = 1; in tsd_hash_add_key()
239 spin_unlock(&table->ht_lock); in tsd_hash_add_key()
243 tmp_entry = tsd_hash_search(table, table->ht_key, DTOR_PID); in tsd_hash_add_key()
246 /* Add destructor entry in to hash table */ in tsd_hash_add_key()
247 entry->he_key = *keyp = table->ht_key; in tsd_hash_add_key()
255 hash = hash_long((ulong_t)*keyp * (ulong_t)DTOR_PID, table->ht_bits); in tsd_hash_add_key()
256 bin = &table->ht_bins[hash]; in tsd_hash_add_key()
262 spin_unlock(&table->ht_lock); in tsd_hash_add_key()
268 * tsd_hash_add_pid - adds a process entry to the hash table
269 * @table: hash table
277 tsd_hash_add_pid(tsd_hash_table_t *table, pid_t pid) in tsd_hash_add_pid() argument
288 spin_lock(&table->ht_lock); in tsd_hash_add_pid()
297 hash = hash_long((ulong_t)PID_KEY * (ulong_t)pid, table->ht_bits); in tsd_hash_add_pid()
298 bin = &table->ht_bins[hash]; in tsd_hash_add_pid()
304 spin_unlock(&table->ht_lock); in tsd_hash_add_pid()
310 * tsd_hash_del - delete an entry from hash table, key, and pid lists
311 * @table: hash table
316 tsd_hash_del(tsd_hash_table_t *table, tsd_hash_entry_t *entry) in tsd_hash_del() argument
324 * tsd_hash_table_init - allocate a hash table
325 * @bits: hash table size
327 * A hash table with 2^bits bins will be created, it may not be resized
333 tsd_hash_table_t *table; in tsd_hash_table_init() local
336 table = kmem_zalloc(sizeof (tsd_hash_table_t), KM_SLEEP); in tsd_hash_table_init()
337 if (table == NULL) in tsd_hash_table_init()
340 table->ht_bins = kmem_zalloc(sizeof (tsd_hash_bin_t) * size, KM_SLEEP); in tsd_hash_table_init()
341 if (table->ht_bins == NULL) { in tsd_hash_table_init()
342 kmem_free(table, sizeof (tsd_hash_table_t)); in tsd_hash_table_init()
347 spin_lock_init(&table->ht_bins[hash].hb_lock); in tsd_hash_table_init()
348 INIT_HLIST_HEAD(&table->ht_bins[hash].hb_head); in tsd_hash_table_init()
351 spin_lock_init(&table->ht_lock); in tsd_hash_table_init()
352 table->ht_bits = bits; in tsd_hash_table_init()
353 table->ht_key = 1; in tsd_hash_table_init()
355 return (table); in tsd_hash_table_init()
359 * tsd_hash_table_fini - free a hash table
360 * @table: hash table
362 * Free a hash table allocated by tsd_hash_table_init(). If the hash
363 * table is not empty this function will call the proper destructor for
367 tsd_hash_table_fini(tsd_hash_table_t *table) in tsd_hash_table_fini() argument
374 ASSERT3P(table, !=, NULL); in tsd_hash_table_fini()
375 spin_lock(&table->ht_lock); in tsd_hash_table_fini()
376 for (i = 0, size = (1 << table->ht_bits); i < size; i++) { in tsd_hash_table_fini()
377 bin = &table->ht_bins[i]; in tsd_hash_table_fini()
382 tsd_hash_del(table, entry); in tsd_hash_table_fini()
387 spin_unlock(&table->ht_lock); in tsd_hash_table_fini()
390 kmem_free(table->ht_bins, sizeof (tsd_hash_bin_t)*(1<<table->ht_bits)); in tsd_hash_table_fini()
391 kmem_free(table, sizeof (tsd_hash_table_t)); in tsd_hash_table_fini()
405 tsd_hash_table_t *table; in tsd_remove_entry() local
410 table = tsd_hash_table; in tsd_remove_entry()
411 ASSERT3P(table, !=, NULL); in tsd_remove_entry()
414 spin_lock(&table->ht_lock); in tsd_remove_entry()
417 (ulong_t)entry->he_pid, table->ht_bits); in tsd_remove_entry()
418 entry_bin = &table->ht_bins[hash]; in tsd_remove_entry()
426 tsd_hash_del(table, entry); in tsd_remove_entry()
434 (ulong_t)pid_entry->he_pid, table->ht_bits); in tsd_remove_entry()
435 pid_entry_bin = &table->ht_bins[hash]; in tsd_remove_entry()
438 tsd_hash_del(table, pid_entry); in tsd_remove_entry()
443 spin_unlock(&table->ht_lock); in tsd_remove_entry()
462 tsd_hash_table_t *table; in tsd_set() local
469 table = tsd_hash_table; in tsd_set()
471 ASSERT3P(table, !=, NULL); in tsd_set()
476 /* Entry already exists in hash table update value */ in tsd_set()
477 entry = tsd_hash_search(table, key, pid); in tsd_set()
491 entry = tsd_hash_search(table, PID_KEY, pid); in tsd_set()
493 rc = tsd_hash_add_pid(table, pid); in tsd_set()
498 rc = tsd_hash_add(table, key, pid, value); in tsd_set()
509 * lock the entire table only a single hash bin.
536 * lock the entire table only a single hash bin.
592 tsd_hash_table_t *table; in tsd_destroy() local
597 table = tsd_hash_table; in tsd_destroy()
598 ASSERT3P(table, !=, NULL); in tsd_destroy()
600 spin_lock(&table->ht_lock); in tsd_destroy()
601 dtor_entry = tsd_hash_search(table, *keyp, DTOR_PID); in tsd_destroy()
603 spin_unlock(&table->ht_lock); in tsd_destroy()
609 * DTOR_PID entry. They are removed from the hash table and in tsd_destroy()
619 (ulong_t)entry->he_pid, table->ht_bits); in tsd_destroy()
620 entry_bin = &table->ht_bins[hash]; in tsd_destroy()
623 tsd_hash_del(table, entry); in tsd_destroy()
629 (ulong_t)dtor_entry->he_pid, table->ht_bits); in tsd_destroy()
630 dtor_entry_bin = &table->ht_bins[hash]; in tsd_destroy()
633 tsd_hash_del(table, dtor_entry); in tsd_destroy()
636 spin_unlock(&table->ht_lock); in tsd_destroy()
655 tsd_hash_table_t *table; in tsd_exit() local
660 table = tsd_hash_table; in tsd_exit()
661 ASSERT3P(table, !=, NULL); in tsd_exit()
663 spin_lock(&table->ht_lock); in tsd_exit()
664 pid_entry = tsd_hash_search(table, PID_KEY, curthread->pid); in tsd_exit()
666 spin_unlock(&table->ht_lock); in tsd_exit()
672 * PID_KEY entry. They are removed from the hash table and in tsd_exit()
682 (ulong_t)entry->he_pid, table->ht_bits); in tsd_exit()
683 entry_bin = &table->ht_bins[hash]; in tsd_exit()
686 tsd_hash_del(table, entry); in tsd_exit()
692 (ulong_t)pid_entry->he_pid, table->ht_bits); in tsd_exit()
693 pid_entry_bin = &table->ht_bins[hash]; in tsd_exit()
696 tsd_hash_del(table, pid_entry); in tsd_exit()
699 spin_unlock(&table->ht_lock); in tsd_exit()