schedule: allocate the scheduler objects with sof_heap_alloc()#10821
schedule: allocate the scheduler objects with sof_heap_alloc()#10821kv2019i wants to merge 2 commits into
Conversation
|
For context, part of #10558 |
There was a problem hiding this comment.
Pull request overview
This PR updates scheduler object allocation so scheduler state can reside in the appropriate heap for both kernel and userspace LL scheduler configurations.
Changes:
- Replaces
rzalloc(SOF_MEM_FLAG_KERNEL, ...)withsof_heap_alloc(...). - Selects the LL userspace heap when
CONFIG_SOF_USERSPACE_LLis enabled. - Adds explicit zero-initialization after allocation to preserve previous
rzalloc()behavior.
| struct k_heap *heap = NULL; | ||
|
|
||
| #ifdef CONFIG_SOF_USERSPACE_LL | ||
| heap = sof_sys_user_heap_get(); |
There was a problem hiding this comment.
whats the split between kernel/user memory for scheduler APIs for LL user ?
There was a problem hiding this comment.
@lgirdwood The idea here is the audio schedulers (i.e. SOF schedule.h) are owned by the system LL thread (that can be now in user-space). This means we move other audio schedulers (DP, EDF) also to user-space. Only initial setup (and cleanup) is done from kernel.
| /* init schedulers list */ | ||
| *sch = rzalloc(SOF_MEM_FLAG_KERNEL, | ||
| sizeof(**sch)); | ||
| *sch = sof_heap_alloc(heap, 0, sizeof(**sch), 0); |
There was a problem hiding this comment.
this would mean, that userspace code now effectively has access to all schedulers, also kernel ones
There was a problem hiding this comment.
Ack. This does leave a gap with EDF currently, so this is not safe yet for production use. So in short, generic scheduler logic (Zephyr scheduling) in kernel, audio task scheduling in user-space (if SOF built for LL userspace).
|
Back to draft. I'll refactor this to follow a more conservative/opt-in approach where scheduler type can be moved (or not moved) one-by-one to user-space. |
Add support for registering user-space LL tasks, and ability to use the task scheduling functions from user-space. The implementation splits scheduler list into kernel and user portions if SOF is built with CONFIG_SOF_USERSPACE_LL. A scheduler type can be either maintained in kernel or user, never both. With this patch, the SOF_SCHEDULE_LL_TIMER is moved to user managed if CONFIG_SOF_USERSPACE_LL is used. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Ensure the scheduler objects and lists of schedulers are allocated such that they can be used with both kernel and user-space LL scheduler implementations. The SOF_MEM_FLAG_KERNEL flag is removed. This flag has been a no-op for a while, and given scheduler list is not always in kernel anymore, it would be highly confusing to keep it. When CONFIG_SOF_USERSPACE_LL is set, the context of all schedulers is managed in the LL user-space domain. Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
1f2b5c4 to
8892eb0
Compare
|
V2:
|
| * either holds all or subset of scheduler types. | ||
| * Not accessible from user-space threads. | ||
| */ | ||
| static struct schedulers *_schedulers[CONFIG_CORE_COUNT]; |
There was a problem hiding this comment.
nitpick, we could put a k/u in the names if we have some static objects that are always kernel or always user, just to make sure we can visualize their usage better.
lyakh
left a comment
There was a problem hiding this comment.
so does this mean now, that we don't need to access the global scheduler list from the userspace? Only respective individual schedulers?
But please check if those tiny functions can be inlined, would be much better that way.
|
|
||
| assert(schedulers); | ||
| assert(task && task->sch); | ||
| sch = task->sch; |
There was a problem hiding this comment.
...at some point would be good to have all these converted to
const struct scheduler_ops *ops = task->sch->ops;
if (ops->x)
return ops->x(...);
just to reduce the number of arrows that we carry around
| } | ||
|
|
||
| #ifdef CONFIG_SOF_USERSPACE_LL | ||
| if (scheduler_is_user(type)) |
There was a problem hiding this comment.
can we use if (IS_ENABLED(CONFIG_SOF_USERSPACE_LL) && scheduler_is_user(type)) here?
| return NULL; | ||
| #endif | ||
| } | ||
| EXPORT_SYMBOL(arch_user_schedulers_get_for_core); |
There was a problem hiding this comment.
can these be made static inline which would also avoid having to export them?
Ensure the scheduler objects and lists of schedulers are allocated such that they can be used with both kernel and user-space LL scheduler implementations.
The SOF_MEM_FLAG_KERNEL flag is remevod. This flag has been a no-op for a while, and given scheduler list is not always in kernel anymore, it would be highly confusing to keep it.
When CONFIG_SOF_USERSPACE_LL is set, the context of all schedulers is managed in the LL user-space domain.