You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/03/29 15:09:16 UTC

[incubator-nuttx-apps] branch master updated: system/libuv: Support specify stack size for worker thread

This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new ec15dc0  system/libuv: Support specify stack size for worker thread
ec15dc0 is described below

commit ec15dc0344e76681e5aae676ce64c9b61aa0b458
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Mon Mar 28 17:12:42 2022 +0800

    system/libuv: Support specify stack size for worker thread
    
    Signed-off-by: Huang Qi <hu...@xiaomi.com>
---
 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 f930185..fda609a 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, &params, 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 ba487bc..56f30bc 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 e8b3c46..717d491 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