Add sof_sys_user_heap_get() and APP_SYSUSER_DATA/BSS macros#10732
Add sof_sys_user_heap_get() and APP_SYSUSER_DATA/BSS macros#10732kv2019i wants to merge 2 commits intothesofproject:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds APIs and macros to support running low-latency (LL) audio pipeline code in Zephyr user-space by ensuring certain heaps/static objects are accessible from non-privileged LL threads, without changing behavior for regular (kernel-thread) SOF builds.
Changes:
- Introduce
sof_sys_user_heap_get()(Zephyr implementation returns the LL user heap when enabled). - Add a new Zephyr app memory partition (
sysuser_partition) plus attach helper for memory domains. - Add
APP_SYSUSER_DATA/APP_SYSUSER_BSSmacros for tagging static objects into the new partition.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| zephyr/lib/userspace_helper.c | Defines sysuser_partition and adds a helper to attach it to a mem domain. |
| zephyr/lib/alloc.c | Adds sof_sys_user_heap_get() to select the LL userspace heap when enabled. |
| zephyr/include/rtos/userspace_helper.h | Adds APP_SYSUSER_* macros and declares the new partition attach helper. |
| zephyr/include/rtos/alloc.h | Declares sof_sys_user_heap_get() with a new API comment block. |
| src/platform/library/lib/alloc.c | Adds a stub implementation of sof_sys_user_heap_get() for the library/testbench platform. |
| posix/include/rtos/alloc.h | Adds the sof_sys_user_heap_get() prototype for POSIX builds. |
kv2019i
left a comment
There was a problem hiding this comment.
Responses to review comments, will upload V2.
Add sof_sys_user_heap_get() to get heap object to use for SOF audio application heap allocations. When SOF is built with CONFIG_SOF_USERSPACE_LL, this will return a heap that can be used for user-space code. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Add APP_SYSUSER_BSS() and APP_SYSUSER_DATA() macros to put global objects to a memory partition that is available to the user context used to run main SOF application. If SOF is run in kernel space, these are no-ops, but if CONFIG_SOF_USERSPACE_LL is set, a dedicated memory partition is used. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
|
V2 pushed:
|
| #else | ||
| #define APP_SYSUSER_BSS | ||
| #define APP_SYSUSER_DATA | ||
| #endif |
There was a problem hiding this comment.
do I understand it correctly, that in principle we could just use APP_TASK_BSS and APP_TASK_DATA but the difference is that these only place the affected data in that new partition if CONFIG_SOF_USERSPACE_LL is selected, while APP_TASK_* do that unconditionally? If that my understanding is correct, maybe would be good to explain it somewhere.
There was a problem hiding this comment.
That does apply, but also APP_SYSUSER objects are NOT available to all user-space threads. The LL user thread has much more access to system resources than e.g. DP modules running in their own user-space thread. So we do not want to use APP_TASK for these objects.
But ack, better to clarify in inline comments.
Add helpers to allocate heap memory that should be accessible to the LL audio pipelines when they are ran in a user-space thread. Also add userspace helper macros for APP_SYSUSER_DATA/BSS to allow tag static objects such that they are made accessible to the LL userspace threads. These changes have no impact to regular SOF builds where LL audio pipelines are run in kernel threads.
For context, these commits are part of #10558