From ec15dc0344e76681e5aae676ce64c9b61aa0b458 Mon Sep 17 00:00:00 2001 From: Huang Qi Date: Mon, 28 Mar 2022 17:12:42 +0800 Subject: [PATCH] system/libuv: Support specify stack size for worker thread Signed-off-by: Huang Qi --- system/libuv/0001-libuv-port-for-nuttx.patch | 32 ++++++++++++++++++-- system/libuv/Kconfig | 4 +++ system/libuv/Makefile | 1 + 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/system/libuv/0001-libuv-port-for-nuttx.patch b/system/libuv/0001-libuv-port-for-nuttx.patch index f930185dc..fda609a86 100644 --- a/system/libuv/0001-libuv-port-for-nuttx.patch +++ b/system/libuv/0001-libuv-port-for-nuttx.patch @@ -59,7 +59,7 @@ index e75f77de..feef5a44 100644 #elif defined(_AIX) || defined(__QNX__) rc = uv__random_readpath("/dev/random", buf, buflen); diff --git a/src/threadpool.c b/src/threadpool.c -index 869ae95f..8fabeba5 100644 +index 869ae95f..73077ec6 100644 --- a/src/threadpool.c +++ b/src/threadpool.c @@ -20,6 +20,7 @@ @@ -169,7 +169,24 @@ index 869ae95f..8fabeba5 100644 } -@@ -212,7 +217,7 @@ static void init_threads(void) { +@@ -188,6 +193,16 @@ static void init_threads(void) { + const char* val; + uv_sem_t sem; + ++ const uv_thread_options_t params = { ++#ifdef DEF_THREADPOOL_STACKSIZE ++ UV_THREAD_HAS_STACK_SIZE, ++ DEF_THREADPOOL_STACKSIZE ++#else ++ UV_THREAD_NO_FLAGS, ++ 0 ++#endif ++ }; ++ + nthreads = ARRAY_SIZE(default_threads); + val = getenv("UV_THREADPOOL_SIZE"); + if (val != NULL) +@@ -212,7 +227,7 @@ static void init_threads(void) { if (uv_mutex_init(&mutex)) abort(); @@ -178,7 +195,16 @@ index 869ae95f..8fabeba5 100644 QUEUE_INIT(&slow_io_pending_wq); QUEUE_INIT(&run_slow_work_message); -@@ -230,14 +235,6 @@ static void init_threads(void) { +@@ -220,7 +235,7 @@ static void init_threads(void) { + abort(); + + for (i = 0; i < nthreads; i++) +- if (uv_thread_create(threads + i, worker, &sem)) ++ if (uv_thread_create_ex(threads + i, ¶ms, worker, &sem)) + abort(); + + for (i = 0; i < nthreads; i++) +@@ -230,14 +245,6 @@ static void init_threads(void) { } diff --git a/system/libuv/Kconfig b/system/libuv/Kconfig index ba487bc2b..56f30bc90 100644 --- a/system/libuv/Kconfig +++ b/system/libuv/Kconfig @@ -16,6 +16,10 @@ config LIBUV_THREADPOOL_SIZE int "libuv default thread pool size" default 1 +config LIBUV_THREAD_STACKSIZE + int "libuv worker thread stack size" + default PTHREAD_STACK_DEFAULT + choice prompt "libuv utils" default LIBUV_UTILS_NONE diff --git a/system/libuv/Makefile b/system/libuv/Makefile index e8b3c4688..717d491c0 100644 --- a/system/libuv/Makefile +++ b/system/libuv/Makefile @@ -51,6 +51,7 @@ CFLAGS += -I$(LIBUV_UNPACK)/src/unix CFLAGS += -I$(LIBUV_UNPACK)/test CFLAGS += -Wno-shadow CFLAGS += -DDEF_THREADPOOL_SIZE=CONFIG_LIBUV_THREADPOOL_SIZE +CFLAGS += -DDEF_THREADPOOL_STACKSIZE=CONFIG_LIBUV_THREAD_STACKSIZE VPATH += $(LIBUV_UNPACK)/src VPATH += $(LIBUV_UNPACK)/src/unix