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

kernel: Improve cooperative and preemptive performance as per thread_metric benchmark #81311

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
3 changes: 3 additions & 0 deletions include/zephyr/kernel_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ struct _priq_rb {
struct _priq_mq {
sys_dlist_t queues[K_NUM_THREAD_PRIO];
unsigned long bitmask[PRIQ_BITMAP_SIZE];
#ifndef CONFIG_SMP
unsigned int cached_queue_index;
#endif
};

struct _ready_q {
Expand Down
23 changes: 23 additions & 0 deletions include/zephyr/sys/dlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,29 @@ static inline void sys_dlist_insert_at(sys_dlist_t *list, sys_dnode_t *node,
}
}

/**
* @brief remove a specific node from a list
*
* Like :c:func:`sys_dlist_remove()`, this routine removes a specific node
* from a list. However, unlike :c:func:`sys_dlist_remove()`, this routine
* does not re-initialize the removed node. One significant implication of
* this difference is that the function :c:func`sys_dnode_is_linked()` will
* not work on a dequeued node.
*
* The list is implicit from the node. The node must be part of a list.
* This and other sys_dlist_*() functions are not thread safe.
*
* @param node the node to dequeue
*/
static inline void sys_dlist_dequeue(sys_dnode_t *node)
cfriedt marked this conversation as resolved.
Show resolved Hide resolved
{
sys_dnode_t *const prev = node->prev;
sys_dnode_t *const next = node->next;

prev->next = next;
next->prev = prev;
}

/**
* @brief remove a specific node from a list
*
Expand Down
2 changes: 0 additions & 2 deletions kernel/include/ksched.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ static inline bool z_is_prio_lower_or_equal(int prio1, int prio2)
return z_is_prio1_lower_than_or_equal_to_prio2(prio1, prio2);
}

int32_t z_sched_prio_cmp(struct k_thread *thread_1, struct k_thread *thread_2);

static inline bool _is_valid_prio(int prio, void *entry_point)
{
if ((prio == K_IDLE_PRIO) && z_is_idle_thread_entry(entry_point)) {
Expand Down
10 changes: 10 additions & 0 deletions kernel/include/kthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ static inline bool z_is_thread_queued(struct k_thread *thread)
return z_is_thread_state_set(thread, _THREAD_QUEUED);
}

static inline void z_mark_thread_as_queued(struct k_thread *thread)
{
thread->base.thread_state |= _THREAD_QUEUED;
}

static inline void z_mark_thread_as_not_queued(struct k_thread *thread)
{
thread->base.thread_state &= ~_THREAD_QUEUED;
}

static inline void z_mark_thread_as_suspended(struct k_thread *thread)
{
thread->base.thread_state |= _THREAD_SUSPENDED;
Expand Down
Loading
Loading