Hi Mark, On Wed, Jan 22, 2025 at 4:55 PM Mark Wielaard <m...@klomp.org> wrote: > > On Sun, Jan 19, 2025 at 10:20:28PM -0500, Aaron Merey wrote: > > Change type of dwarf_lock to mutex in order to take advantage of > > built-in support for recursive locking. > > When/where do we need recursive locking?
One example is dwarf_getsrcfiles, which contains a call to itself. A dwarf_getsrcfiles lock is added in patch 04/15 in this series. > > > * lib/locks.h: Add macros for locking, unlocking, initializing > > and destroying mutexes. > > * libdw/dwarf_begin_elf.c (dwarf_end): Replace rwlock macro with > > mutex macro. > > * libdw/dwarf_formref_die.c (dwarf_formref_die): Ditto. > > * libdw/dwarf_getalt.c (dwarf_getalt): Ditto. > > * libdw/dwarf_setalt.c (dwarf_setalt): Ditto. > > * libdw/libdwP.h (struct Dwarf): Ditto. > > * libdw/libdw_findcu.c (__libdw_findcu): Ditto. > > OK, this seems to work because we only use rwlocks and never rdlocks. > > > Signed-off-by: Aaron Merey <ame...@redhat.com> > > > > --- > > If performance suffers too much from serializing all accesses to Dwarf > > objects, we could instead consider using an rwlock with a custom wrapper > > that implements recursive locking. > > We could also use multiple locks for different parts of the > Dwarf. Like we already do for the trees. > > Currently the lock is shared for accessing the > __libdw_intern_next_unit and the alt_dwarf. Yes but for now I'd prefer to keep the lock logic as simple as possible and address lock performance issues when necessary. This should make it easier to achieve full thread-safety.