zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.64k stars 6.52k forks source link

handle SMP memory domain migration gracefully #29601

Open andrewboie opened 3 years ago

andrewboie commented 3 years ago

Is your enhancement proposal related to a problem? Please describe. Moving a thread from one memory domain to another with SMP active is not as simple as de-configuring it from the old domain and applying the incoming domain's permissions. The thread must survive this operation if it is running on another CPU and its memory access is limited to its own stack or the intersection of the two domains.

I had to do some ugly stuff in arch_mem_domain_add_thread() and arch_mem_domain_remove_thread() in https://github.com/zephyrproject-rtos/zephyr/pull/29411/.

That PR adds a test for this scenario, at least.

Describe the solution you'd like Cleaner interfaces, perhaps maybe something along the lines of

#ifdef CONFIG_SMP
void arch_mem_domain_migrate(struct k_thread *thread,
                             struct k_mem_domain *old_domain,
                             struct k_mem_domain *new_domain);
#endif

k_mem_domain_add_thread() would hook into this.

arch_mem_domain_add_thread() and arch_mem_domain_remove_thread() would still exist, but only be called on thread creation/termination.

andrewboie commented 3 years ago

@ruuddw @abrodkin I remember this came up about SMP support for ARC MPU.

zephyrbot commented 8 months ago

Hi @dcpleung,

This issue, marked as an Enhancement, was opened a while ago and did not get any traction. It was just assigned to you based on the labels. If you don't consider yourself the right person to address this issue, please re-assing it to the right person.

Please take a moment to review if the issue is still relevant to the project. If it is, please provide feedback and direction on how to move forward. If it is not, has already been addressed, is a duplicate, or is no longer relevant, please close it with a short comment explaining the reason.

@andrewboie you are also encouraged to help moving this issue forward by providing additional information and confirming this request/issue is still relevant to you.

Thanks!