]> pd.if.org Git - nbds/commitdiff
free its keys too when freeing a ht
authorjdybnis <jdybnis@9ec2166a-aeea-11dd-8830-69e4bb380a4a>
Thu, 13 Nov 2008 06:29:14 +0000 (06:29 +0000)
committerjdybnis <jdybnis@9ec2166a-aeea-11dd-8830-69e4bb380a4a>
Thu, 13 Nov 2008 06:29:14 +0000 (06:29 +0000)
runtime/mem.c
struct/ht.c
struct/ht_test.c
todo

index e46eb7efbd8bf8278ba786666012e753bf6e9650..7e56909fbd994cd7f77f0355b2898ef61d7d6067 100644 (file)
@@ -62,6 +62,7 @@ void mem_init (void) {
 //
 // TODO: maybe we want to munmap() larger size blocks to reclaim virtual address space?
 void nbd_free (void *x) {
 //
 // TODO: maybe we want to munmap() larger size blocks to reclaim virtual address space?
 void nbd_free (void *x) {
+    assert(x);
     LOCALIZE_THREAD_LOCAL(tid_, int);
     block_t  *b = (block_t *)x;
     assert(((size_t)b >> REGION_SCALE) < ((1 << HEADER_REGION_SCALE) / sizeof(header_t)));
     LOCALIZE_THREAD_LOCAL(tid_, int);
     block_t  *b = (block_t *)x;
     assert(((size_t)b >> REGION_SCALE) < ((1 << HEADER_REGION_SCALE) / sizeof(header_t)));
@@ -88,6 +89,7 @@ void nbd_free (void *x) {
 // on the private free list. If we didn't find any blocks on the public free lists, allocate a new
 // region, break it up into blocks and put them on the private free list.
 void *nbd_malloc (size_t n) {
 // on the private free list. If we didn't find any blocks on the public free lists, allocate a new
 // region, break it up into blocks and put them on the private free list.
 void *nbd_malloc (size_t n) {
+    assert(n);
     LOCALIZE_THREAD_LOCAL(tid_, int);
     if (n < sizeof(block_t)) {
         n = sizeof(block_t);
     LOCALIZE_THREAD_LOCAL(tid_, int);
     if (n < sizeof(block_t)) {
         n = sizeof(block_t);
index 8703faa705085edeaa7bcc2e50a6eade2042e76e..aed74fae86a2462e156e04cab4209d5d45145f05 100644 (file)
@@ -517,6 +517,12 @@ hash_table_t *ht_alloc (void) {
 void ht_free (hash_table_t *ht) {
     hash_table_i_t *hti = *ht;
     do {
 void ht_free (hash_table_t *ht) {
     hash_table_i_t *hti = *ht;
     do {
+        for (uint32_t i = 0; i < (1 << hti->scale); ++i) {
+            assert(hti->table[i].value == COPIED_VALUE || !IS_TAGGED(hti->table[i].value));
+            if (hti->table[i].key != DOES_NOT_EXIST) {
+                nbd_free((void *)(hti->table[i].key & MASK(48)));
+            }
+        }
         hash_table_i_t *next = hti->next;
         nbd_free(hti);
         hti = next;
         hash_table_i_t *next = hti->next;
         nbd_free(hti);
         hti = next;
index c7e6d57c1d34c59f9cd4ae2ce89750f1e544e0d1..fd7652446706cd55a2a59dab1db106184a017f18 100644 (file)
@@ -93,7 +93,7 @@ void *simple_worker (void *arg) {
     hash_table_t *ht = wd->ht;
     CuTest* tc = wd->tc;
     uint64_t d = wd->id;
     hash_table_t *ht = wd->ht;
     CuTest* tc = wd->tc;
     uint64_t d = wd->id;
-    int iters = 20000;
+    int iters = 1000000;
 
     SYNC_ADD(wd->wait, -1);
     do { } while (*((volatile worker_data_t *)wd)->wait); // wait for all workers to be ready
 
     SYNC_ADD(wd->wait, -1);
     do { } while (*((volatile worker_data_t *)wd)->wait); // wait for all workers to be ready
diff --git a/todo b/todo
index ff93413f6a9c8e9c58271e8101fcb26277e378e6..ab8c0db4bca300fbedcd8a5e6e4a9af0a1c0dc88 100644 (file)
--- a/todo
+++ b/todo
@@ -1,7 +1,5 @@
 - make rcu wait when its buffer gets full, instead of crashing
 - fix makefile to compute dependency info as a side-effect of compilation (-MF)
 - make rcu wait when its buffer gets full, instead of crashing
 - fix makefile to compute dependency info as a side-effect of compilation (-MF)
-- investigate 16 byte CAS 
-    - ht can store GUIDs inline instead of pointers to actual keys 
-    - mem can keep tail pointers for free-lists and do O(1) appends
+- investigate 16 byte CAS; ht can store GUIDs inline instead of pointers to actual keys 
 - test ht
 - optimize tracing code, still too much overhead
 - test ht
 - optimize tracing code, still too much overhead