From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18235 invoked by alias); 21 Oct 2019 18:00:46 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 18225 invoked by uid 89); 21 Oct 2019 18:00:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.100.3 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-19.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 spammy= X-Spam-Status: No, score=-19.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 21 Oct 2019 18:00:44 +0000 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 60B7C302BBF2; Mon, 21 Oct 2019 20:00:42 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 3A039404895B; Mon, 21 Oct 2019 20:00:42 +0200 (CEST) Message-ID: Subject: Re: [PATCH 2/3] libdw: Rewrite the memory handler to be thread-safe. From: Mark Wielaard To: Jonathon Anderson Cc: elfutils-devel@sourceware.org, Srdan Milakovic Date: Mon, 21 Oct 2019 18:00:00 -0000 In-Reply-To: <1571675292.2151.2@rice.edu> References: <1566877968.10901.0@smtp.mail.rice.edu> <20190829131614.18190-1-mark@klomp.org> <20190829131614.18190-3-mark@klomp.org> <0b22cc7764f6486e7e423c0aa8dc8571dddb9fd5.camel@klomp.org> <1571675292.2151.2@rice.edu> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Evolution 3.28.5 (3.28.5-5.el7) Mime-Version: 1.0 X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2019-q4/txt/msg00027.txt.bz2 Hi, On Mon, 2019-10-21 at 11:28 -0500, Jonathon Anderson wrote: > On Mon, Oct 21, 2019 at 18:13, Mark Wielaard wrote: > > Does that look reasonable? >=20 > It does, although I would prefer: >=20 > diff --git a/libdw/dwarf_end.c b/libdw/dwarf_end.c > index 9ca17212..6da9e0cd 100644 > --- a/libdw/dwarf_end.c > +++ b/libdw/dwarf_end.c > @@ -95,7 +95,9 @@ dwarf_end (Dwarf *dwarf) > tdestroy (dwarf->split_tree, noop_free); >=20 > /* Free the internally allocated memory. */ > - struct libdw_memblock *memp =3D (struct libdw_memblock=20 > *)dwarf->mem_tail; > + struct libdw_memblock *memp; > + memp =3D (struct libdw_memblock *)atomic_load(&dwarf->mem_tail, > + memory_order_relaxed); > while (memp !=3D NULL) > { > struct libdw_memblock *prevp =3D memp->prev; >=20 > Because some idiot thought making seq_cst the default was a good idea.=20 > And this way it notes in the code that this load is non-synchronizing. Lets avoid the "strong" language about people. But lets see if we can make the load less "strong" for the atomics :) I think we cannot use the atomic_load () function, but have to use atomic_load_explicit. So it would become: diff --git a/libdw/dwarf_end.c b/libdw/dwarf_end.c index fc573cb3..a2e94436 100644 --- a/libdw/dwarf_end.c +++ b/libdw/dwarf_end.c @@ -95,7 +95,10 @@ dwarf_end (Dwarf *dwarf) tdestroy (dwarf->split_tree, noop_free); =20 /* Free the internally allocated memory. */ - struct libdw_memblock *memp =3D (struct libdw_memblock *)dwarf->mem_= tail; + struct libdw_memblock *memp; + memp =3D (struct libdw_memblock *) (atomic_load_explicit + (&dwarf->mem_tail, + memory_order_relaxed)); while (memp !=3D NULL) { struct libdw_memblock *prevp =3D memp->prev; Cheers, Mark