From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: tml <tarantool-patches@freelists.org>
Subject: Re: [PATCH 3/3] lib/core/fiber: Put watermarks into stack to track its usage
Date: Wed, 13 Mar 2019 17:00:54 +0300 [thread overview]
Message-ID: <20190313140054.GO10420@uranus.lan> (raw)
In-Reply-To: <20190313135204.x7gn54iqiy5ulavn@esperanza>
On Wed, Mar 13, 2019 at 04:52:04PM +0300, Vladimir Davydov wrote:
> >
> > +static bool
> > +stack_has_wmark(void *addr)
>
> Please add brief comments to all the functions you add.
ok
> > +
> > + /*
> > + * When dropping pages make sure the page
> > + * containing overflow mark is untouched.
> > + * Same time no need to unmap the page which
> > + * carries "shrink" wmark, since we're updating
> > + * this page anyway.
> > + */
> > + if (stack_direction < 0) {
> > + end = page_align_down(fiber->stack_shrink_wmark);
> > + start = page_align_up(fiber->stack_overflow_wmark);
> > + madvise(start, end - start, MADV_DONTNEED);
> > + } else {
> > + start = page_align_up(fiber->stack_shrink_wmark);
> > + end = page_align_down(fiber->stack_overflow_wmark);
> > + madvise(start, end - start, MADV_DONTNEED);
> > + }
>
> Nit: you could move madvise() out of the if-else block.
indeed, thanks!
> > +
> > + if (!stack_has_wmark(fiber->stack_overflow_wmark)) {
> > + say_warn("stack usage is close to the limit of %zu bytes",
> > + (size_t)FIBER_STACK_SIZE_DEFAULT);
>
> IMO warning only when we are close to the limit isn't very useful.
> Let's keep track of the max stack size instead and print it whenever
> it's increased.
Could you please elaborate. I don't understand what you mean by
keep tracking of max stack size. You propose to remember somewhere
if this mark has been vanished?
> > + fiber->wmark_inpage_offset = ((rand() % 128) + 8) & ~7;
>
> Please define a constant for this.
ok
> > + fiber->stack_shrink_wmark -= 16 << 12;
>
> Ditto.
ok
> > @@ -927,8 +1090,12 @@ cord_create(struct cord *cord, const char *name)
> > /* Record stack extents */
> > tt_pthread_attr_getstack(cord->id, &cord->sched.stack,
> > &cord->sched.stack_size);
> > + cord->sched.stack_overflow_wmark = cord->sched.stack;
> > + cord->sched.stack_shrink_wmark = cord->sched.stack;
>
> I don't think we need to set the watermarks for the sched fiber,
> even if ASAN is on.
Won't they left unitialized then? The only reason I put nils here
is to force them have known values even if they are unused.
Cyrill
next prev parent reply other threads:[~2019-03-13 14:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-12 22:47 [PATCH v5 0/2] lib/core/fiber: Increase default stack size Cyrill Gorcunov
2019-03-12 22:47 ` [PATCH 1/3] " Cyrill Gorcunov
2019-03-13 13:42 ` Vladimir Davydov
2019-03-13 13:53 ` Cyrill Gorcunov
2019-03-13 14:13 ` Vladimir Davydov
2019-03-12 22:47 ` [PATCH 2/3] lib/core/fiber: Mark stack as unneeded on creation Cyrill Gorcunov
2019-03-12 22:47 ` [PATCH 3/3] lib/core/fiber: Put watermarks into stack to track its usage Cyrill Gorcunov
2019-03-13 13:52 ` Vladimir Davydov
2019-03-13 14:00 ` Cyrill Gorcunov [this message]
2019-03-13 14:17 ` Vladimir Davydov
2019-03-13 16:15 ` Cyrill Gorcunov
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=20190313140054.GO10420@uranus.lan \
--to=gorcunov@gmail.com \
--cc=tarantool-patches@freelists.org \
--cc=vdavydov.dev@gmail.com \
--subject='Re: [PATCH 3/3] lib/core/fiber: Put watermarks into stack to track its usage' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox