From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Konstantin Osipov <kostja@tarantool.org>
Cc: tarantool-patches@freelists.org, vdavydov.dev@gmail.com
Subject: Re: [tarantool-patches] [rfc 3/4] core/fiber: Put static watermark into stack to track its usage
Date: Tue, 5 Mar 2019 22:17:55 +0300 [thread overview]
Message-ID: <20190305191755.GN13301@uranus.lan> (raw)
In-Reply-To: <20190305081013.GK21955@chai>
On Tue, Mar 05, 2019 at 11:10:13AM +0300, Konstantin Osipov wrote:
> * Cyrill Gorcunov <gorcunov@gmail.com> [19/03/03 23:25]:
> > +/*
> > + * Random values generated with uuid.
> > + * Try to fit a cache line.
> > + */
> > +static const uint64_t poison_pool[] = {
> > + 0x74f31d37285c4c37, 0xb10269a05bf10c29,
> > + 0x0994d845bd284e0f, 0x9ffd4f7129c184df,
> > + 0x357151e6711c4415, 0x8c5e5f41aafe6f28,
> > + 0x6917dd79e78049d5, 0xba61957c65ca2465,
> > +};
>
> With randomness incorporated into each fiber I think we can reduce
> the poison pool to 4 8-byte integers or even less.
Kostja, you know, randoms values is a bad idea. For example I just got
[cyrill@uranus tarantool.git] ./src/tarantool
poison_gaps[0] = 736
poison_gaps[1] = 952
poison_gaps[2] = 976
poison_gaps[3] = 2016
Tarantool 2.1.1-360-g6666db8d5
type 'help' for interactive help
So the first gap almost close to 1K value :( Which means we won't detect
the page dirtifying while someone is putting values on start of the
page and even more, we're not controlling what exactly random values
come to us. I think putting poisons at 128 byte bound a way better
The pretty draf code I used is
---
static void
stack_poison_gaps_init(void)
{
size_t i, j, m = page_size / 2;
uint16_t v;
assert(POISON_SIZE > 1);
/*
* Fill the gaps with random (8 byte aligned)
* values in a half page range. This should decrease
* probability that someone manage to sneak out
* the poison values.
*/
random_bytes((void *)poison_gaps, sizeof(poison_gaps));
for (i = 0; i < POISON_SIZE; i++) {
v = poison_gaps[i] % m;
poison_gaps[i] = (v + 8) & ~7;
}
for (i = 0; i < POISON_SIZE; i++) {
v = poison_gaps[i], j = i;
while (j > 0 && poison_gaps[j-1] > v)
poison_gaps[j] = poison_gaps[j-1], j--;
poison_gaps[j] = v;
}
for (i = 0; i < POISON_SIZE; i++) {
say_info("poison_gaps[%d] = %d", i, (unsigned)poison_gaps[i]);
if (i == 0)
continue;
assert(poison_gaps[i-1] != poison_gaps[i]);
}
}
---
next prev parent reply other threads:[~2019-03-05 19:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-02 12:55 [rfc 0/4] fiber/stack: Increase stack size and shrink rss usage Cyrill Gorcunov
2019-03-02 12:55 ` [rfc 1/4] core/fiber: Increase default stack size Cyrill Gorcunov
2019-03-02 12:55 ` [rfc 2/4] core/fiber: Mark stack as unneeded on creation Cyrill Gorcunov
2019-03-02 12:55 ` [rfc 3/4] core/fiber: Put static watermark into stack to track its usage Cyrill Gorcunov
2019-03-05 8:08 ` [tarantool-patches] " Konstantin Osipov
2019-03-05 8:17 ` Cyrill Gorcunov
2019-03-05 8:10 ` Konstantin Osipov
2019-03-05 8:14 ` Cyrill Gorcunov
2019-03-05 19:17 ` Cyrill Gorcunov [this message]
2019-03-05 8:20 ` Konstantin Osipov
2019-03-05 8:27 ` Cyrill Gorcunov
2019-03-02 12:55 ` [rfc 4/4] core/fiber: Shrink stack when recycling Cyrill Gorcunov
2019-03-05 8:30 ` [tarantool-patches] " Konstantin Osipov
2019-03-05 8:41 ` Cyrill Gorcunov
2019-03-05 9:32 ` [tarantool-patches] " Konstantin Osipov
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=20190305191755.GN13301@uranus.lan \
--to=gorcunov@gmail.com \
--cc=kostja@tarantool.org \
--cc=tarantool-patches@freelists.org \
--cc=vdavydov.dev@gmail.com \
--subject='Re: [tarantool-patches] [rfc 3/4] core/fiber: Put static watermark 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