kernel/poll: Move "_poller" into thread struct, fix COHERENCE collision
Fix the issue where the kernel poll code would place the tracking struct on the caller stack and share it with other threads, thus creating a cache coherence issue on systems where KERNEL_COHERENCE is enabled. This works by eliminating the thread backpointer in struct _poller and simply placing the (now just two-byte!) struct directly into the thread struct. Note that this doesn't attempt to fix the API paradigm that the natural way to structure a call to k_poll() is to use an array of k_poll_events on the CALLER's stack. So it's likely that most "typical" k_poll code is still going to have problems with KERNEL_COHERENCE. But at least now the kernel internals aren't fundamentally broken. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
310f60f5b6
commit
dadc6643e4
2 changed files with 28 additions and 33 deletions
|
@ -272,6 +272,14 @@ struct _thread_userspace_local_data {
|
|||
};
|
||||
#endif
|
||||
|
||||
/* private, used by k_poll and k_work_poll */
|
||||
struct k_work_poll;
|
||||
typedef int (*_poller_cb_t)(struct k_poll_event *event, uint32_t state);
|
||||
struct _poller {
|
||||
bool is_polling;
|
||||
uint8_t mode;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup thread_apis
|
||||
* Thread Structure
|
||||
|
@ -309,6 +317,10 @@ struct k_thread {
|
|||
*/
|
||||
void (*fn_abort)(struct k_thread *aborted);
|
||||
|
||||
#if defined(CONFIG_POLL)
|
||||
struct _poller poller;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_THREAD_MONITOR)
|
||||
/** thread entry and parameters description */
|
||||
struct __thread_entry entry;
|
||||
|
@ -2710,15 +2722,6 @@ __syscall int k_stack_pop(struct k_stack *stack, stack_data_t *data,
|
|||
/** @} */
|
||||
|
||||
struct k_work;
|
||||
struct k_work_poll;
|
||||
|
||||
/* private, used by k_poll and k_work_poll */
|
||||
typedef int (*_poller_cb_t)(struct k_poll_event *event, uint32_t state);
|
||||
struct _poller {
|
||||
volatile bool is_polling;
|
||||
struct k_thread *thread;
|
||||
uint8_t mode;
|
||||
};
|
||||
|
||||
/**
|
||||
* @addtogroup thread_apis
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue