From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-0010f301.pphosted.com (mx0a-0010f301.pphosted.com [148.163.149.254]) by sourceware.org (Postfix) with ESMTPS id 73D3B3858C54 for ; Tue, 17 Oct 2023 19:21:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 73D3B3858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=rice.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rice.edu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 73D3B3858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.149.254 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697570468; cv=none; b=HRi3zZpuC9uhgczN9BM507yyn6QbtdV11QCTGvsqOBRwFxfKsIRw+e/nxWD0P7LjE4cIf/N6yitpFgWgoREpe3FZGI2q4uA5MHnIrvprZ5kJ8nRgUlTWwbXPK5yMkX2wfVnTA7XOV9OEgzM2jP/ERobb4cXq4TDXeNRMvC8uPaI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697570468; c=relaxed/simple; bh=d9GVVBBrOL/Va3+hT+HxdZ+Ocpgqm2ex7O5J9c860Y8=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=e99jz4/qHkCd883FWbh5bjq2jUFC1GDtEDwU2jR9mgKutRjZqyGu6HvNtBCnC+80fXH7/gsFNMM171g5hdnLZtBYX9P2haYVBaqAcZrWgR7ULmmPe2GV+a85L+3q+NvvCiDz8qiluPyEffcM5MYyr4tWX9LnWK1iuFq/093u4Cc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0102856.ppops.net [127.0.0.1]) by mx0b-0010f301.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 39HHEEHZ006751 for ; Tue, 17 Oct 2023 14:21:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rice.edu; h= mime-version:references:in-reply-to:from:date:message-id:subject :to:cc:content-type; s=ricemail; bh=R19SnbcSYBUgHA0AbaGljqv5pVqj lXiolUG/op4aHV0=; b=aLYBTzLSZahdPHg6ys3bEQ48QfQbZih17pRRb8Ze7P5j b/L4DTqs2tKhS8LjtZF0qvC1wniV5zwksFgu8a73TlIsA7QGm98tto5HyzsbIjUZ 8Ijtf3rbJDAidX2NAqv0ZD8cBkrmGiBQusHoq6VZLavZzpLxpxLmXmwTJQ1nMYMQ bsIOus23NsIyh+liXyyVd+uFqnmYA9ejbVCQ5QpPBeRNasZbve4qSixt7TnS72uU omoMFm54Dxu3RgRK0u99xxj4J7rA+901I3Ww91A/dc2bLl4e2JfTRN6FjNBs5T6v QZJ5y5oi6Grtief4WSKHnSntkNaCRTuyodzK3R1oeQ== Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by mx0b-0010f301.pphosted.com (PPS) with ESMTPS id 3tqr415734-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 17 Oct 2023 14:21:02 -0500 (CDT) Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-507a0904cdbso3796642e87.1 for ; Tue, 17 Oct 2023 12:21:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697570460; x=1698175260; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=R19SnbcSYBUgHA0AbaGljqv5pVqjlXiolUG/op4aHV0=; b=jMFfAbf3OAi8nxE2BP9kMXU5y4kupIVkNKyAXcWoBG/H54uWl1BXdNYZKGFrERRomw YRlIXjFCkSIyOi8WfMA8xrdBUfn+7rG2wi0d4CLybyNS6EYBbNBgfrQi/ffT5IIAU8qh /f5lnWD4jyZNNzPAE24r1++seVfO035qGt/PLM1Q3qG2O1weB56tnVo7mWsRO3ByuTuU TCu0w4aoZ1bEYeEDP2bw79ivq2QAVvxGi4872oEL2s9QlTSho5hE8+4CdgHVs32JvkG2 T6aI+vHbL0EhQMOMjQN+wrxPd+OyQh/Wh+QkOWeL/rYYrJ9CSMl9v7ysGFAMx6CUYYAM QR5A== X-Gm-Message-State: AOJu0YxK4ZBtwCVO6XUydbpNyUDLLFS7eCr16roKUnIWJHnpIs/dlsZH KduVSEwQrIJQgYJ+NjVzdG1oAnUnoorcNVdk/eVgkCJVZsNgG36Q7PQQwtU0mkiltSe98CkV//+ ek6NFHy+UYwy/eejCJyY3b2EZ/N2LIaqlgHs90syArysocMiYT0Uy9ZlC19TxoulycJQmrr3ZYG MPEtU= X-Received: by 2002:ac2:4da3:0:b0:503:55c:7999 with SMTP id h3-20020ac24da3000000b00503055c7999mr2159111lfe.34.1697570459868; Tue, 17 Oct 2023 12:20:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJH9zyUfFvZ2x0zbtqLQZ86dXz6A+t1KUOKywPAGDP5LkxX7My+WQR88bxDyjI9Ocy2gLfpsf6fx83yO2eqrs= X-Received: by 2002:ac2:4da3:0:b0:503:55c:7999 with SMTP id h3-20020ac24da3000000b00503055c7999mr2159094lfe.34.1697570459509; Tue, 17 Oct 2023 12:20:59 -0700 (PDT) MIME-Version: 1.0 References: <301fac87e83ebbbd677750579ae9a3429b461bdf.camel@klomp.org> <20231010134300.53830-1-mark@klomp.org> <20231010134300.53830-9-mark@klomp.org> <20231010212533.GM728@gnu.wildebeest.org> In-Reply-To: <20231010212533.GM728@gnu.wildebeest.org> From: Heather McIntyre Date: Tue, 17 Oct 2023 14:20:48 -0500 Message-ID: Subject: Re: [PATCH 09/16] src: Use eu-search in nm and findtextrel. To: Mark Wielaard Cc: elfutils-devel@sourceware.org Content-Type: multipart/alternative; boundary="000000000000387c560607ee6c69" X-Proofpoint-DLP: Gmail-Outbound X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-17_03,2023-10-17_01,2023-05-22_02 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,HTML_MESSAGE,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000387c560607ee6c69 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thank you for pointing out that changes to these two files are not needed due to them being single threaded utilities. I reverted the changes and ran some tests. Works just fine with the original search.h, tsearch, and tfind. On Tue, Oct 10, 2023 at 4:26=E2=80=AFPM Mark Wielaard wrot= e: > Hi Heather, > > On Tue, Oct 10, 2023 at 03:42:53PM +0200, Mark Wielaard wrote: > > From: Heather McIntyre > > > > * 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 > > Signed-off-by: Mark Wielaard > > --- > > 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 +=3D $(YYDEBUG) -DDEBUGPRED=3D@DEBUGPRED@ \ > > AM_CPPFLAGS +=3D -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ > > -I$(srcdir)/../libdw -I$(srcdir)/../libdwelf \ > > -I$(srcdir)/../libdwfl -I$(srcdir)/../libasm > > +if USE_LOCKS > > + AM_CFLAGS +=3D -pthread > > +endif > > > > AM_LDFLAGS =3D -Wl,-rpath-link,../libelf:../libdw $(STACK_USAGE_NO_ERR= OR) > > > > 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 > > #include > > #include > > -#include > > +#include > > #include > > #include > > #include > > @@ -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) =3D=3D NULL) > > + if (eu_tfind (src, knownsrcs, ptrcompare) =3D=3D 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) =3D=3D = NULL) > > + if (eu_tfind (lowstr, knownsrcs, ptrcompare) =3D= =3D > 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 =3D=3D -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 > > #include > > #include > > -#include > > +#include > > #include > > #include > > #include > > @@ -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 =3D tsearch (newp, &local_root, > > + struct local_name **tres =3D eu_tsearch (newp, &local_root, > > local_compare); > > if (tres =3D=3D NULL) > > error_exit (errno, _("cannot create search tree")); > > @@ -1387,7 +1387,7 @@ show_symbols (int fd, Ebl *ebl, GElf_Ehdr *ehdr, > > && global_root !=3D NULL) > > { > > Dwarf_Global fake =3D { .name =3D symstr }; > > - Dwarf_Global **found =3D tfind (&fake, &global_root, > > + Dwarf_Global **found =3D eu_tfind (&fake, &global_root, > > global_compare); > > if (found !=3D NULL) > > { > > @@ -1442,7 +1442,7 @@ show_symbols (int fd, Ebl *ebl, GElf_Ehdr *ehdr, > > .lowpc =3D sym->st_value, > > .highpc =3D sym->st_value, > > }; > > - struct local_name **found =3D tfind (&fake, &local_root, > > + struct local_name **found =3D eu_tfind (&fake, &local_root, > > local_compare); > > if (found !=3D NULL) > > { > > -- > > 2.41.0 > > > --000000000000387c560607ee6c69--