Lines Matching full:table
25 * Thread specific data has implemented using a hash table, this avoids
30 * The majority of the entries in the hash table are for specific tsd
37 * By default the hash table is sized to 512 bins which is expected to
40 * The hash table contains two additional type of entries. They first
92 * tsd_hash_search - searches hash table for tsd_hash_entry
93 * @table: hash table
98 tsd_hash_search(tsd_hash_table_t *table, uint_t key, pid_t pid) in tsd_hash_search() argument
105 hash = hash_long((ulong_t)key * (ulong_t)pid, table->ht_bits); in tsd_hash_search()
106 bin = &table->ht_bins[hash]; in tsd_hash_search()
144 * tsd_hash_add - adds an entry to hash table
145 * @table: hash table
150 * already exist in the hash table. This possible because all entries
153 * links to the dtor and pid entries the entire table is locked.
156 tsd_hash_add(tsd_hash_table_t *table, uint_t key, pid_t pid, void *value) in tsd_hash_add() argument
163 ASSERT3P(tsd_hash_search(table, key, pid), ==, NULL); in tsd_hash_add()
177 spin_lock(&table->ht_lock); in tsd_hash_add()
180 dtor_entry = tsd_hash_search(table, entry->he_key, DTOR_PID); in tsd_hash_add()
185 pid_entry = tsd_hash_search(table, PID_KEY, entry->he_pid); in tsd_hash_add()
188 hash = hash_long((ulong_t)key * (ulong_t)pid, table->ht_bits); in tsd_hash_add()
189 bin = &table->ht_bins[hash]; in tsd_hash_add()
198 spin_unlock(&table->ht_lock); in tsd_hash_add()
204 * tsd_hash_add_key - adds a destructor entry to the hash table
205 * @table: hash table
212 * will be set to the next available key for the hash table.
215 tsd_hash_add_key(tsd_hash_table_t *table, uint_t *keyp, dtor_func_t dtor) in tsd_hash_add_key() argument
222 ASSERT3P(table, !=, NULL); in tsd_hash_add_key()
230 spin_lock(&table->ht_lock); in tsd_hash_add_key()
233 if (table->ht_key++ > TSD_KEYS_MAX) in tsd_hash_add_key()
234 table->ht_key = 1; in tsd_hash_add_key()
238 spin_unlock(&table->ht_lock); in tsd_hash_add_key()
242 tmp_entry = tsd_hash_search(table, table->ht_key, DTOR_PID); in tsd_hash_add_key()
245 /* Add destructor entry in to hash table */ in tsd_hash_add_key()
246 entry->he_key = *keyp = table->ht_key; in tsd_hash_add_key()
254 hash = hash_long((ulong_t)*keyp * (ulong_t)DTOR_PID, table->ht_bits); in tsd_hash_add_key()
255 bin = &table->ht_bins[hash]; in tsd_hash_add_key()
261 spin_unlock(&table->ht_lock); in tsd_hash_add_key()
267 * tsd_hash_add_pid - adds a process entry to the hash table
268 * @table: hash table
276 tsd_hash_add_pid(tsd_hash_table_t *table, pid_t pid) in tsd_hash_add_pid() argument
287 spin_lock(&table->ht_lock); in tsd_hash_add_pid()
296 hash = hash_long((ulong_t)PID_KEY * (ulong_t)pid, table->ht_bits); in tsd_hash_add_pid()
297 bin = &table->ht_bins[hash]; in tsd_hash_add_pid()
303 spin_unlock(&table->ht_lock); in tsd_hash_add_pid()
309 * tsd_hash_del - delete an entry from hash table, key, and pid lists
310 * @table: hash table
315 tsd_hash_del(tsd_hash_table_t *table, tsd_hash_entry_t *entry) in tsd_hash_del() argument
323 * tsd_hash_table_init - allocate a hash table
324 * @bits: hash table size
326 * A hash table with 2^bits bins will be created, it may not be resized
332 tsd_hash_table_t *table; in tsd_hash_table_init() local
335 table = kmem_zalloc(sizeof (tsd_hash_table_t), KM_SLEEP); in tsd_hash_table_init()
336 if (table == NULL) in tsd_hash_table_init()
339 table->ht_bins = kmem_zalloc(sizeof (tsd_hash_bin_t) * size, KM_SLEEP); in tsd_hash_table_init()
340 if (table->ht_bins == NULL) { in tsd_hash_table_init()
341 kmem_free(table, sizeof (tsd_hash_table_t)); in tsd_hash_table_init()
346 spin_lock_init(&table->ht_bins[hash].hb_lock); in tsd_hash_table_init()
347 INIT_HLIST_HEAD(&table->ht_bins[hash].hb_head); in tsd_hash_table_init()
350 spin_lock_init(&table->ht_lock); in tsd_hash_table_init()
351 table->ht_bits = bits; in tsd_hash_table_init()
352 table->ht_key = 1; in tsd_hash_table_init()
354 return (table); in tsd_hash_table_init()
358 * tsd_hash_table_fini - free a hash table
359 * @table: hash table
361 * Free a hash table allocated by tsd_hash_table_init(). If the hash
362 * table is not empty this function will call the proper destructor for
366 tsd_hash_table_fini(tsd_hash_table_t *table) in tsd_hash_table_fini() argument
373 ASSERT3P(table, !=, NULL); in tsd_hash_table_fini()
374 spin_lock(&table->ht_lock); in tsd_hash_table_fini()
375 for (i = 0, size = (1 << table->ht_bits); i < size; i++) { in tsd_hash_table_fini()
376 bin = &table->ht_bins[i]; in tsd_hash_table_fini()
381 tsd_hash_del(table, entry); in tsd_hash_table_fini()
386 spin_unlock(&table->ht_lock); in tsd_hash_table_fini()
389 kmem_free(table->ht_bins, sizeof (tsd_hash_bin_t)*(1<<table->ht_bits)); in tsd_hash_table_fini()
390 kmem_free(table, sizeof (tsd_hash_table_t)); in tsd_hash_table_fini()
404 tsd_hash_table_t *table; in tsd_remove_entry() local
409 table = tsd_hash_table; in tsd_remove_entry()
410 ASSERT3P(table, !=, NULL); in tsd_remove_entry()
413 spin_lock(&table->ht_lock); in tsd_remove_entry()
416 (ulong_t)entry->he_pid, table->ht_bits); in tsd_remove_entry()
417 entry_bin = &table->ht_bins[hash]; in tsd_remove_entry()
425 tsd_hash_del(table, entry); in tsd_remove_entry()
433 (ulong_t)pid_entry->he_pid, table->ht_bits); in tsd_remove_entry()
434 pid_entry_bin = &table->ht_bins[hash]; in tsd_remove_entry()
437 tsd_hash_del(table, pid_entry); in tsd_remove_entry()
442 spin_unlock(&table->ht_lock); in tsd_remove_entry()
461 tsd_hash_table_t *table; in tsd_set() local
468 table = tsd_hash_table; in tsd_set()
470 ASSERT3P(table, !=, NULL); in tsd_set()
475 /* Entry already exists in hash table update value */ in tsd_set()
476 entry = tsd_hash_search(table, key, pid); in tsd_set()
490 entry = tsd_hash_search(table, PID_KEY, pid); in tsd_set()
492 rc = tsd_hash_add_pid(table, pid); in tsd_set()
497 rc = tsd_hash_add(table, key, pid, value); in tsd_set()
508 * lock the entire table only a single hash bin.
535 * lock the entire table only a single hash bin.
591 tsd_hash_table_t *table; in tsd_destroy() local
596 table = tsd_hash_table; in tsd_destroy()
597 ASSERT3P(table, !=, NULL); in tsd_destroy()
599 spin_lock(&table->ht_lock); in tsd_destroy()
600 dtor_entry = tsd_hash_search(table, *keyp, DTOR_PID); in tsd_destroy()
602 spin_unlock(&table->ht_lock); in tsd_destroy()
608 * DTOR_PID entry. They are removed from the hash table and in tsd_destroy()
618 (ulong_t)entry->he_pid, table->ht_bits); in tsd_destroy()
619 entry_bin = &table->ht_bins[hash]; in tsd_destroy()
622 tsd_hash_del(table, entry); in tsd_destroy()
628 (ulong_t)dtor_entry->he_pid, table->ht_bits); in tsd_destroy()
629 dtor_entry_bin = &table->ht_bins[hash]; in tsd_destroy()
632 tsd_hash_del(table, dtor_entry); in tsd_destroy()
635 spin_unlock(&table->ht_lock); in tsd_destroy()
654 tsd_hash_table_t *table; in tsd_exit() local
659 table = tsd_hash_table; in tsd_exit()
660 ASSERT3P(table, !=, NULL); in tsd_exit()
662 spin_lock(&table->ht_lock); in tsd_exit()
663 pid_entry = tsd_hash_search(table, PID_KEY, curthread->pid); in tsd_exit()
665 spin_unlock(&table->ht_lock); in tsd_exit()
671 * PID_KEY entry. They are removed from the hash table and in tsd_exit()
681 (ulong_t)entry->he_pid, table->ht_bits); in tsd_exit()
682 entry_bin = &table->ht_bins[hash]; in tsd_exit()
685 tsd_hash_del(table, entry); in tsd_exit()
691 (ulong_t)pid_entry->he_pid, table->ht_bits); in tsd_exit()
692 pid_entry_bin = &table->ht_bins[hash]; in tsd_exit()
695 tsd_hash_del(table, pid_entry); in tsd_exit()
698 spin_unlock(&table->ht_lock); in tsd_exit()