From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 3FCD91F61A for ; Sat, 3 Sep 2022 11:18:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1662203909; bh=acBNiNhzbn2+bdGFQtfuUc/ZQnHLQ3ERwPPktlttDYc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=EzS7IziOW57ctvl4Si7lguJT+gnaVj/UboQ1Gt3Sz6Fc3x17o6TFdzA86yoHp3hd9 L++TvUwKZMcj8fhLCQAEv6BfGKZFBqsfhRICWIY9L6n7RnyV8ym6CxSDHzjEkS2txF WwHxaHiDAs/E0qB0kuq2T2VTOxb6thIrjVneIPRw= From: Eric Wong To: mwrap-perl@80x24.org Subject: [PATCH 4/4] workaround breakage from urcu v0.11.4 Date: Sat, 3 Sep 2022 11:18:28 +0000 Message-Id: <20220903111828.2316808-5-mwrap-perl@80x24.org> In-Reply-To: <20220903111828.2316808-1-mwrap-perl@80x24.org> References: <20220903111828.2316808-1-mwrap-perl@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: urcu v0.11.4+ introduced commit 7ca7fe9c03 (Make temporary variable in _rcu_dereference non-const, 2021-07-29) which conflicts with our use of _LGPL_SOURCE. In retrospect, CMM_LOAD_SHARED and CMM_STORE_SHARED seem sufficient for our use of the `totals' cds_lfht pointer since the constructur should always fire before any threads are running. This is fixed in urcu v0.12.4 and v0.13.2 (released 2022-08-18) but I suspect older versions will live on in enterprise/LTS distros for a long while. Link: https://lore.kernel.org/lttng-dev/20220809181927.GA3718@dcvr/ --- Mwrap.xs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Mwrap.xs b/Mwrap.xs index 9e9f571..9a85f36 100644 --- a/Mwrap.xs +++ b/Mwrap.xs @@ -298,7 +298,7 @@ static struct src_loc *totals_add_rcu(struct src_loc *k) struct cds_lfht *t; again: - t = rcu_dereference(totals); + t = CMM_LOAD_SHARED(totals); if (!t) goto out_unlock; cds_lfht_lookup(t, k->hval, loc_eq, k, &iter); cur = cds_lfht_iter_get_node(&iter); @@ -341,7 +341,7 @@ update_stats_rcu_lock(size_t *generation, size_t size, uintptr_t caller) static const size_t xlen = sizeof(caller); char *dst; const COP *cop; - struct cds_lfht *t = rcu_dereference(totals); + struct cds_lfht *t = CMM_LOAD_SHARED(totals); if (caa_unlikely(!t)) return 0; if (locating++) goto out; /* do not recurse into another *alloc */ @@ -684,7 +684,7 @@ static void *dump_to_file(struct dump_arg *a) ++locating; rcu_read_lock(); - t = rcu_dereference(totals); + t = CMM_LOAD_SHARED(totals); if (!t) goto out_unlock; cds_lfht_for_each_entry(t, &iter, l, hnode) { @@ -805,8 +805,8 @@ BOOT: #ifndef PERL_IMPLICIT_CONTEXT root_locating = &locating; #endif - totals = lfht_new(); - if (!totals) + CMM_STORE_SHARED(totals, lfht_new()); + if (!CMM_LOAD_SHARED(totals)) fprintf(stderr, "failed to allocate totals table\n"); PROTOTYPES: ENABLE @@ -851,7 +851,7 @@ PREINIT: CODE: ++locating; rcu_read_lock(); - t = rcu_dereference(totals); + t = CMM_LOAD_SHARED(totals); if (t) { bool err = false; @@ -903,7 +903,7 @@ CODE: uatomic_set(&total_bytes_dec, 0); rcu_read_lock(); - t = rcu_dereference(totals); + t = CMM_LOAD_SHARED(totals); cds_lfht_for_each_entry(t, &iter, l, hnode) { uatomic_set(&l->total, 0); uatomic_set(&l->allocations, 0); @@ -949,7 +949,7 @@ CODE: XSRETURN_UNDEF; rcu_read_lock(); - t = rcu_dereference(totals); + t = CMM_LOAD_SHARED(totals); if (!t) goto out_unlock; cds_lfht_lookup(t, k->hval, loc_eq, k, &iter);