From: Cyrill Gorcunov <gorcunov@gmail.com>
To: tml <tarantool-patches@freelists.org>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>,
Cyrill Gorcunov <gorcunov@gmail.com>
Subject: [PATCH 1/2] lib/core/fiber: Rename stack_direction to stack_growsdown
Date: Tue, 19 Mar 2019 22:38:44 +0300 [thread overview]
Message-ID: <20190319193845.31221-2-gorcunov@gmail.com> (raw)
In-Reply-To: <20190319193845.31221-1-gorcunov@gmail.com>
Since growsdown (or growsup) is more clear and common name.
---
src/lib/core/fiber.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c
index c55b3ab39..922a0bfe8 100644
--- a/src/lib/core/fiber.c
+++ b/src/lib/core/fiber.c
@@ -105,7 +105,7 @@ __thread struct cord *cord_ptr = NULL;
pthread_t main_thread_id;
static size_t page_size;
-static int stack_direction;
+static bool stack_growsdown;
enum {
/* The minimum allowable fiber stack size in bytes */
@@ -808,7 +808,7 @@ fiber_stack_recycle(struct fiber *fiber)
* it anyway.
*/
void *start, *end;
- if (stack_direction < 0) {
+ if (stack_growsdown) {
start = fiber->stack;
end = page_align_down(fiber->stack_watermark);
} else {
@@ -842,7 +842,7 @@ fiber_stack_watermark_create(struct fiber *fiber)
* we put the first mark at a random position.
*/
size_t offset = rand() % POISON_OFF * sizeof(poison_pool[0]);
- if (stack_direction < 0) {
+ if (stack_growsdown) {
fiber->stack_watermark = fiber->stack + fiber->stack_size;
fiber->stack_watermark -= FIBER_STACK_SIZE_WATERMARK;
fiber->stack_watermark += offset;
@@ -881,7 +881,7 @@ fiber_stack_create(struct fiber *fiber, size_t stack_size)
}
void *guard;
/* Adjust begin and size for stack memory chunk. */
- if (stack_direction < 0) {
+ if (stack_growsdown) {
/*
* A stack grows down. First page after begin of a
* stack memory chunk should be protected and memory
@@ -922,7 +922,7 @@ fiber_stack_destroy(struct fiber *fiber, struct slab_cache *slabc)
ASAN_UNPOISON_MEMORY_REGION(fiber->stack, fiber->stack_size);
#endif
void *guard;
- if (stack_direction < 0)
+ if (stack_growsdown)
guard = page_align_down(fiber->stack - page_size);
else
guard = page_align_up(fiber->stack + fiber->stack_size);
@@ -1384,16 +1384,16 @@ cord_slab_cache(void)
}
static NOINLINE int
-check_stack_direction(void *prev_stack_frame)
+is_stack_growsdown(void *prev_stack_frame)
{
- return __builtin_frame_address(0) < prev_stack_frame ? -1: 1;
+ return __builtin_frame_address(0) < prev_stack_frame ? true : false;
}
void
fiber_init(int (*invoke)(fiber_func f, va_list ap))
{
page_size = sysconf(_SC_PAGESIZE);
- stack_direction = check_stack_direction(__builtin_frame_address(0));
+ stack_growsdown = is_stack_growsdown(__builtin_frame_address(0));
fiber_invoke = invoke;
main_thread_id = pthread_self();
main_cord.loop = ev_default_loop(EVFLAG_AUTO | EVFLAG_ALLOCFD);
--
2.20.1
next prev parent reply other threads:[~2019-03-19 19:38 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-19 19:38 [RFC 0/2] lib/core/fiber: Allow to extend stack size via env variable Cyrill Gorcunov
2019-03-19 19:38 ` Cyrill Gorcunov [this message]
2019-03-27 9:35 ` [PATCH 1/2] lib/core/fiber: Rename stack_direction to stack_growsdown Vladimir Davydov
2019-03-27 9:48 ` Cyrill Gorcunov
2019-03-27 10:20 ` Vladimir Davydov
2019-03-27 10:30 ` Cyrill Gorcunov
2019-03-19 19:38 ` [PATCH 2/2] lib/core/fiber: Allow to extend default stack size Cyrill Gorcunov
2019-03-27 9:35 ` Vladimir Davydov
2019-03-27 9:46 ` Cyrill Gorcunov
2019-03-27 10:15 ` Vladimir Davydov
2019-03-27 10:23 ` Cyrill Gorcunov
2019-04-01 17:41 ` Cyrill Gorcunov
2019-04-01 18:58 ` Konstantin Osipov
2019-04-01 19:19 ` Cyrill Gorcunov
2019-04-01 20:51 ` Konstantin Osipov
2019-04-01 22:05 ` Cyrill Gorcunov
2019-04-02 7:14 ` Konstantin Osipov
2019-04-02 8:09 ` 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=20190319193845.31221-2-gorcunov@gmail.com \
--to=gorcunov@gmail.com \
--cc=tarantool-patches@freelists.org \
--cc=vdavydov.dev@gmail.com \
--subject='Re: [PATCH 1/2] lib/core/fiber: Rename stack_direction to stack_growsdown' \
/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