This is an automated email from the ASF dual-hosted git repository.
GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 18d5513ffef sched: default NFILE_DESCRIPTORS_PER_BLOCK to 4 on
DEFAULT_SMALL
18d5513ffef is described below
commit 18d5513ffef4a2e93c1bb2a218444e7ea11148c3
Author: Swatantra Yadav <[email protected]>
AuthorDate: Thu Nov 26 22:19:30 2026 +0530
sched: default NFILE_DESCRIPTORS_PER_BLOCK to 4 on DEFAULT_SMALL
In the NuttX VFS implementation, file descriptors are allocated in chunks
of CONFIG_NFILE_DESCRIPTORS_PER_BLOCK. The initial block is statically
embedded in struct fdlist (fl_prefds) inside each task group
(struct task_group_s) to avoid heap allocation overhead during task creation
and standard I/O initialization.
Previously, NFILE_DESCRIPTORS_PER_BLOCK defaulted unconditionally to 8,
unlike other scheduler pre-allocation parameters (SEM_PREALLOCHOLDERS,
SIG_PREALLOC_IRQ_ACTIONS, PREALLOC_MQ_MSGS, PREALLOC_TIMERS,
PREALLOC_IRQCHAIN) which scale down to 4 when DEFAULT_SMALL is enabled.
Defaulting NFILE_DESCRIPTORS_PER_BLOCK to 4 on DEFAULT_SMALL targets
reduces the preallocated descriptor table by 4 entries, saving 32 bytes of
SRAM per active task group on 32-bit architectures and 64 bytes on 64-bit
architectures. Standard POSIX streams (stdin 0, stdout 1, stderr 2) plus one
additional descriptor remain available without heap overhead; opening
further descriptors continues to extend dynamically in blocks of 4 via
fdlist_extend().
Also remove redundant CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4 settings from 11
board defconfigs (10 AVR targets and stm32vldiscovery:nsh) that now inherit
the default, and update documentation in tasks_vs_threads.rst.
Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Swatantra Yadav <[email protected]>
---
Documentation/os/scheduling/tasks_vs_threads.rst | 4 ++--
boards/arm/stm32f1/stm32vldiscovery/configs/nsh/defconfig | 1 -
boards/avr/at90usb/micropendous3/configs/hello/defconfig | 1 -
boards/avr/at90usb/teensy-2.0/configs/hello/defconfig | 1 -
boards/avr/atmega/amber/configs/hello/defconfig | 1 -
boards/avr/atmega/arduino-mega2560/configs/hello/defconfig | 1 -
boards/avr/atmega/arduino-mega2560/configs/nsh/defconfig | 1 -
boards/avr/atmega/elegoo-mega2560r3/configs/nsh/defconfig | 1 -
boards/avr/atmega/mega1284p-xplained/configs/hello/defconfig | 1 -
boards/avr/atmega/moteino-mega/configs/hello/defconfig | 1 -
boards/avr/avrdx/breadxavr/configs/nsh/defconfig | 1 -
boards/avr/avrdx/breadxavr/configs/ws2812/defconfig | 1 -
sched/Kconfig | 3 ++-
13 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/Documentation/os/scheduling/tasks_vs_threads.rst
b/Documentation/os/scheduling/tasks_vs_threads.rst
index 71bd38f989c..4ed19f66309 100644
--- a/Documentation/os/scheduling/tasks_vs_threads.rst
+++ b/Documentation/os/scheduling/tasks_vs_threads.rst
@@ -100,8 +100,8 @@ The memory cost of a task is higher because it includes
most of the costs
of a pthread plus the cost of the task group structure.
The cost of the task group structure varies with such things as:
-* The number of file descriptors you have configured (controlled by
- ``CONFIG_NFILE_DESCRIPTORS``),
+* The number of pre-allocated file descriptors per block (controlled by
+ ``CONFIG_NFILE_DESCRIPTORS_PER_BLOCK``),
* The number of streams that you have configured for C buffered I/O
(controlled by ``CONFIG_NFILE_STREAMS``),
* The size of the I/O buffer configured for for each stream
diff --git a/boards/arm/stm32f1/stm32vldiscovery/configs/nsh/defconfig
b/boards/arm/stm32f1/stm32vldiscovery/configs/nsh/defconfig
index dc5b5c596e9..d05bd9f269e 100644
--- a/boards/arm/stm32f1/stm32vldiscovery/configs/nsh/defconfig
+++ b/boards/arm/stm32f1/stm32vldiscovery/configs/nsh/defconfig
@@ -36,7 +36,6 @@ CONFIG_IDLETHREAD_STACKSIZE=128
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=768
CONFIG_INTELHEX_BINARY=y
-CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_PTHREAD_STACK_DEFAULT=128
CONFIG_PTHREAD_STACK_MIN=128
diff --git a/boards/avr/at90usb/micropendous3/configs/hello/defconfig
b/boards/avr/at90usb/micropendous3/configs/hello/defconfig
index 3b871967ed2..cff42679829 100644
--- a/boards/avr/at90usb/micropendous3/configs/hello/defconfig
+++ b/boards/avr/at90usb/micropendous3/configs/hello/defconfig
@@ -25,7 +25,6 @@ CONFIG_IDLETHREAD_STACKSIZE=512
CONFIG_INIT_ENTRYPOINT="hello_main"
CONFIG_INIT_STACKSIZE=512
CONFIG_INTELHEX_BINARY=y
-CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
CONFIG_NUNGET_CHARS=0
CONFIG_PTHREAD_STACK_DEFAULT=1024
CONFIG_RAM_SIZE=4096
diff --git a/boards/avr/at90usb/teensy-2.0/configs/hello/defconfig
b/boards/avr/at90usb/teensy-2.0/configs/hello/defconfig
index 964c49a5bb8..6621c77dcfa 100644
--- a/boards/avr/at90usb/teensy-2.0/configs/hello/defconfig
+++ b/boards/avr/at90usb/teensy-2.0/configs/hello/defconfig
@@ -25,7 +25,6 @@ CONFIG_IDLETHREAD_STACKSIZE=512
CONFIG_INIT_ENTRYPOINT="hello_main"
CONFIG_INIT_STACKSIZE=512
CONFIG_INTELHEX_BINARY=y
-CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
CONFIG_NUNGET_CHARS=0
CONFIG_PTHREAD_STACK_DEFAULT=1024
CONFIG_RAM_SIZE=8192
diff --git a/boards/avr/atmega/amber/configs/hello/defconfig
b/boards/avr/atmega/amber/configs/hello/defconfig
index 2b8059121c6..c0d0a96cd7b 100644
--- a/boards/avr/atmega/amber/configs/hello/defconfig
+++ b/boards/avr/atmega/amber/configs/hello/defconfig
@@ -25,7 +25,6 @@ CONFIG_IDLETHREAD_STACKSIZE=512
CONFIG_INIT_ENTRYPOINT="hello_main"
CONFIG_INIT_STACKSIZE=512
CONFIG_INTELHEX_BINARY=y
-CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
CONFIG_NUNGET_CHARS=0
CONFIG_PTHREAD_STACK_DEFAULT=1024
CONFIG_RAM_SIZE=4096
diff --git a/boards/avr/atmega/arduino-mega2560/configs/hello/defconfig
b/boards/avr/atmega/arduino-mega2560/configs/hello/defconfig
index c5173193e2a..6beb0da49d3 100644
--- a/boards/avr/atmega/arduino-mega2560/configs/hello/defconfig
+++ b/boards/avr/atmega/arduino-mega2560/configs/hello/defconfig
@@ -27,7 +27,6 @@ CONFIG_IDLETHREAD_STACKSIZE=128
CONFIG_INIT_ENTRYPOINT="hello_main"
CONFIG_INIT_STACKSIZE=128
CONFIG_INTELHEX_BINARY=y
-CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
CONFIG_NUNGET_CHARS=0
CONFIG_PTHREAD_STACK_DEFAULT=128
CONFIG_PTHREAD_STACK_MIN=128
diff --git a/boards/avr/atmega/arduino-mega2560/configs/nsh/defconfig
b/boards/avr/atmega/arduino-mega2560/configs/nsh/defconfig
index f7a5c808f4e..4946ae1b951 100644
--- a/boards/avr/atmega/arduino-mega2560/configs/nsh/defconfig
+++ b/boards/avr/atmega/arduino-mega2560/configs/nsh/defconfig
@@ -24,7 +24,6 @@ CONFIG_DISABLE_MOUNTPOINT=y
CONFIG_IDLETHREAD_STACKSIZE=128
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=768
-CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
CONFIG_NUNGET_CHARS=0
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=768
CONFIG_PTHREAD_STACK_DEFAULT=128
diff --git a/boards/avr/atmega/elegoo-mega2560r3/configs/nsh/defconfig
b/boards/avr/atmega/elegoo-mega2560r3/configs/nsh/defconfig
index 2d690acf672..0318709938b 100644
--- a/boards/avr/atmega/elegoo-mega2560r3/configs/nsh/defconfig
+++ b/boards/avr/atmega/elegoo-mega2560r3/configs/nsh/defconfig
@@ -25,7 +25,6 @@ CONFIG_IDLETHREAD_STACKSIZE=128
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=768
CONFIG_INTELHEX_BINARY=y
-CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
CONFIG_NUNGET_CHARS=0
CONFIG_POSIX_SPAWN_DEFAULT_STACKSIZE=768
CONFIG_PTHREAD_STACK_DEFAULT=128
diff --git a/boards/avr/atmega/mega1284p-xplained/configs/hello/defconfig
b/boards/avr/atmega/mega1284p-xplained/configs/hello/defconfig
index 89ca812f6ca..5c233f4cbec 100644
--- a/boards/avr/atmega/mega1284p-xplained/configs/hello/defconfig
+++ b/boards/avr/atmega/mega1284p-xplained/configs/hello/defconfig
@@ -25,7 +25,6 @@ CONFIG_IDLETHREAD_STACKSIZE=512
CONFIG_INIT_ENTRYPOINT="hello_main"
CONFIG_INIT_STACKSIZE=512
CONFIG_INTELHEX_BINARY=y
-CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
CONFIG_NUNGET_CHARS=0
CONFIG_PTHREAD_STACK_DEFAULT=512
CONFIG_RAM_SIZE=16384
diff --git a/boards/avr/atmega/moteino-mega/configs/hello/defconfig
b/boards/avr/atmega/moteino-mega/configs/hello/defconfig
index ceeffb1d043..70785278bd0 100644
--- a/boards/avr/atmega/moteino-mega/configs/hello/defconfig
+++ b/boards/avr/atmega/moteino-mega/configs/hello/defconfig
@@ -25,7 +25,6 @@ CONFIG_IDLETHREAD_STACKSIZE=512
CONFIG_INIT_ENTRYPOINT="hello_main"
CONFIG_INIT_STACKSIZE=512
CONFIG_INTELHEX_BINARY=y
-CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
CONFIG_NUNGET_CHARS=0
CONFIG_PTHREAD_STACK_DEFAULT=512
CONFIG_RAM_SIZE=16384
diff --git a/boards/avr/avrdx/breadxavr/configs/nsh/defconfig
b/boards/avr/avrdx/breadxavr/configs/nsh/defconfig
index 43fd67c7af2..10f6044c890 100644
--- a/boards/avr/avrdx/breadxavr/configs/nsh/defconfig
+++ b/boards/avr/avrdx/breadxavr/configs/nsh/defconfig
@@ -20,7 +20,6 @@ CONFIG_IDLETHREAD_STACKSIZE=512
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=512
CONFIG_INTELHEX_BINARY=y
-CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
CONFIG_NUNGET_CHARS=0
CONFIG_PTHREAD_STACK_DEFAULT=1024
CONFIG_RAM_SIZE=16384
diff --git a/boards/avr/avrdx/breadxavr/configs/ws2812/defconfig
b/boards/avr/avrdx/breadxavr/configs/ws2812/defconfig
index 088ca1c007d..3e9f2468d45 100644
--- a/boards/avr/avrdx/breadxavr/configs/ws2812/defconfig
+++ b/boards/avr/avrdx/breadxavr/configs/ws2812/defconfig
@@ -35,7 +35,6 @@ CONFIG_IDLETHREAD_STACKSIZE=512
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_INIT_STACKSIZE=512
CONFIG_INTELHEX_BINARY=y
-CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=4
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NUNGET_CHARS=0
CONFIG_PTHREAD_STACK_DEFAULT=1024
diff --git a/sched/Kconfig b/sched/Kconfig
index 92a6d061abd..f3686ae84ce 100644
--- a/sched/Kconfig
+++ b/sched/Kconfig
@@ -1603,7 +1603,8 @@ config FDCLONE_STDIO
config NFILE_DESCRIPTORS_PER_BLOCK
int "The number of file descriptors per block"
- default 8
+ default 4 if DEFAULT_SMALL
+ default 8 if !DEFAULT_SMALL
range 3 99999
---help---
The number of file descriptors per block(one for each open)