Skip to content

Commit ec4df64

Browse files
peter-mitsiskartben
authored andcommitted
kernel: make order_key field in thread conditional
The 'order_key' field in the thread structure '_thread_base' is only required when CONFIG_SCHED_SCALABLE and/or CONFIG_WAITQ_SCALABLE are enabled (neither of which is a default setting). Making the existence of this field conditional slightly reduces the size of the k_thread structure when neither of those Kconfig options are selected. Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
1 parent 4338122 commit ec4df64

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

include/zephyr/kernel/thread.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ struct _thread_base {
105105
int prio_deadline;
106106
#endif /* CONFIG_SCHED_DEADLINE */
107107

108+
#if defined(CONFIG_SCHED_SCALABLE) || defined(CONFIG_WAITQ_SCALABLE)
108109
uint32_t order_key;
110+
#endif
109111

110112
#ifdef CONFIG_SMP
111113
/* True for the per-CPU idle threads */

kernel/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,14 @@ list(APPEND kernel_files
8080
system_work_q.c
8181
work.c
8282
condvar.c
83-
priority_queues.c
8483
thread.c
8584
sched.c
8685
)
86+
87+
if (CONFIG_SCHED_SCALABLE OR CONFIG_WAITQ_SCALABLE)
88+
list(APPEND kernel_files priority_queues.c)
89+
endif()
90+
8791
# FIXME: Once the prior pipe implementation is removed, this should be included in the above list
8892
if(NOT CONFIG_PIPES)
8993
list(APPEND kernel_files pipe.c)

kernel/include/priority_q.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#include <zephyr/sys/math_extras.h>
1111
#include <zephyr/sys/dlist.h>
1212

13-
bool z_priq_rb_lessthan(struct rbnode *a, struct rbnode *b);
14-
1513
/* Dumb Scheduling */
1614
#if defined(CONFIG_SCHED_DUMB)
1715
#define _priq_run_init z_priq_dumb_init
@@ -185,8 +183,11 @@ static ALWAYS_INLINE struct k_thread *z_priq_dumb_mask_best(sys_dlist_t *pq)
185183
}
186184
#endif /* CONFIG_SCHED_CPU_MASK */
187185

186+
#if defined(CONFIG_SCHED_SCALABLE) || defined(CONFIG_WAITQ_SCALABLE)
188187
static ALWAYS_INLINE void z_priq_rb_init(struct _priq_rb *pq)
189188
{
189+
bool z_priq_rb_lessthan(struct rbnode *a, struct rbnode *b);
190+
190191
*pq = (struct _priq_rb) {
191192
.tree = {
192193
.lessthan_fn = z_priq_rb_lessthan,
@@ -244,6 +245,7 @@ static ALWAYS_INLINE struct k_thread *z_priq_rb_best(struct _priq_rb *pq)
244245
}
245246
return thread;
246247
}
248+
#endif
247249

248250
struct prio_info {
249251
uint8_t offset_prio;

0 commit comments

Comments
 (0)