Revert "libsysprof: add rwlock for symbol cache"

This reverts commit d1b4308af7.
This commit is contained in:
Christian Hergert
2023-08-16 15:43:50 -07:00
parent 48dc402c3b
commit 9f00d904b0

View File

@ -42,7 +42,6 @@ struct _SysprofSymbolCacheNode
struct _SysprofSymbolCache struct _SysprofSymbolCache
{ {
GObject parent_instance; GObject parent_instance;
GRWLock rwlock;
RB_HEAD(sysprof_symbol_cache, _SysprofSymbolCacheNode) head; RB_HEAD(sysprof_symbol_cache, _SysprofSymbolCacheNode) head;
}; };
@ -105,8 +104,6 @@ sysprof_symbol_cache_finalize (GObject *object)
if (node != NULL) if (node != NULL)
sysprof_symbol_cache_node_free (node); sysprof_symbol_cache_node_free (node);
g_rw_lock_clear (&self->rwlock);
G_OBJECT_CLASS (sysprof_symbol_cache_parent_class)->finalize (object); G_OBJECT_CLASS (sysprof_symbol_cache_parent_class)->finalize (object);
} }
@ -121,7 +118,6 @@ sysprof_symbol_cache_class_init (SysprofSymbolCacheClass *klass)
static void static void
sysprof_symbol_cache_init (SysprofSymbolCache *self) sysprof_symbol_cache_init (SysprofSymbolCache *self)
{ {
g_rw_lock_init (&self->rwlock);
RB_INIT (&self->head); RB_INIT (&self->head);
} }
@ -158,14 +154,11 @@ sysprof_symbol_cache_take (SysprofSymbolCache *self,
node->high = symbol->end_address-1; node->high = symbol->end_address-1;
node->max = node->high; node->max = node->high;
g_rw_lock_writer_lock (&self->rwlock);
/* If there is a collision, then the node is returned. Otherwise /* If there is a collision, then the node is returned. Otherwise
* if the node was inserted, NULL is returned. * if the node was inserted, NULL is returned.
*/ */
if ((ret = RB_INSERT(sysprof_symbol_cache, &self->head, node))) if ((ret = RB_INSERT(sysprof_symbol_cache, &self->head, node)))
{ {
g_rw_lock_writer_unlock (&self->rwlock);
sysprof_symbol_cache_node_free (node); sysprof_symbol_cache_node_free (node);
return; return;
} }
@ -179,8 +172,6 @@ sysprof_symbol_cache_take (SysprofSymbolCache *self,
node = parent; node = parent;
parent = RB_PARENT(parent, link); parent = RB_PARENT(parent, link);
} }
g_rw_lock_writer_unlock (&self->rwlock);
} }
SysprofSymbol * SysprofSymbol *
@ -194,8 +185,6 @@ sysprof_symbol_cache_lookup (SysprofSymbolCache *self,
if (address == 0) if (address == 0)
return NULL; return NULL;
g_rw_lock_reader_lock (&self->rwlock);
node = RB_ROOT(&self->head); node = RB_ROOT(&self->head);
/* The root node contains our calculated max as augmented in RBTree. /* The root node contains our calculated max as augmented in RBTree.
@ -203,10 +192,7 @@ sysprof_symbol_cache_lookup (SysprofSymbolCache *self,
* in O(1) without having to add a branch to the while loop below. * in O(1) without having to add a branch to the while loop below.
*/ */
if (node == NULL || node->max < address) if (node == NULL || node->max < address)
{ return NULL;
g_rw_lock_reader_unlock (&self->rwlock);
return NULL;
}
while (node != NULL) while (node != NULL)
{ {
@ -216,10 +202,7 @@ sysprof_symbol_cache_lookup (SysprofSymbolCache *self,
node->max >= RB_RIGHT(node, link)->max); node->max >= RB_RIGHT(node, link)->max);
if (address >= node->low && address <= node->high) if (address >= node->low && address <= node->high)
{ return node->symbol;
g_rw_lock_reader_unlock (&self->rwlock);
return node->symbol;
}
if (RB_LEFT(node, link) && RB_LEFT(node, link)->max >= address) if (RB_LEFT(node, link) && RB_LEFT(node, link)->max >= address)
node = RB_LEFT(node, link); node = RB_LEFT(node, link);
@ -227,8 +210,6 @@ sysprof_symbol_cache_lookup (SysprofSymbolCache *self,
node = RB_RIGHT(node, link); node = RB_RIGHT(node, link);
} }
g_rw_lock_reader_unlock (&self->rwlock);
return NULL; return NULL;
} }