From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Tue, 5 Mar 2019 11:20:29 +0300 From: Konstantin Osipov Subject: Re: [tarantool-patches] [rfc 3/4] core/fiber: Put static watermark into stack to track its usage Message-ID: <20190305082029.GL21955@chai> References: <20190302125524.279852704@gmail.com> <20190302130034.050488016@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190302130034.050488016@gmail.com> To: tarantool-patches@freelists.org Cc: gorcunov@gmail.com, vdavydov.dev@gmail.com List-ID: * Cyrill Gorcunov [19/03/03 23:25]: > We want to detect a situation where task in fiber is too eager for > stack and close to its exhausting. For this sake upon stack creation > we put 8 marks on last stack page with step of 128 bytes. Such params > allows us to fill ~1/4 of a page, which does seem reasonable but > we might change this params with time. > > Since the watermark position is permanent and some task is close > to stack limit we print about the situation once to not spam > a user much and stop putting the mark on recycling. > > Closes #3418 As a policy we write meaningful comments for every function, static or not, obvious or not. The idea of such a comment is to reflect the author's intent and technical trade-offs considered when designing a function. The comment should preferably be concise, however. > +/* > + * Random values generated with uuid. > + * Try to fit a cache line. I don't understand this comment. Since you're putting a poison-gap between each number, how could you possibly fit a cache line? > + */ > +static const uint64_t poison_pool[] = { > + 0x74f31d37285c4c37, 0xb10269a05bf10c29, > + 0x0994d845bd284e0f, 0x9ffd4f7129c184df, > + 0x357151e6711c4415, 0x8c5e5f41aafe6f28, > + 0x6917dd79e78049d5, 0xba61957c65ca2465, > +}; > + > +/* > + * We poison by 8 bytes as it natural for stack > + * step on x86-64. Also 128 byte gap between > + * poison values should cover a common cases. > + /** Stack watermark addr for overflow detection. */ > + void *stack_wmark_ofl; Generally we try to avoid abbreviations unless really necessary. Why not simply stack_overflow_watermark? > /** Coro stack size. */ > size_t stack_size; > /** Valgrind stack id. */ -- Konstantin Osipov, Moscow, Russia, +7 903 626 22 32 http://tarantool.io - www.twitter.com/kostja_osipov