From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH 1/2] cont.c (fiber_memsize): do not rely on ROOT_FIBER_CONTEXT
Date: Sun, 9 Sep 2018 08:35:13 +0000 [thread overview]
Message-ID: <20180909083514.13957-1-e@80x24.org> (raw)
We can check if the fiber we're interested in is the
th->root_fiber, so there is no need to use ROOT_FIBER_CONTEXT.
Note: there is no guarantee th->ec points to
&th->root_fiber->cont.saved_ec, vm::thread_memsize may not
account for root fiber correctly.
---
cont.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/cont.c b/cont.c
index 29c18a8eb2..0311e01f99 100644
--- a/cont.c
+++ b/cont.c
@@ -493,12 +493,15 @@ static size_t
fiber_memsize(const void *ptr)
{
const rb_fiber_t *fib = ptr;
- size_t size = 0;
+ size_t size = sizeof(*fib);
+ const rb_execution_context_t *saved_ec = &fib->cont.saved_ec;
+ const rb_thread_t *th = rb_ec_thread_ptr(saved_ec);
- size = sizeof(*fib);
- if (fib->cont.type != ROOT_FIBER_CONTEXT &&
- fib->cont.saved_ec.local_storage != NULL) {
- size += st_memsize(fib->cont.saved_ec.local_storage);
+ /*
+ * vm.c::thread_memsize already counts th->ec->local_storage
+ */
+ if (saved_ec->local_storage && fib != th->root_fiber) {
+ size += st_memsize(saved_ec->local_storage);
}
size += cont_memsize(&fib->cont);
return size;
--
EW
next reply other threads:[~2018-09-09 8:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-09 8:35 Eric Wong [this message]
2018-09-09 8:35 ` [PATCH 2/2] wip Eric Wong
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=20180909083514.13957-1-e@80x24.org \
--to=e@80x24.org \
--cc=spew@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.
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).