Skip to content
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

Make k_poll work with KERNEL_COHERENCE #26495

Closed
andyross opened this issue Jun 26, 2020 · 1 comment
Closed

Make k_poll work with KERNEL_COHERENCE #26495

andyross opened this issue Jun 26, 2020 · 1 comment
Assignees
Labels
area: Kernel area: SMP Symmetric multiprocessing Enhancement Changes/Updates/Additions to existing features priority: medium Medium impact/importance bug

Comments

@andyross
Copy link
Contributor

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.

@andyross andyross added the Enhancement Changes/Updates/Additions to existing features label Jun 26, 2020
@nashif nashif added priority: medium Medium impact/importance bug area: SMP Symmetric multiprocessing area: k_poll labels Aug 13, 2020
@andyross
Copy link
Contributor Author

Close this, poll coherence work got merged a while ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Kernel area: SMP Symmetric multiprocessing Enhancement Changes/Updates/Additions to existing features priority: medium Medium impact/importance bug
Projects
None yet
Development

No branches or pull requests

3 participants