From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Cc: hsm2@rice.edu
Subject: Re: [PATCH 09/16] src: Use eu-search in nm and findtextrel.
Date: Tue, 10 Oct 2023 23:25:33 +0200 [thread overview]
Message-ID: <20231010212533.GM728@gnu.wildebeest.org> (raw)
In-Reply-To: <20231010134300.53830-9-mark@klomp.org>
Hi Heather,
On Tue, Oct 10, 2023 at 03:42:53PM +0200, Mark Wielaard wrote:
> From: Heather McIntyre <hsm2@rice.edu>
>
> * src/Makefile.am: Add USE_LOCKS condition for -pthread.
> * src/findtextrel.c: Add eu-search.h and remove search.h.
> Change calls of tsearch/tfind to eu_tsearch/eu_tfind.
> * src/nm.c: Likewise.
This does look technically correct. But both nm and findtextrel are
single threaded programs. It might be interesting to try to make them
parallel. But currently I think this would just introduce unnecessary
locking.
Cheers,
Mark
> Signed-off-by: Heather S. McIntyre <hsm2@rice.edu>
> Signed-off-by: Mark Wielaard <mark@klomp.org>
> ---
> src/Makefile.am | 3 +++
> src/findtextrel.c | 10 +++++-----
> src/nm.c | 10 +++++-----
> 3 files changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 10d59a48..fea5d43e 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -22,6 +22,9 @@ DEFS += $(YYDEBUG) -DDEBUGPRED=@DEBUGPRED@ \
> AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \
> -I$(srcdir)/../libdw -I$(srcdir)/../libdwelf \
> -I$(srcdir)/../libdwfl -I$(srcdir)/../libasm
> +if USE_LOCKS
> + AM_CFLAGS += -pthread
> +endif
>
> AM_LDFLAGS = -Wl,-rpath-link,../libelf:../libdw $(STACK_USAGE_NO_ERROR)
>
> diff --git a/src/findtextrel.c b/src/findtextrel.c
> index d3021a3a..5ac4c29a 100644
> --- a/src/findtextrel.c
> +++ b/src/findtextrel.c
> @@ -27,7 +27,7 @@
> #include <gelf.h>
> #include <libdw.h>
> #include <locale.h>
> -#include <search.h>
> +#include <eu-search.h>
> #include <stdbool.h>
> #include <stdio.h>
> #include <stdlib.h>
> @@ -501,10 +501,10 @@ check_rel (size_t nsegments, struct segments segments[nsegments],
> /* There can be more than one relocation against one file.
> Try to avoid multiple messages. And yes, the code uses
> pointer comparison. */
> - if (tfind (src, knownsrcs, ptrcompare) == NULL)
> + if (eu_tfind (src, knownsrcs, ptrcompare) == NULL)
> {
> printf (_("%s not compiled with -fpic/-fPIC\n"), src);
> - tsearch (src, knownsrcs, ptrcompare);
> + eu_tsearch (src, knownsrcs, ptrcompare);
> }
> return;
> }
> @@ -555,12 +555,12 @@ check_rel (size_t nsegments, struct segments segments[nsegments],
> if (sym->st_value + sym->st_size > addr)
> {
> /* It is this function. */
> - if (tfind (lowstr, knownsrcs, ptrcompare) == NULL)
> + if (eu_tfind (lowstr, knownsrcs, ptrcompare) == NULL)
> {
> printf (_("\
> the file containing the function '%s' is not compiled with -fpic/-fPIC\n"),
> lowstr);
> - tsearch (lowstr, knownsrcs, ptrcompare);
> + eu_tsearch (lowstr, knownsrcs, ptrcompare);
> }
> }
> else if (highidx == -1)
> diff --git a/src/nm.c b/src/nm.c
> index fbdee8e1..44c20fb2 100644
> --- a/src/nm.c
> +++ b/src/nm.c
> @@ -32,7 +32,7 @@
> #include <libdw.h>
> #include <locale.h>
> #include <obstack.h>
> -#include <search.h>
> +#include <eu-search.h>
> #include <stdbool.h>
> #include <stdio.h>
> #include <stdio_ext.h>
> @@ -537,7 +537,7 @@ static int
> get_global (Dwarf *dbg __attribute__ ((unused)), Dwarf_Global *global,
> void *arg __attribute__ ((unused)))
> {
> - tsearch (memcpy (xmalloc (sizeof (Dwarf_Global)), global,
> + eu_tsearch (memcpy (xmalloc (sizeof (Dwarf_Global)), global,
> sizeof (Dwarf_Global)),
> &global_root, global_compare);
>
> @@ -696,7 +696,7 @@ get_local_names (Dwarf *dbg)
> /* Check whether a similar local_name is already in the
> cache. That should not happen. But if it does, we
> don't want to leak memory. */
> - struct local_name **tres = tsearch (newp, &local_root,
> + struct local_name **tres = eu_tsearch (newp, &local_root,
> local_compare);
> if (tres == NULL)
> error_exit (errno, _("cannot create search tree"));
> @@ -1387,7 +1387,7 @@ show_symbols (int fd, Ebl *ebl, GElf_Ehdr *ehdr,
> && global_root != NULL)
> {
> Dwarf_Global fake = { .name = symstr };
> - Dwarf_Global **found = tfind (&fake, &global_root,
> + Dwarf_Global **found = eu_tfind (&fake, &global_root,
> global_compare);
> if (found != NULL)
> {
> @@ -1442,7 +1442,7 @@ show_symbols (int fd, Ebl *ebl, GElf_Ehdr *ehdr,
> .lowpc = sym->st_value,
> .highpc = sym->st_value,
> };
> - struct local_name **found = tfind (&fake, &local_root,
> + struct local_name **found = eu_tfind (&fake, &local_root,
> local_compare);
> if (found != NULL)
> {
> --
> 2.41.0
>
next prev parent reply other threads:[~2023-10-10 21:25 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 17:07 [PATCH] Fix thread-safety for elfutils Heather McIntyre
2023-08-21 22:08 ` John Mellor-Crummey
2023-08-25 14:10 ` Mark Wielaard
2023-10-10 13:40 ` Mark Wielaard
2023-10-10 13:42 ` [PATCH 01/16] lib: Add new once_define and once macros to eu-config.h Mark Wielaard
2023-10-10 13:42 ` [PATCH 02/16] libelf: Make elf_version thread-safe Mark Wielaard
2023-10-10 14:00 ` Mark Wielaard
2023-10-17 19:05 ` Heather McIntyre
2023-10-19 21:00 ` Mark Wielaard
2023-10-10 13:42 ` [PATCH 03/16] libelf: Fix deadlock in __libelf_readall Mark Wielaard
2023-10-10 15:06 ` Mark Wielaard
2023-10-17 19:11 ` Heather McIntyre
2023-11-09 13:26 ` Mark Wielaard
2023-10-10 13:42 ` [PATCH 04/16] libelf: Fix deadlock in elf_cntl Mark Wielaard
2023-10-10 15:23 ` Mark Wielaard
2023-10-17 19:14 ` Heather McIntyre
2023-10-10 13:42 ` [PATCH 05/16] libelf: Fix elf_end deadlock Mark Wielaard
2023-10-10 15:28 ` Mark Wielaard
2023-10-10 13:42 ` [PATCH 06/16] libelf: Make elf32_getchdr and elf64_getchdr thread-safe Mark Wielaard
2023-10-10 16:28 ` Mark Wielaard
2023-10-10 13:42 ` [PATCH 07/16] lib: Add eu_tsearch and eu_tfind Mark Wielaard
2023-10-10 16:51 ` Mark Wielaard
2023-10-17 20:52 ` Heather McIntyre
2023-10-10 13:42 ` [PATCH 08/16] libcpu: Change calls for tsearch/tfind to eu_tsearch/eu_tfind Mark Wielaard
2023-10-10 21:10 ` Mark Wielaard
2023-10-10 13:42 ` [PATCH 09/16] src: Use eu-search in nm and findtextrel Mark Wielaard
2023-10-10 21:25 ` Mark Wielaard [this message]
2023-10-17 19:20 ` Heather McIntyre
2023-10-10 13:42 ` [PATCH 10/16] libdw: make dwarf_getalt thread-safe Mark Wielaard
2023-10-10 22:02 ` Mark Wielaard
2023-10-17 19:25 ` Heather McIntyre
2023-10-10 13:42 ` [PATCH 11/16] libdw: Add locking around __libdw_dieabbrev for dwarf_hasattr Mark Wielaard
2023-10-11 15:10 ` Mark Wielaard
2023-10-17 19:57 ` Heather McIntyre
2023-10-19 22:06 ` Mark Wielaard
2023-10-10 13:42 ` [PATCH 12/16] libdw: Make libdw_find_split_unit thread-safe Mark Wielaard
2023-10-11 17:17 ` Mark Wielaard
2023-10-17 20:01 ` Heather McIntyre
2023-10-10 13:42 ` [PATCH 13/16] libdw: Make libdw_findcu thread-safe Mark Wielaard
2023-10-12 22:02 ` Mark Wielaard
2023-10-17 20:10 ` Heather McIntyre
2023-10-10 13:42 ` [PATCH 14/16] libdw,libdwfl: Use eu-search for thread-safety Mark Wielaard
2023-10-12 22:05 ` Mark Wielaard
2023-10-10 13:42 ` [PATCH 15/16] tests: Add eu-search tests Mark Wielaard
2023-10-13 14:38 ` Mark Wielaard
2023-10-10 13:43 ` [PATCH 16/16] configure: No longer mark --enable-thread-safety as EXPERIMENTAL Mark Wielaard
2023-10-12 22:09 ` Mark Wielaard
2023-10-10 13:54 ` [PATCH 01/16] lib: Add new once_define and once macros to eu-config.h Mark Wielaard
2023-10-14 15:39 ` [PATCH] Fix thread-safety for elfutils Mark Wielaard
2023-10-14 18:29 ` Heather McIntyre
2023-10-17 15:04 ` Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231010212533.GM728@gnu.wildebeest.org \
--to=mark@klomp.org \
--cc=elfutils-devel@sourceware.org \
--cc=hsm2@rice.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).