Message ID | 20240717223409.1788719-7-amerey@redhat.com |
---|---|
State | Superseded |
Headers |
Return-Path: <elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 79DAC385E830 for <patchwork@sourceware.org>; Wed, 17 Jul 2024 22:35:15 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 84B10385EC56 for <elfutils-devel@sourceware.org>; Wed, 17 Jul 2024 22:34:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 84B10385EC56 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 84B10385EC56 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721255699; cv=none; b=tLrA+BhvEqT0Z7yQbkg3qHf8qB89iK3Tko6pmvia2ZqVMupE0XOzzm6JzWv5RmhYS6y5BOd154Aue6pCZwCf+qhSo+GWIjZn21+KSkDmftBuclFHgOKfFwzbrJe8S9E2jfixunNCqkW3uI7Wx+j0GBftQC8wfXfjmwJFJ+Sbg+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721255699; c=relaxed/simple; bh=xUGS+/yjz8li4HJFyS/d3x9JiF0XbfVB60EOpK7UX9c=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=iqAKzJP2pDKbC1WZyvk3Tj8rLnKU8jd88c926QFlcy6GSkKFPYo89bACjBDmpgHsM8BbkifF7pQKgU/G0GjqVWJ1lDw5E/+7UW7g0JTTC2ohcuiiJUVgJeXQ5WGDwAK29wsQ7knhDkfjwICeEclGY0lqmXIXC7RNeTJ8FGpWd6g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721255697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+heS7PWPjBYP+bDelWFfYMweIg0OYK+k8SwAHyJXx9Y=; b=YfIrL6ipLUAlkkTGkOON5X9j1UvAQF3qOOPkcdKWRIg6WdHlDV58GuaEB/uUoMGM1OF81P 9khZcBskDmSZv0v3sQIMWPNdk6qwf7fIOPaD8cS9WgB1fjGvDsB1sGCaSJKIL7BSBXukLJ pHVMZ/NVqvaJIiD4kV5OWjACZV4sTEs= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-644-EHxOhvmVMum4uinHx1JyLg-1; Wed, 17 Jul 2024 18:34:55 -0400 X-MC-Unique: EHxOhvmVMum4uinHx1JyLg-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A18DC19560B1; Wed, 17 Jul 2024 22:34:54 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.16.62]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2686B19560AA; Wed, 17 Jul 2024 22:34:52 +0000 (UTC) From: Aaron Merey <amerey@redhat.com> To: elfutils-devel@sourceware.org Cc: hsm2@rice.edu, johnmc@rice.edu, Aaron Merey <amerey@redhat.com>, Mark Wielaard <mark@klomp.org> Subject: [PATCH 6/9 v2] libdw: Make libdw_find_split_unit thread-safe Date: Wed, 17 Jul 2024 18:34:05 -0400 Message-ID: <20240717223409.1788719-7-amerey@redhat.com> In-Reply-To: <20240717223409.1788719-1-amerey@redhat.com> References: <20240717223409.1788719-1-amerey@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, 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 X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list <elfutils-devel.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/elfutils-devel>, <mailto:elfutils-devel-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/elfutils-devel/> List-Post: <mailto:elfutils-devel@sourceware.org> List-Help: <mailto:elfutils-devel-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/elfutils-devel>, <mailto:elfutils-devel-request@sourceware.org?subject=subscribe> Errors-To: elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org |
Series |
Fix thread-safety for elfutils
|
|
Commit Message
Aaron Merey
July 17, 2024, 10:34 p.m. UTC
From: Heather McIntyre <hsm2@rice.edu> * (__libdw_find_split_unit): Add lock for cu->split. Signed-off-by: Heather S. McIntyre <hsm2@rice.edu> Signed-off-by: Aaron Merey <amerey@redhat.com> Signed-off-by: Mark Wielaard <mark@klomp.org> --- v2 changes: Locking applied to __libdw_find_split_unit instead of try_split_file. libdw/libdw_find_split_unit.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Comments
Hi, On Wed, Jul 17, 2024 at 06:34:05PM -0400, Aaron Merey wrote: > From: Heather McIntyre <hsm2@rice.edu> > > * (__libdw_find_split_unit): Add lock for cu->split. > > Signed-off-by: Heather S. McIntyre <hsm2@rice.edu> > Signed-off-by: Aaron Merey <amerey@redhat.com> > Signed-off-by: Mark Wielaard <mark@klomp.org> > > --- > > v2 changes: > Locking applied to __libdw_find_split_unit instead of try_split_file. > > libdw/libdw_find_split_unit.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) Would be nice to have the split_lock definition from patch "lib: Add eu_tsearch, eu_tfind, eu_tdelete and eu_tdestroy " here to make this patch self-contained. > diff --git a/libdw/libdw_find_split_unit.c b/libdw/libdw_find_split_unit.c > index 67d31a9c..eb3d88d7 100644 > --- a/libdw/libdw_find_split_unit.c > +++ b/libdw/libdw_find_split_unit.c > @@ -150,9 +150,14 @@ Dwarf_CU * > internal_function > __libdw_find_split_unit (Dwarf_CU *cu) > { > + rwlock_wrlock(cu->split_lock); > + > /* Only try once. */ > if (cu->split != (Dwarf_CU *) -1) > - return cu->split; > + { > + rwlock_unlock(cu->split_lock); > + return cu->split; > + } > > /* We need a skeleton unit with a comp_dir and [GNU_]dwo_name attributes. > The split unit will be the first in the dwo file and should have the > @@ -207,5 +212,6 @@ __libdw_find_split_unit (Dwarf_CU *cu) > if (cu->split == (Dwarf_CU *) -1) > cu->split = NULL; > > + rwlock_unlock(cu->split_lock); > return cu->split; > } Again, just as a style issue, because it looks like the unlocked read is fine in this case, but I really like the Dwarf_CU *result; result = cu->split; unlock; return result; idiom here. Cheers, Mark
diff --git a/libdw/libdw_find_split_unit.c b/libdw/libdw_find_split_unit.c index 67d31a9c..eb3d88d7 100644 --- a/libdw/libdw_find_split_unit.c +++ b/libdw/libdw_find_split_unit.c @@ -150,9 +150,14 @@ Dwarf_CU * internal_function __libdw_find_split_unit (Dwarf_CU *cu) { + rwlock_wrlock(cu->split_lock); + /* Only try once. */ if (cu->split != (Dwarf_CU *) -1) - return cu->split; + { + rwlock_unlock(cu->split_lock); + return cu->split; + } /* We need a skeleton unit with a comp_dir and [GNU_]dwo_name attributes. The split unit will be the first in the dwo file and should have the @@ -207,5 +212,6 @@ __libdw_find_split_unit (Dwarf_CU *cu) if (cu->split == (Dwarf_CU *) -1) cu->split = NULL; + rwlock_unlock(cu->split_lock); return cu->split; }