Skip to content

automount: 4 kB of stack and 60 s to stop - what a mount sets going runs in its thread - #6

Merged
JohnAmadis merged 3 commits into
mainfrom
fix/automount-stack-for-mount-reports
Oct 26, 2026
Merged

JohnAmadis merged 3 commits into
mainfrom
fix/automount-stack-for-mount-reports

Conversation

@JaxCalder

@JaxCalder JaxCalder commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Problem 1 - the stack

automount is released with a 2 kB stack (2560 bytes with the overhead). The thread that mounts is also the one dmvfs calls the _mount_changed listeners in (dmfsi's dif), and libsystemd uses that call to load <mount point>/cfg/services and cfg/rules of the new file system and start its units (choco-technologies/dmsystem#9) - a module loaded from the new file system, with its dependencies, in automount's thread.

Change

DMOD_STACK_SIZE of services/automount 2048 -> 4096.

Measured (STM32F746G-DISCO)

Peak of automount's stack with the car HMI demo started from the card and the one-shot devscan (choco-technologies/dmdevfs#75, #77) running: 2596 bytes (ps). With the 2 kB stack the thread overflows: vApplicationStackOverflowHook, the system is dead - seen on the board when a unit had to load its module from /ext (littlefs) inside the mount report. With 4 kB: cold boots in a row, the card mounts, carhmi starts from it.

Problem 2 - the stop timeout

The same thread also does the unmount, and libsystemd (choco-technologies/dmsystem#9, #10) hears it there: it runs the remove units of its rules (devscan, up to 20 s each) and stops the units that came from the file system (the car HMI demo: ~4 s), each with its own timeout. With stop_timeout_ms=5000 automount was killed in the middle of the unmount: on the board the card stayed mounted, the service stop took 85-105 s and units were started again. stop_timeout_ms=60000; with it, unmounting a card with the car HMI running completes (25 s on the board, no hang).

Needed by choco-technologies/dmod-boot#148 (do not merge that before a release with this).

🤖 Generated with Claude Code

The thread that mounts is the one dmvfs calls the _mount_changed listeners in.
libsystemd loads <mount point>/cfg/services there and starts its units - a module
loaded from the new file system with its dependencies: 2596 bytes of stack
measured on STM32F746G-DISCO with the car HMI demo from the card, more than the
2 kB automount had (vApplicationStackOverflowHook, the system is dead).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
JaxCalder and others added 2 commits October 25, 2026 23:14
…system

libsystemd hears the unmount in automount's thread: it runs the rules' remove
units and stops the units that came from the file system (the car HMI demo takes
seconds to stop), each with its own timeout. With 5 s for automount itself it was
killed in the middle of the unmount: the card stayed mounted, the stop took
minutes, and units were started again.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@JohnAmadis
JohnAmadis merged commit a95fc6c into main Oct 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants