diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-09-03 18:50:35 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2017-09-05 14:33:01 -0400 |
| commit | bd74dc610a2069f8549a26668940ef655f51598d (patch) | |
| tree | c22aae3216f8c6ac50466ab8ce83fd58b7f9d77c /lib/thread.c | |
| parent | f24fdd9921b98f99d63b1299029d177954090243 (diff) | |
lib: Hash creation cleanup
1) Some hash key functions where converting pointers
directly to a 32 bit value via downcasting. Pointers
are 64 bit on a majority of our platforms.
2) Some hashes were being created with 256 entries,
downsize the hash creation size to more appropriate
values.
3) Add hash names to hash creation so we can watch
the hash via 'show debugging hashtable'
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'lib/thread.c')
| -rw-r--r-- | lib/thread.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/thread.c b/lib/thread.c index b39f2d55c2..0ce38dd340 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -31,6 +31,7 @@ #include "command.h" #include "sigevent.h" #include "network.h" +#include "jhash.h" DEFINE_MTYPE_STATIC(LIB, THREAD, "Thread") DEFINE_MTYPE_STATIC(LIB, THREAD_MASTER, "Thread master") @@ -58,7 +59,9 @@ static struct list *masters; /* CLI start ---------------------------------------------------------------- */ static unsigned int cpu_record_hash_key(struct cpu_thread_history *a) { - return (uintptr_t)a->func; + int size = sizeof (&a->func); + + return jhash(&a->func, size, 0); } static int cpu_record_hash_cmp(const struct cpu_thread_history *a, @@ -376,9 +379,11 @@ struct thread_master *thread_master_create(const char *name) return NULL; } - rv->cpu_record = hash_create( + rv->cpu_record = hash_create_size( + 8, (unsigned int (*)(void *))cpu_record_hash_key, - (int (*)(const void *, const void *))cpu_record_hash_cmp, NULL); + (int (*)(const void *, const void *))cpu_record_hash_cmp, + "Thread Hash"); /* Initialize the timer queues */ |
