From: Eric Wong <mwrap-perl@80x24.org>
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 [thread overview]
Message-ID: <20220904074442.26051-3-mwrap-perl@80x24.org> (raw)
In-Reply-To: <20220904074442.26051-1-mwrap-perl@80x24.org>
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
prev parent reply other threads:[~2022-09-04 7:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-04 7:44 [PATCH 0/2] allow tracking allocations earlier Eric Wong
2022-09-04 7:44 ` [PATCH 1/2] Makefile.PL: check for execinfo on FreeBSD Eric Wong
2022-09-04 7:44 ` Eric Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220904074442.26051-3-mwrap-perl@80x24.org \
--to=mwrap-perl@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mwrap-perl.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).