Skip to content

Conversation

@maribu
Copy link
Member

@maribu maribu commented Dec 8, 2025

Contribution description

This adds a mechanism for modules to declare requirements on the thread stack size in their Makefile.dep and let the build system then override the default stack size, if any requirements are declared.

The motivation is to allow multiple modules to have special requirements without causing conflicts, as just adding the following to their Makefile.include would do:

CFLAGS += -DEVENT_THREAD_MEDIUM_STACKSIZE=<MAGIC_NUMBER>

Instead, the new mechanism would work by having them both declare in their Makefile.dep:

EVENT_THREAD_MEDIUM_STACKSIZE_MIN +=

The build system then picks the maximum number in EVENT_THREAD_MEDIUM_STACKSIZE_MIN and exposes this as stack size, if any module did declare a minimum requirement.

Testing procedure

The test in tests/sys/event_thread_shared has been extended to test correct passing of the stack size value at compile time. So a green CI would be sufficient.

Issues/PRs references

None

This can be used to get the highest value out of a list of numeric
numbers in a Makefile variable separated by whitespace.
This adds a mechanism for modules to declare requirements on the thread
stack size in their `Makefile.dep` and let the build system then
override the default stack size, if any requirements are declared.

The motivation is to allow multiple modules to have special requirements
without causing conflicts, as just adding the following to their
`Makefile.include` would do:

```Makefile
CFLAGS += -DEVENT_THREAD_MEDIUM_STACKSIZE=<MAGIC_NUMBER>
```

Instead, the new mechanism would work by having them both declare in
their `Makefile.dep`:

```Makefile
EVENT_THREAD_MEDIUM_STACKSIZE_MIN +=
```

The build system then picks the maximum number in
`EVENT_THREAD_MEDIUM_STACKSIZE_MIN` and exposes this as stack size, if
any module did declare a minimum requirement.
This adds a simple integration test for declaring the stack size
requirements in modules.
@maribu maribu requested a review from benpicco December 8, 2025 14:54
@maribu maribu added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 8, 2025
@github-actions github-actions bot added Area: tests Area: tests and testing framework Area: build system Area: Build system Area: sys Area: System labels Dec 8, 2025
@mguetschow mguetschow changed the title makefiles: add $(call max_number, <NUMS>) shell function sys/event: manage event thread size via build system Dec 8, 2025
@riot-ci
Copy link

riot-ci commented Dec 8, 2025

Murdock results

✔️ PASSED

2db5023 fixup! tests/sys/event_thread_shared: test stack size handling

Success Failures Total Runtime
10950 0 10950 12m:04s

Artifacts

@maribu
Copy link
Member Author

maribu commented Dec 8, 2025

I defused the footgun with potential confusion of event thread names and event queue names.

E.g. if event_thread is in use, we only have the lowest prio event thread handling all three event queues (but handling the event queues in the order of their priorities).

I think a module posting to EVENT_PRIO_MEDIUM rightfully may expect that EVENT_THREAD_MEDIUM_STACKSIZE_MIN += 1024 would ensure that the thread handling EVENT_PRIO_MEDIUM has a stack size of at least 1024. With new change this is the case, even when the medium queue is handled by the same thread as EVENT_PRIO_LOWEST.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: build system Area: Build system Area: sys Area: System Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants