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 CB8E61F601 for ; Sun, 4 Sep 2022 07:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1662277433; bh=4NzlWXw51jWhWwaxyUOjJvW68vLRBP2G3+gu2YcHIXc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=X3IDn/MQh5WbZSQHfR6mC1kRuMFzb4xT8X2bBfhgW5NU1JWSWJ6AqT6wMfrYnf+rz EXx1KKdYG9svxC5X5aTVZFWKxK0GEIDdF1zBtKyXKgw1M7u65hk0pIIuh5rzexq6w7 De0GqjfnE0Bq3Qsuu1XnclL/MKaVqAGzwiyl6ffM= From: Eric Wong To: mwrap-perl@80x24.org Subject: [PATCH 2/2] create the `totals' rculfhash as early as possible Date: Sun, 4 Sep 2022 07:44:42 +0000 Message-Id: <20220904074442.26051-3-mwrap-perl@80x24.org> In-Reply-To: <20220904074442.26051-1-mwrap-perl@80x24.org> References: <20220904074442.26051-1-mwrap-perl@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This allows us to start tracking allocations before Perl calls our BOOT code, which can be far later if it has to boot other modules first. As an LD_PRELOAD, the constructor can fire before Perl's main(). --- Mwrap.xs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Mwrap.xs b/Mwrap.xs index 510e211..092aaf4 100644 --- a/Mwrap.xs +++ b/Mwrap.xs @@ -144,6 +144,10 @@ __attribute__((constructor)) static void resolve_malloc(void) } #endif /* !__FreeBSD__ */ } + CMM_STORE_SHARED(totals, lfht_new()); + if (!CMM_LOAD_SHARED(totals)) + fprintf(stderr, "failed to allocate totals table\n"); + err = pthread_atfork(call_rcu_before_fork, call_rcu_after_fork_parent, call_rcu_after_fork_child); @@ -805,9 +809,6 @@ BOOT: #ifndef PERL_IMPLICIT_CONTEXT root_locating = &locating; #endif - CMM_STORE_SHARED(totals, lfht_new()); - if (!CMM_LOAD_SHARED(totals)) - fprintf(stderr, "failed to allocate totals table\n"); PROTOTYPES: ENABLE