You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The k_poll() implementation, at one spot at the top of z_impl_k_poll(), places a struct _poller object on the stack of the calling thread to store metadata about the call. This is necessarily a shared struct read and updated by other threads.
That doesn't work with the new "coherence" framework, which places all stack memory into incoherent (cached) memory regions for performance. Right now it's disabled and will produce a build failure if you try to combine CONFIG_KERNEL_COHERENECE with CONFIG_POLL.
This isn't unfixable. Possible treatments:
Put appropriate cache invalidate and flush operations around access to the stack memory, and align/pad it so that it doesn't share a cache line with other data. It's already locked for synchronization, this would go into the same spot. This is IMHO the gold standard choice, as it will perform optimally (because you only pay the cache flush once instead of on every access). But it's subtle.
Put the _poller somewhere else. There can only be one per thread at a time (because it represents a thread blocked in k_poll(), which is non-reentrant). It could live in the (uncached) thread struct, at the cost of wasted memory per thread.
Likewise, put it in a k_malloc()'d block, or keep a cache of static pollers allocated at call time (via mem_slab or whatever). The call is already capable of returning an error, so this could work reasonably well, again at a cost in performance. And I'm not sure if we want to tie k_poll to dynamic memory allocation or not.
The text was updated successfully, but these errors were encountered:
The k_poll() implementation, at one spot at the top of z_impl_k_poll(), places a struct _poller object on the stack of the calling thread to store metadata about the call. This is necessarily a shared struct read and updated by other threads.
That doesn't work with the new "coherence" framework, which places all stack memory into incoherent (cached) memory regions for performance. Right now it's disabled and will produce a build failure if you try to combine CONFIG_KERNEL_COHERENECE with CONFIG_POLL.
This isn't unfixable. Possible treatments:
Put appropriate cache invalidate and flush operations around access to the stack memory, and align/pad it so that it doesn't share a cache line with other data. It's already locked for synchronization, this would go into the same spot. This is IMHO the gold standard choice, as it will perform optimally (because you only pay the cache flush once instead of on every access). But it's subtle.
Put the _poller somewhere else. There can only be one per thread at a time (because it represents a thread blocked in k_poll(), which is non-reentrant). It could live in the (uncached) thread struct, at the cost of wasted memory per thread.
Likewise, put it in a k_malloc()'d block, or keep a cache of static pollers allocated at call time (via mem_slab or whatever). The call is already capable of returning an error, so this could work reasonably well, again at a cost in performance. And I'm not sure if we want to tie k_poll to dynamic memory allocation or not.
The text was updated successfully, but these errors were encountered: