-
Notifications
You must be signed in to change notification settings - Fork 1k
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
sched: Introduce Bound Multi-Processing (BMP) into NuttX #12020
base: master
Are you sure you want to change the base?
Conversation
e1ddca8
to
0802894
Compare
38887e3
to
016201d
Compare
@anchao could you split irqaff change to a new pr? So the change crossing apps/nuttx could be merged first. Since the remaining change touch many files, it's better to ensure it can pass ci standalone. |
eb003ee
to
cde829d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move the detailed commit message to an entry at https://nuttx.apache.org/docs/latest/components/index.html
27e2459
to
a64a1e7
Compare
Can BMP ensure that if an application bound to a separate processor crashes, it will not affect other processors? |
Of course, this is just the initial pull request of BMP. MPU protection and assertion chain related optimization will be added in the future. |
Great! |
Cool work, I'm curious would this work on a asymmetrical system witch it's own caches i.e. Cortex-M7 and Cortex-M4 but without hardware cache coherency? |
Yes, but the implementation requires more customized modifications. If platforms without hardware cache consistency, all data must be correctly placed on cache line aligned sections, which will depend on some labeling for specific data/bss in the link script. |
What is the difference between this approach and the pthread_setaffinity_np functions implemented by NuttX?Does threads spawned by a task bound to a specific processor can also be automatically bound to that |
Please refer PR summary. Compared with SMP, BMP can provide more performance, stability and isolation advantages. |
i see,it seem's that BMP can resolve two problems of SMP processor affinity: constraining threads in third-party code, and constraining dynamically created threads |
Bound multiprocessing provides the scheduling control of an asymmetric multiprocessing model, while preserving the hardware abstraction and management of symmetric multiprocessing. BMP is similar to SMP, but you can specify which processors a thread can run on. You can use both SMP and BMP on the same system, allowing some threads to migrate from one processor to another, while other threads are restricted to one or more processors. As with SMP, a single copy of the OS maintains an overall view of all system resources, allowing them to be dynamically allocated and shared among applications. But, during application initialization, a setting determined by the system designer forces all of an application's threads to execute only on a specified CPU. Compared to full, floating SMP operation, this approach offers several advantages: 1. It eliminates the cache thrashing that can reduce performance in an SMP system by allowing applications that share the same data set to run exclusively on the same CPU. 2. It offers simpler application debugging than SMP since all execution threads within an application run on a single CPU. 3. It helps legacy applications that use poor techniques for synchronizing shared data to run correctly, again by letting them run on a single CPU. Bound Multi-Processing (BMP): --------------------------------------------- | APP 0 | APP 1 | APP 2 | APP 3 | <- Application bound to CPU --------------------------------------------- | Data[0] | Data[1] | Data[2] | Data[3] | <- NuttX Kernel Data supports multiple CPU instances --------------------------------------------- | Share Code | <- NuttX kernel code shared for all CPUs --------------------------------------------- | UART 0 | SPI 0 | SPI 1 | I2C 0 | <- Driver is only registered to CPUs with application needs --------------------------------------------- | TIME 0 | TIME 1 | TIME 2 | TIME 3 | <- Core/CPU timers --------------------------------------------- | CPU0 | CPU1 | CPU2 | CPU3 | <- CPUs run independently --------------------------------------------- Some subsystem data does not need to be duplicated, especially the components bound to the application. For shared hardware devices, Use spinlock to avoid race-condition for multi-core. --------------------------------------------- | APP 0 | APP 1 | APP 2 | APP 3 | --------------------------------------------- | NetStack | BTStack | AUDIO | ... | <- Components bound to the application, data no need to duplicate. --------------------------------------------- | Share Code | --------------------------------------------- | Share UART (Protected by Spinlock) | <- Driver shared for all CPUS will protected by spinlock(e.g print logs) --------------------------------------------- | CPU0 | CPU1 | CPU2 | CPU3 | --------------------------------------------- Signed-off-by: chao an <anchao@lixiang.com> Signed-off-by: chao an <anchao@lixiang.com>
Signed-off-by: chao an <anchao@lixiang.com>
Summary
sched: Introduce Bound Multi-Processing (BMP) into NuttX
Bound multiprocessing provides the scheduling control of an asymmetric
multiprocessing model, while preserving the hardware abstraction and
management of symmetric multiprocessing.
BMP is similar to SMP, but you can specify which processors a thread
can run on. You can use both SMP and BMP on the same system, allowing
some threads to migrate from one processor to another, while other
threads are restricted to one or more processors.
As with SMP, a single copy of the OS maintains an overall view of all
system resources, allowing them to be dynamically allocated and shared
among applications. But, during application initialization, a setting
determined by the system designer forces all of an application's threads
to execute only on a specified CPU.
Compared to full, floating SMP operation, this approach offers several
advantages:
system by allowing applications that share the same data set to run
exclusively on the same CPU.
threads within an application run on a single CPU.
shared data to run correctly, again by letting them run on a single CPU.
Bound Multi-Processing (BMP):
Some subsystem data does not need to be duplicated, especially the components bound to the application.
For shared hardware devices, Use spinlock to avoid race-condition for multi-core.
Reference:
https://www.ghs.com/products/safety_critical/integrity_178_multicore.html
https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.sys_arch/topic/smp_BMP.html
https://www.nxp.com.cn/docs/en/brochure/PWRARBYNDBITSRAS.pdf
Signed-off-by: chao an anchao@lixiang.com
Impact
Depends on: apache/nuttx-apps#2342
N/A
Testing
qemu-armv7a/bmp ostest on single core