-
Notifications
You must be signed in to change notification settings - Fork 318
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
ace: zephyr: alloc: Use virtual memory heap for buffers #9155
base: main
Are you sure you want to change the base?
Conversation
@@ -36,7 +36,7 @@ | |||
* either be spanned on specifically configured heap or have | |||
* individual configs with bigger block sizes. | |||
*/ | |||
#define MAX_MEMORY_ALLOCATORS_COUNT 8 | |||
#define MAX_MEMORY_ALLOCATORS_COUNT 10 |
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.
Should this now come from Kconfig if CONFIG_VIRTUAL_HEAP == y ?
@softwarecki sorry, could you explain why it's necessary? Your buffer size as a range PR is separate, so it also works with the standard Zephyr heap allocator, right? |
@lyakh In a situation where a preferred buffer size given by the IPC is too large to be allocated, the size of a buffer is reduced step by step until allocation is successful. Using this mechanism on a regular allocator will allocate all available memory. As a result, it will not be possible to allocate next buffers due to lack of available memory. In a situation where we have memory divided earlier into buffers of specific sizes, allocating the largest possible buffer leaves the remaining buffers available. |
@softwarecki sorry, still don't understand. You have your range allocator. First you request a buffer of size min=16k, max=128k. Say, we have more than 128k available, so we allocate the maximum. With both allocators, right? Then comes another request for the same size range. Now we don't have another 128k available any more, but we do have 16k, so we allocate that - with either allocator. What's the difference? Why are you saying that "on a regular allocator will allocate all available memory?" Why should one allocation take all the available memory? Confused. |
@lyakh Let me explain. For example, we want to make two allocations (min=16k, preferred=128k) but we only have 96k available. In the case of a classic allocation using |
@softwarecki ok, I see, but TBH this seems to be a rather artificial example to me. In this "lucky" situation - yes, that would be the case. But in many other cases the VMH would fail too. In fact, doesn't VMH add fragmentation? E.g. if you allocate buffers of 24 or 48k and you use 32 or 64k VMH buffers for them? |
5d8f11d
to
80bb55f
Compare
@softwarecki I think the west update can probably be dropped now as Zephyr should be up to date. |
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.
Looks ok to me
36132d4
to
ce05dc9
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.
@softwarecki I'm good for this today, but long term we should move all our memory logic into Zephyr i.e. all SOF application would be a client of Zephyr memory mgmt logic APIs.
@softwarecki can you check internal CI. Thanks ! |
@nashif @teburd @andyross fwiw, we are good to take this into SOF atm, but can we plan initial Zephyr support for virtual memory in next merge window ? I assume we are still pending some dependencies for virtual memory heaps in Zephyr ? |
@lgirdwood Last year I proposed my allocator for zephyr (zephyrproject-rtos/zephyr#54714) with predefined buffers, but it was met with criticism that it did not use zephyr's existing allocators as a base. It supports any division configuration and does not use dynamic memory allocation. Virtual memory support (page mapping) was supposed to be added in the next layer but it turned out that colleagues were already working on a similar solution and I did not continue the work. |
ok, we can keep here until everything can be aligned with Zephyr folks and migrated in the future. |
@softwarecki can you check internal CI and confirm, we could split the PR here if its only 1 patch that causing the failure ? |
The current design constraints of vmh allocator dictate that a buffer size must be a power of two and each group of buffers must have a size that is a multiple of the page size. The current configuration of memory regions provides 1MB of virtual space for buffers. The combination of these factors currently makes it impossible to allocate bigger buffer for the kbp. It is therefore necessary to increase the number of memory pools of which kbp use to allocade necessary buffer. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Platforms based on xtensa have a non-coherent cache between cores. Before releasing a memory block, it is necessary to invalidate the cache. This memory block can be allocated by another core and performing cache writeback by the previous owner will destroy current content of the main memory. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
The buffer allocation method for ace platform has been changed. They are allocated using the virtual memory heap. This consists of a set of buffers with a predefined size. Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Remove config preventing log grabbing. Enable logging using probes on PTL platform instead of MTRACE Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
Enable probe extraction/injection on PTL platform Signed-off-by: Ievgen Ganakov <ievgen.ganakov@intel.com>
9a27f79
to
e200f37
Compare
@softwarecki still DNM ? |
Release reminder - one week to v2.11-rc1. |
@softwarecki any ETA, stable v2.11 now forked so less risk now. |
The buffer allocation method for ace platform has been changed. They are allocated using the virtual memory heap. This consists of a set of buffers with a predefined size.
Dividing memory into buffers of a predefined size is necessary for the proper operation of the allocator, which creates a buffer with a size given as a range (
buffer_alloc_range
#9145) - a functionality used for deep buffering.PR needed before merge this PR: