From 8ef99c536b4b7b028e3cf69c712d1ca56b955fdb Mon Sep 17 00:00:00 2001 From: Swatantra Yadav Date: Mon, 23 Nov 2026 23:20:17 +0530 Subject: [PATCH] drivers/serial: change default SERIAL_NPOLLWAITERS to 2 Change CONFIG_SERIAL_NPOLLWAITERS default from 4 to 2 across all configurations. Most serial applications only poll stdin for POLLIN and do not require 4 simultaneous poll waiter slots. Reducing CONFIG_SERIAL_NPOLLWAITERS from 4 to 2 eliminates two pollfd pointer entries from struct uart_dev_s, saving 8 bytes of RAM per allocated serial port on 32-bit architectures (16 bytes on 64-bit architectures), and 16 bytes total on stm32f103-minimum:nsh. Also refresh existing board defconfigs where CONFIG_SERIAL_NPOLLWAITERS=2 was explicitly set to avoid defconfig normalization warnings in CI. Assisted-by: Claude:claude-opus-4.6 Signed-off-by: Swatantra Yadav --- Documentation/os/drivers/character/serial.rst | 6 ++++++ boards/arm64/imx9/imx93-evk/configs/knsh/defconfig | 1 - boards/arm64/imx9/imx93-evk/configs/koptee/defconfig | 1 - boards/risc-v/mpfs/icicle/configs/hwtest/defconfig | 1 - boards/risc-v/mpfs/icicle/configs/knsh/defconfig | 1 - boards/risc-v/mpfs/icicle/configs/nsh/defconfig | 1 - boards/risc-v/mpfs/icicle/configs/opensbi/defconfig | 1 - boards/risc-v/mpfs/icicle/configs/pnsh/defconfig | 1 - boards/risc-v/mpfs/icicle/configs/rpmsg-sbi/defconfig | 1 - boards/risc-v/mpfs/m100pfsevp/configs/nsh/defconfig | 1 - .../esp32/esp32-devkitc/configs/wamr_wasi_debug/defconfig | 1 - drivers/serial/Kconfig | 4 ++-- include/nuttx/serial/serial.h | 2 +- 13 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Documentation/os/drivers/character/serial.rst b/Documentation/os/drivers/character/serial.rst index 4dedaa1cbaa81..d344b5fb05f3f 100644 --- a/Documentation/os/drivers/character/serial.rst +++ b/Documentation/os/drivers/character/serial.rst @@ -92,6 +92,12 @@ Serial Device Drivers set to ``ENOTTY``), reducing code size on memory-constrained targets. +- **Poll waiters**. ``CONFIG_SERIAL_NPOLLWAITERS`` sets the maximum + number of threads that can wait simultaneously for ``POLLIN`` or + ``POLLOUT`` events on a serial device. The default is 2, + reducing the ``struct uart_dev_s`` waiter array size and saving + RAM across all platforms. + - **User Access**. Serial drivers are, ultimately, normal `character drivers <#chardrivers>`__ and are accessed as other character drivers. diff --git a/boards/arm64/imx9/imx93-evk/configs/knsh/defconfig b/boards/arm64/imx9/imx93-evk/configs/knsh/defconfig index e07a750eff664..4ef8235c391d4 100644 --- a/boards/arm64/imx9/imx93-evk/configs/knsh/defconfig +++ b/boards/arm64/imx9/imx93-evk/configs/knsh/defconfig @@ -148,7 +148,6 @@ CONFIG_SCHED_LPWORKSTACKSIZE=4096 CONFIG_SCHED_WAITPID=y CONFIG_SDIO_BLOCKSETUP=y CONFIG_SEM_PREALLOCHOLDERS=32 -CONFIG_SERIAL_NPOLLWAITERS=2 CONFIG_SERIAL_TERMIOS=y CONFIG_SIG_DEFAULT=y CONFIG_SIG_SIGALRM_ACTION=y diff --git a/boards/arm64/imx9/imx93-evk/configs/koptee/defconfig b/boards/arm64/imx9/imx93-evk/configs/koptee/defconfig index b5641a53c42e2..c13fdc3d7e734 100644 --- a/boards/arm64/imx9/imx93-evk/configs/koptee/defconfig +++ b/boards/arm64/imx9/imx93-evk/configs/koptee/defconfig @@ -153,7 +153,6 @@ CONFIG_SCHED_LPWORKSTACKSIZE=4096 CONFIG_SCHED_WAITPID=y CONFIG_SDIO_BLOCKSETUP=y CONFIG_SEM_PREALLOCHOLDERS=32 -CONFIG_SERIAL_NPOLLWAITERS=2 CONFIG_SERIAL_TERMIOS=y CONFIG_SIG_DEFAULT=y CONFIG_SIG_SIGALRM_ACTION=y diff --git a/boards/risc-v/mpfs/icicle/configs/hwtest/defconfig b/boards/risc-v/mpfs/icicle/configs/hwtest/defconfig index 83a0ad53bfe5d..43c067f6b39b1 100644 --- a/boards/risc-v/mpfs/icicle/configs/hwtest/defconfig +++ b/boards/risc-v/mpfs/icicle/configs/hwtest/defconfig @@ -100,7 +100,6 @@ CONFIG_RR_INTERVAL=200 CONFIG_SCHED_HPWORK=y CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y -CONFIG_SERIAL_NPOLLWAITERS=2 CONFIG_SPI=y CONFIG_SPI_CS_CONTROL=y CONFIG_SPI_DRIVER=y diff --git a/boards/risc-v/mpfs/icicle/configs/knsh/defconfig b/boards/risc-v/mpfs/icicle/configs/knsh/defconfig index a4950cf03433f..b947dbc7f9ea3 100644 --- a/boards/risc-v/mpfs/icicle/configs/knsh/defconfig +++ b/boards/risc-v/mpfs/icicle/configs/knsh/defconfig @@ -91,7 +91,6 @@ CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_HPWORK=y CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y -CONFIG_SERIAL_NPOLLWAITERS=2 CONFIG_STACK_COLORATION=y CONFIG_START_MONTH=4 CONFIG_START_YEAR=2021 diff --git a/boards/risc-v/mpfs/icicle/configs/nsh/defconfig b/boards/risc-v/mpfs/icicle/configs/nsh/defconfig index 2be999dccb573..f509bd927c6a6 100644 --- a/boards/risc-v/mpfs/icicle/configs/nsh/defconfig +++ b/boards/risc-v/mpfs/icicle/configs/nsh/defconfig @@ -56,7 +56,6 @@ CONFIG_RR_INTERVAL=200 CONFIG_SCHED_HPWORK=y CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y -CONFIG_SERIAL_NPOLLWAITERS=2 CONFIG_STACK_COLORATION=y CONFIG_START_MONTH=4 CONFIG_START_YEAR=2021 diff --git a/boards/risc-v/mpfs/icicle/configs/opensbi/defconfig b/boards/risc-v/mpfs/icicle/configs/opensbi/defconfig index 4157f76c3778e..2f345ae8a0241 100644 --- a/boards/risc-v/mpfs/icicle/configs/opensbi/defconfig +++ b/boards/risc-v/mpfs/icicle/configs/opensbi/defconfig @@ -55,7 +55,6 @@ CONFIG_RR_INTERVAL=200 CONFIG_SCHED_HPWORK=y CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y -CONFIG_SERIAL_NPOLLWAITERS=2 CONFIG_STACK_COLORATION=y CONFIG_START_MONTH=4 CONFIG_START_YEAR=2021 diff --git a/boards/risc-v/mpfs/icicle/configs/pnsh/defconfig b/boards/risc-v/mpfs/icicle/configs/pnsh/defconfig index 0547f894477d3..da5e99311438a 100644 --- a/boards/risc-v/mpfs/icicle/configs/pnsh/defconfig +++ b/boards/risc-v/mpfs/icicle/configs/pnsh/defconfig @@ -63,7 +63,6 @@ CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_HPWORK=y CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y -CONFIG_SERIAL_NPOLLWAITERS=2 CONFIG_STACK_COLORATION=y CONFIG_START_MONTH=4 CONFIG_START_YEAR=2021 diff --git a/boards/risc-v/mpfs/icicle/configs/rpmsg-sbi/defconfig b/boards/risc-v/mpfs/icicle/configs/rpmsg-sbi/defconfig index 5f82b5ca4662c..c90549d7e79ad 100644 --- a/boards/risc-v/mpfs/icicle/configs/rpmsg-sbi/defconfig +++ b/boards/risc-v/mpfs/icicle/configs/rpmsg-sbi/defconfig @@ -64,7 +64,6 @@ CONFIG_RR_INTERVAL=200 CONFIG_SCHED_HPWORK=y CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y -CONFIG_SERIAL_NPOLLWAITERS=2 CONFIG_STACK_COLORATION=y CONFIG_START_MONTH=4 CONFIG_START_YEAR=2021 diff --git a/boards/risc-v/mpfs/m100pfsevp/configs/nsh/defconfig b/boards/risc-v/mpfs/m100pfsevp/configs/nsh/defconfig index c395a2758b623..ddc80066c3977 100644 --- a/boards/risc-v/mpfs/m100pfsevp/configs/nsh/defconfig +++ b/boards/risc-v/mpfs/m100pfsevp/configs/nsh/defconfig @@ -55,7 +55,6 @@ CONFIG_RR_INTERVAL=200 CONFIG_SCHED_HPWORK=y CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y -CONFIG_SERIAL_NPOLLWAITERS=2 CONFIG_STACK_COLORATION=y CONFIG_START_MONTH=4 CONFIG_START_YEAR=2021 diff --git a/boards/xtensa/esp32/esp32-devkitc/configs/wamr_wasi_debug/defconfig b/boards/xtensa/esp32/esp32-devkitc/configs/wamr_wasi_debug/defconfig index 75ec225f840b8..a4487f3c7406a 100644 --- a/boards/xtensa/esp32/esp32-devkitc/configs/wamr_wasi_debug/defconfig +++ b/boards/xtensa/esp32/esp32-devkitc/configs/wamr_wasi_debug/defconfig @@ -100,7 +100,6 @@ CONFIG_SCHED_HPWORK=y CONFIG_SCHED_HPWORKSTACKSIZE=2048 CONFIG_SCHED_LPWORK=y CONFIG_SCHED_WAITPID=y -CONFIG_SERIAL_NPOLLWAITERS=2 CONFIG_SIG_DEFAULT=y CONFIG_SPI=y CONFIG_START_DAY=6 diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index bb817dc99c4ee..a8adf20275772 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -254,10 +254,10 @@ config STANDARD_SERIAL config SERIAL_NPOLLWAITERS int "Number of poll threads" - default 4 + default 2 ---help--- Maximum number of threads than can be waiting for POLL events. - Default: 4 + Default: 2 config SERIAL_IFLOWCONTROL bool diff --git a/include/nuttx/serial/serial.h b/include/nuttx/serial/serial.h index ff532a183d793..c58cf57dac6cc 100644 --- a/include/nuttx/serial/serial.h +++ b/include/nuttx/serial/serial.h @@ -46,7 +46,7 @@ /* Maximum number of threads than can be waiting for POLL events */ #ifndef CONFIG_SERIAL_NPOLLWAITERS -# define CONFIG_SERIAL_NPOLLWAITERS 4 +# define CONFIG_SERIAL_NPOLLWAITERS 2 #endif /* RX flow control */