Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel: Improve single thread (CONFIG_MULTITHREADING=n) support #34279

Merged

Conversation

nordic-krch
Copy link
Contributor

An attempt to improve no multithreading (no-mt) support in order to keep it in the tree by:

  • cleanup in kernel/timer as k_timer is expected to work in no-mt
  • extending tests/kernel/timer/timer_api to validate no-mt case
  • cleanup in kernel so that number of kernel source files can be limited when no-mt.
  • added support for no-mt in ztest
  • added sanity test for no-mt which validates that expected features are working: k_busy_wait, k_timer, irq_locking, k_cpu_idle, SYS_INIT
  • removing z_arm_pendsv from vector table
  • reverted deprecation of no-mt.

Note that currently all existing multithreading tests are passing only on cortex_m but having test coverage for expected scope will help to add support for other platforms.

Separate PR will cover documentation (will be based on #29338).

@github-actions github-actions bot added area: ARM ARM (32-bit) Architecture area: Kernel area: Test Framework Issues related not to a particular test, but to the framework instead area: Tests Issues related to a particular existing or missing test labels Apr 14, 2021
@nordic-krch nordic-krch requested review from carlescufi, andyross and nashif and removed request for carlescufi April 15, 2021 08:07
@nordic-krch nordic-krch force-pushed the kernel/no_multithreading branch from b6797e8 to f4748cb Compare April 15, 2021 08:49
@carlescufi carlescufi requested a review from npitre April 15, 2021 10:58
@nordic-krch nordic-krch force-pushed the kernel/no_multithreading branch from 8301cee to 56328ad Compare April 15, 2021 11:04
@carlescufi carlescufi requested a review from katsuster April 15, 2021 12:37
Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that it fits much with Zephyr's overall market direction (increasingly moving into larger and more complicated systems), but it's nice to see this being resurrected. Any data on binary size to share?

@carlescufi
Copy link
Member

Not that it fits much with Zephyr's overall market direction (increasingly moving into larger and more complicated systems), but it's nice to see this being resurrected. Any data on binary size to share?

Thank you @andyross. I do not want to reopen the discussion about the usefulness of the feature but suffice to say that the fact that we are investing time and effort into it, that we commit to maintaining it, that the ARC architecture might use it in the future and that it was useful for the Aarch64 maintainers when initially bringing up the platform should be enough reason to keep it.

@npitre
Copy link
Collaborator

npitre commented Apr 15, 2021 via email

@hongshui3000
Copy link
Contributor

hongshui3000 commented Apr 16, 2021

This is good news. I can still use single-threaded + my own single-threaded thing-driven framework to develop simple applications. At the same time, I can also use the zephyr software ecosystem.
If someone can separate the related content in the mayfly directory(zephyr/subsys/bluetooth/controller/util/) from the Bluetooth controller code and provide it for single-threaded tasks, I think it would be more perfect.
This will also enable the single-threaded mode to have greater vitality in the future to survive under this complex zephyr system

@nordic-krch nordic-krch force-pushed the kernel/no_multithreading branch from 56328ad to 17b67ab Compare April 16, 2021 10:35
@nordic-krch
Copy link
Contributor Author

@andyross regarding:

Any data on binary size to share?

Savings are not stunning (~2k) but it depends on the perspective. If you want to fit your bootloader in 4k pages. Then such savings may mean 4k vs 8k and that becomes significant.

nordic-krch and others added 14 commits April 29, 2021 08:17
…case

Extended test to validate that timer API is working as expected
when CONFIG_MULTITHREADING=n.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Extended test to validate following functionality:
- k_busy_wait
- k_timer
- irq_lock/irq_unlock
- k_cpu_idle
- SYS_INIT()

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Extended mslab_api test suite with CONFIG_MULTITHREADING=n
configuration.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Extended mheap_api_concept test suite to support case when
multithreading is disabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This provides the documentation of scope required as a stage towards
removing deprecation for CONFIG_MULTITHREADING=n.  The specific lists
of what does work will follow as the code base is inspected and
updated.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Spin lock validation is touching threads. Allow only when
multithreading is enabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Add support to no multithreading configuration.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Don use k_sleep when multithreading is disabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fixed to ensure that semaphore is not used by the log core
when multithreading is disabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Enable by default power managment only when multithreading is
enabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Added test which verifies that when multithreading is disabled
exception as correctly handled by the kernel.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Update configuration of qemu_cortex_m0 to use LF XTAL as low
frequency clock source. Previously used RC requires more
modules to be fetched into the build, including TEMP sensor
used for clock calibration.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Removed #ifdef that guarded irq_offload API.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
@nordic-krch nordic-krch force-pushed the kernel/no_multithreading branch from 537b679 to 0519100 Compare April 29, 2021 06:19
@nordic-krch
Copy link
Contributor Author

@carlescufi rebased, CI green except for compliance failure that we need to live with.

@carlescufi carlescufi merged commit a1829cf into zephyrproject-rtos:master Apr 29, 2021
nvlsianpu added a commit to nvlsianpu/mcuboot that referenced this pull request Jun 11, 2021
Sine zephyr zephyrproject-rtos/zephyr#34279
was merged there is no silent idle thread created automatically while
CONFIG_MULTITHREADING=n. Since that any single thread application
needs to call k_cpu_idle() by itself for entering idle mode, which
allows for reduction power consumption.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
nvlsianpu added a commit to nvlsianpu/mcuboot that referenced this pull request Jun 14, 2021
Sine zephyr zephyrproject-rtos/zephyr#34279
was merged there is no silent idle thread created automatically while
CONFIG_MULTITHREADING=n. Since that any single thread application
needs to call k_cpu_idle() (wrapped by MCUBOOT_CPU_IDLE_WFE)
by itself for entering idle mode, which allows for reduction
power consumption.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
nvlsianpu added a commit to nvlsianpu/mcuboot that referenced this pull request Jun 14, 2021
Sine zephyr zephyrproject-rtos/zephyr#34279
was merged there is no silent idle thread created automatically while
CONFIG_MULTITHREADING=n. Since that any single thread application
needs to call k_cpu_idle() (wrapped by MCUBOOT_CPU_IDLE_WFE)
by itself for entering idle mode, which allows for reduction
power consumption.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
nvlsianpu added a commit to nvlsianpu/mcuboot that referenced this pull request Jun 14, 2021
Sine zephyr zephyrproject-rtos/zephyr#34279
was merged there is no silent idle thread created automatically while
CONFIG_MULTITHREADING=n. Since that any single thread application
needs to call k_cpu_idle() (wrapped by MCUBOOT_CPU_IDLE_WFE)
by itself for entering idle mode, which allows for reduction
power consumption.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
nvlsianpu added a commit to nvlsianpu/mcuboot that referenced this pull request Jun 14, 2021
Sine zephyr zephyrproject-rtos/zephyr#34279
was merged there is no silent idle thread created automatically while
CONFIG_MULTITHREADING=n. Since that any single thread application
needs to call k_cpu_idle() (wrapped by MCUBOOT_CPU_IDLE_WFE)
by itself for entering idle mode, which allows for reduction
power consumption.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
nvlsianpu added a commit to nvlsianpu/mcuboot that referenced this pull request Jun 16, 2021
Sine zephyr zephyrproject-rtos/zephyr#34279
was merged there is no silent idle thread created automatically while
CONFIG_MULTITHREADING=n. Since that any single thread application
needs to call k_cpu_idle() (wrapped by MCUBOOT_CPU_IDLE)
by itself for entering idle mode, which allows for reduction
power consumption.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
nvlsianpu added a commit to mcu-tools/mcuboot that referenced this pull request Jun 17, 2021
Sine zephyr zephyrproject-rtos/zephyr#34279
was merged there is no silent idle thread created automatically while
CONFIG_MULTITHREADING=n. Since that any single thread application
needs to call k_cpu_idle() (wrapped by MCUBOOT_CPU_IDLE)
by itself for entering idle mode, which allows for reduction
power consumption.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
sigvartmh pushed a commit to sigvartmh/fw-nrfconnect-mcuboot-1 that referenced this pull request Aug 3, 2021
Sine zephyr zephyrproject-rtos/zephyr#34279
was merged there is no silent idle thread created automatically while
CONFIG_MULTITHREADING=n. Since that any single thread application
needs to call k_cpu_idle() (wrapped by MCUBOOT_CPU_IDLE)
by itself for entering idle mode, which allows for reduction
power consumption.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
sigvartmh pushed a commit to sigvartmh/fw-nrfconnect-mcuboot-1 that referenced this pull request Aug 9, 2021
Sine zephyr zephyrproject-rtos/zephyr#34279
was merged there is no silent idle thread created automatically while
CONFIG_MULTITHREADING=n. Since that any single thread application
needs to call k_cpu_idle() (wrapped by MCUBOOT_CPU_IDLE)
by itself for entering idle mode, which allows for reduction
power consumption.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
nvlsianpu added a commit to nvlsianpu/fw-nrfconnect-mcuboot that referenced this pull request Dec 2, 2021
Sine zephyr zephyrproject-rtos/zephyr#34279
was merged there is no silent idle thread created automatically while
CONFIG_MULTITHREADING=n. Since that any single thread application
needs to call k_cpu_idle() (wrapped by MCUBOOT_CPU_IDLE)
by itself for entering idle mode, which allows for reduction
power consumption.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: API Changes to public APIs area: ARM ARM (32-bit) Architecture area: Boards area: Documentation area: Kernel area: Logging area: Test Framework Issues related not to a particular test, but to the framework instead area: Tests Issues related to a particular existing or missing test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants