Swatantra-66 opened a new pull request, #22445:
URL: https://github.com/apache/nuttx/pull/22445
## Summary
Addresses Issue #20414
In fs/mqueue/Kconfig, CONFIG_FS_MQUEUE_NPOLLWAITERS currently defaults to 4,
which was originally introduced when poll support was added to message queues
(PR #2957).
Each POSIX message queue allocates an array of poll descriptors sized by
CONFIG_FS_MQUEUE_NPOLLWAITERS:
```c
struct mqueue_inode_s
{
...
FAR struct pollfd_s *fds[CONFIG_FS_MQUEUE_NPOLLWAITERS];
};
```
When mq_open() creates a message queue, struct mqueue_inode_s is dynamically
allocated from heap memory. In typical embedded and RTOS workloads, a message
queue has at most one reader and one writer waiting simultaneously on
poll/select/epoll events.
This change updates the default of CONFIG_FS_MQUEUE_NPOLLWAITERS from 4 to
2, aligning it with all other IPC and device poll waiter defaults across NuttX:
- SERIAL_NPOLLWAITERS=2 (PR #22228)
- DEV_PIPE_NPOLLWAITERS=2 (PR #22348)
- EVENT_FD_NPOLLWAITERS=2
- TIMER_FD_NPOLLWAITERS=2
- SIGNAL_FD_NPOLLWAITERS=2
- FS_NOTIFY_FD_POLLWAITERS=2
Applications requiring more than 2 concurrent poll waiters can still
configure CONFIG_FS_MQUEUE_NPOLLWAITERS to a larger value via Kconfig.
## Impact
- Is new feature added? No.
- User: None. Message queues save dynamic heap memory per allocated queue.
- Build: Zero defconfigs in the tree configure
CONFIG_FS_MQUEUE_NPOLLWAITERS, so no defconfig modifications are required.
- Memory: Saves 8 bytes heap memory per message queue on 32-bit platforms
(16 bytes on 64-bit platforms).
## Testing
### Before and After Comparison
| Configuration | Target Board | Before (master) | After (this patch) |
Memory Impact |
| :--- | :--- | :--- | :--- | :--- |
| DEFAULT_SMALL=y (32-bit) | stm32f103-minimum:nsh |
FS_MQUEUE_NPOLLWAITERS=4 | FS_MQUEUE_NPOLLWAITERS=2 | -8 B heap / queue |
| Standard (32-bit) | sam4s-xplained-pro:nsh | FS_MQUEUE_NPOLLWAITERS=4 |
FS_MQUEUE_NPOLLWAITERS=2 | -8 B heap / queue |
| Standard (64-bit) | generic 64-bit | FS_MQUEUE_NPOLLWAITERS=4 |
FS_MQUEUE_NPOLLWAITERS=2 | -16 B heap / queue |
### Verification Logs
Small profile configuration (stm32f103-minimum:nsh):
```
$ ./tools/configure.sh -l stm32f103-minimum:nsh
Loaded configuration '.config'
Configuration saved to '.config'
$ grep FS_MQUEUE_NPOLLWAITERS .config
CONFIG_FS_MQUEUE_NPOLLWAITERS=2
```
Standard profile configuration (sam4s-xplained-pro:nsh):
```
$ ./tools/configure.sh -l sam4s-xplained-pro:nsh
Loaded configuration '.config'
Configuration saved to '.config'
$ grep FS_MQUEUE_NPOLLWAITERS .config
CONFIG_FS_MQUEUE_NPOLLWAITERS=2
```
Code style check:
```
$ git diff --check
(clean, 0 warnings / errors)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]