mirror of
https://github.com/sched-ext/scx.git
synced 2024-11-24 03:40:23 +00:00
autogenerate scx enum definitions
This commit is contained in:
parent
31b9fb4135
commit
a1d0e7e638
@ -65,8 +65,6 @@ u64 nr_total, nr_locals, nr_queued, nr_lost_pids;
|
||||
u64 nr_timers, nr_dispatches, nr_mismatches, nr_retries;
|
||||
u64 nr_overflows;
|
||||
|
||||
SCX_ENUM_DEFINE();
|
||||
|
||||
UEI_DEFINE(uei);
|
||||
|
||||
struct {
|
||||
@ -121,21 +119,21 @@ void BPF_STRUCT_OPS(central_enqueue, struct task_struct *p, u64 enq_flags)
|
||||
*/
|
||||
if ((p->flags & PF_KTHREAD) && p->nr_cpus_allowed == 1) {
|
||||
__sync_fetch_and_add(&nr_locals, 1);
|
||||
scx_bpf_dispatch(p, SCX_ENUM(SCX_DSQ_LOCAL), SCX_ENUM(SCX_SLICE_INF),
|
||||
enq_flags | SCX_ENUM(SCX_ENQ_PREEMPT));
|
||||
scx_bpf_dispatch(p, SCX_DSQ_LOCAL, SCX_SLICE_INF,
|
||||
enq_flags | SCX_ENQ_PREEMPT);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bpf_map_push_elem(¢ral_q, &pid, 0)) {
|
||||
__sync_fetch_and_add(&nr_overflows, 1);
|
||||
scx_bpf_dispatch(p, FALLBACK_DSQ_ID, SCX_ENUM(SCX_SLICE_INF), enq_flags);
|
||||
scx_bpf_dispatch(p, FALLBACK_DSQ_ID, SCX_SLICE_INF, enq_flags);
|
||||
return;
|
||||
}
|
||||
|
||||
__sync_fetch_and_add(&nr_queued, 1);
|
||||
|
||||
if (!scx_bpf_task_running(p))
|
||||
scx_bpf_kick_cpu(central_cpu, SCX_ENUM(SCX_KICK_PREEMPT));
|
||||
scx_bpf_kick_cpu(central_cpu, SCX_KICK_PREEMPT);
|
||||
}
|
||||
|
||||
static bool dispatch_to_cpu(s32 cpu)
|
||||
@ -161,7 +159,7 @@ static bool dispatch_to_cpu(s32 cpu)
|
||||
*/
|
||||
if (!bpf_cpumask_test_cpu(cpu, p->cpus_ptr)) {
|
||||
__sync_fetch_and_add(&nr_mismatches, 1);
|
||||
scx_bpf_dispatch(p, FALLBACK_DSQ_ID, SCX_ENUM(SCX_SLICE_INF), 0);
|
||||
scx_bpf_dispatch(p, FALLBACK_DSQ_ID, SCX_SLICE_INF, 0);
|
||||
bpf_task_release(p);
|
||||
/*
|
||||
* We might run out of dispatch buffer slots if we continue dispatching
|
||||
@ -175,10 +173,10 @@ static bool dispatch_to_cpu(s32 cpu)
|
||||
}
|
||||
|
||||
/* dispatch to local and mark that @cpu doesn't need more */
|
||||
scx_bpf_dispatch(p, SCX_ENUM(SCX_DSQ_LOCAL_ON) | cpu, SCX_ENUM(SCX_SLICE_INF), 0);
|
||||
scx_bpf_dispatch(p, SCX_DSQ_LOCAL_ON | cpu, SCX_SLICE_INF, 0);
|
||||
|
||||
if (cpu != central_cpu)
|
||||
scx_bpf_kick_cpu(cpu, SCX_ENUM(SCX_KICK_IDLE));
|
||||
scx_bpf_kick_cpu(cpu, SCX_KICK_IDLE);
|
||||
|
||||
bpf_task_release(p);
|
||||
return true;
|
||||
@ -217,7 +215,7 @@ void BPF_STRUCT_OPS(central_dispatch, s32 cpu, struct task_struct *prev)
|
||||
*/
|
||||
if (!scx_bpf_dispatch_nr_slots()) {
|
||||
__sync_fetch_and_add(&nr_retries, 1);
|
||||
scx_bpf_kick_cpu(central_cpu, SCX_ENUM(SCX_KICK_PREEMPT));
|
||||
scx_bpf_kick_cpu(central_cpu, SCX_KICK_PREEMPT);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -239,7 +237,7 @@ void BPF_STRUCT_OPS(central_dispatch, s32 cpu, struct task_struct *prev)
|
||||
* Force dispatch on the scheduling CPU so that it finds a task
|
||||
* to run for us.
|
||||
*/
|
||||
scx_bpf_kick_cpu(central_cpu, SCX_ENUM(SCX_KICK_PREEMPT));
|
||||
scx_bpf_kick_cpu(central_cpu, SCX_KICK_PREEMPT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,19 +280,19 @@ static int central_timerfn(void *map, int *key, struct bpf_timer *timer)
|
||||
/* kick iff the current one exhausted its slice */
|
||||
started_at = ARRAY_ELEM_PTR(cpu_started_at, cpu, nr_cpu_ids);
|
||||
if (started_at && *started_at &&
|
||||
vtime_before(now, *started_at + SCX_ENUM(SCX_SLICE_DFL)))
|
||||
vtime_before(now, *started_at + slice_ns))
|
||||
continue;
|
||||
|
||||
/* and there's something pending */
|
||||
if (scx_bpf_dsq_nr_queued(FALLBACK_DSQ_ID) ||
|
||||
scx_bpf_dsq_nr_queued(SCX_ENUM(SCX_DSQ_LOCAL_ON) | cpu))
|
||||
scx_bpf_dsq_nr_queued(SCX_DSQ_LOCAL_ON | cpu))
|
||||
;
|
||||
else if (nr_to_kick)
|
||||
nr_to_kick--;
|
||||
else
|
||||
continue;
|
||||
|
||||
scx_bpf_kick_cpu(cpu, SCX_ENUM(SCX_KICK_PREEMPT));
|
||||
scx_bpf_kick_cpu(cpu, SCX_KICK_PREEMPT);
|
||||
}
|
||||
|
||||
bpf_timer_start(timer, TIMER_INTERVAL_NS, BPF_F_TIMER_CPU_PIN);
|
||||
|
106
scheds/include/scx/enums.autogen.bpf.h
Normal file
106
scheds/include/scx/enums.autogen.bpf.h
Normal file
@ -0,0 +1,106 @@
|
||||
|
||||
/*
|
||||
* WARNING: This file is autogenerated from scripts/gen_enums.py. If you would
|
||||
* like to access an enum that is currently missing, add it to the script
|
||||
* and run it from the root directory to update this file.
|
||||
*/
|
||||
|
||||
const volatile u64 __SCX_OPS_NAME_LEN;
|
||||
#define SCX_OPS_NAME_LEN __SCX_OPS_NAME_LEN
|
||||
|
||||
const volatile u64 __SCX_SLICE_DFL;
|
||||
#define SCX_SLICE_DFL __SCX_SLICE_DFL
|
||||
|
||||
const volatile u64 __SCX_SLICE_INF;
|
||||
#define SCX_SLICE_INF __SCX_SLICE_INF
|
||||
|
||||
const volatile u64 __SCX_DSQ_FLAG_BUILTIN;
|
||||
#define SCX_DSQ_FLAG_BUILTIN __SCX_DSQ_FLAG_BUILTIN
|
||||
|
||||
const volatile u64 __SCX_DSQ_FLAG_LOCAL_ON;
|
||||
#define SCX_DSQ_FLAG_LOCAL_ON __SCX_DSQ_FLAG_LOCAL_ON
|
||||
|
||||
const volatile u64 __SCX_DSQ_INVALID;
|
||||
#define SCX_DSQ_INVALID __SCX_DSQ_INVALID
|
||||
|
||||
const volatile u64 __SCX_DSQ_GLOBAL;
|
||||
#define SCX_DSQ_GLOBAL __SCX_DSQ_GLOBAL
|
||||
|
||||
const volatile u64 __SCX_DSQ_LOCAL;
|
||||
#define SCX_DSQ_LOCAL __SCX_DSQ_LOCAL
|
||||
|
||||
const volatile u64 __SCX_DSQ_LOCAL_ON;
|
||||
#define SCX_DSQ_LOCAL_ON __SCX_DSQ_LOCAL_ON
|
||||
|
||||
const volatile u64 __SCX_DSQ_LOCAL_CPU_MASK;
|
||||
#define SCX_DSQ_LOCAL_CPU_MASK __SCX_DSQ_LOCAL_CPU_MASK
|
||||
|
||||
const volatile u64 __SCX_TASK_QUEUED;
|
||||
#define SCX_TASK_QUEUED __SCX_TASK_QUEUED
|
||||
|
||||
const volatile u64 __SCX_TASK_RESET_RUNNABLE_AT;
|
||||
#define SCX_TASK_RESET_RUNNABLE_AT __SCX_TASK_RESET_RUNNABLE_AT
|
||||
|
||||
const volatile u64 __SCX_TASK_DEQD_FOR_SLEEP;
|
||||
#define SCX_TASK_DEQD_FOR_SLEEP __SCX_TASK_DEQD_FOR_SLEEP
|
||||
|
||||
const volatile u64 __SCX_TASK_STATE_SHIFT;
|
||||
#define SCX_TASK_STATE_SHIFT __SCX_TASK_STATE_SHIFT
|
||||
|
||||
const volatile u64 __SCX_TASK_STATE_BITS;
|
||||
#define SCX_TASK_STATE_BITS __SCX_TASK_STATE_BITS
|
||||
|
||||
const volatile u64 __SCX_TASK_STATE_MASK;
|
||||
#define SCX_TASK_STATE_MASK __SCX_TASK_STATE_MASK
|
||||
|
||||
const volatile u64 __SCX_TASK_CURSOR;
|
||||
#define SCX_TASK_CURSOR __SCX_TASK_CURSOR
|
||||
|
||||
const volatile u64 __SCX_TASK_NONE;
|
||||
#define SCX_TASK_NONE __SCX_TASK_NONE
|
||||
|
||||
const volatile u64 __SCX_TASK_INIT;
|
||||
#define SCX_TASK_INIT __SCX_TASK_INIT
|
||||
|
||||
const volatile u64 __SCX_TASK_READY;
|
||||
#define SCX_TASK_READY __SCX_TASK_READY
|
||||
|
||||
const volatile u64 __SCX_TASK_ENABLED;
|
||||
#define SCX_TASK_ENABLED __SCX_TASK_ENABLED
|
||||
|
||||
const volatile u64 __SCX_TASK_NR_STATES;
|
||||
#define SCX_TASK_NR_STATES __SCX_TASK_NR_STATES
|
||||
|
||||
const volatile u64 __SCX_TASK_DSQ_ON_PRIQ;
|
||||
#define SCX_TASK_DSQ_ON_PRIQ __SCX_TASK_DSQ_ON_PRIQ
|
||||
|
||||
const volatile u64 __SCX_KICK_IDLE;
|
||||
#define SCX_KICK_IDLE __SCX_KICK_IDLE
|
||||
|
||||
const volatile u64 __SCX_KICK_PREEMPT;
|
||||
#define SCX_KICK_PREEMPT __SCX_KICK_PREEMPT
|
||||
|
||||
const volatile u64 __SCX_KICK_WAIT;
|
||||
#define SCX_KICK_WAIT __SCX_KICK_WAIT
|
||||
|
||||
const volatile u64 __SCX_ENQ_WAKEUP;
|
||||
#define SCX_ENQ_WAKEUP __SCX_ENQ_WAKEUP
|
||||
|
||||
const volatile u64 __SCX_ENQ_HEAD;
|
||||
#define SCX_ENQ_HEAD __SCX_ENQ_HEAD
|
||||
|
||||
const volatile u64 __SCX_ENQ_PREEMPT;
|
||||
#define SCX_ENQ_PREEMPT __SCX_ENQ_PREEMPT
|
||||
|
||||
const volatile u64 __SCX_ENQ_REENQ;
|
||||
#define SCX_ENQ_REENQ __SCX_ENQ_REENQ
|
||||
|
||||
const volatile u64 __SCX_ENQ_LAST;
|
||||
#define SCX_ENQ_LAST __SCX_ENQ_LAST
|
||||
|
||||
const volatile u64 __SCX_ENQ_CLEAR_OPSS;
|
||||
#define SCX_ENQ_CLEAR_OPSS __SCX_ENQ_CLEAR_OPSS
|
||||
|
||||
const volatile u64 __SCX_ENQ_DSQ_PRIQ;
|
||||
#define SCX_ENQ_DSQ_PRIQ __SCX_ENQ_DSQ_PRIQ
|
||||
|
42
scheds/include/scx/enums.autogen.h
Normal file
42
scheds/include/scx/enums.autogen.h
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
/*
|
||||
* WARNING: This file is autogenerated from scripts/gen_enums.py. If you would
|
||||
* like to access an enum that is currently missing, add it to the script
|
||||
* and run it from the root directory to update this file.
|
||||
*/
|
||||
|
||||
#define SCX_ENUM_INIT(skel) do { \
|
||||
SCX_ENUM_SET(skel, scx_public_consts, SCX_OPS_NAME_LEN); \
|
||||
SCX_ENUM_SET(skel, scx_public_consts, SCX_SLICE_DFL); \
|
||||
SCX_ENUM_SET(skel, scx_public_consts, SCX_SLICE_INF); \
|
||||
SCX_ENUM_SET(skel, scx_dsq_id_flags, SCX_DSQ_FLAG_BUILTIN); \
|
||||
SCX_ENUM_SET(skel, scx_dsq_id_flags, SCX_DSQ_FLAG_LOCAL_ON); \
|
||||
SCX_ENUM_SET(skel, scx_dsq_id_flags, SCX_DSQ_INVALID); \
|
||||
SCX_ENUM_SET(skel, scx_dsq_id_flags, SCX_DSQ_GLOBAL); \
|
||||
SCX_ENUM_SET(skel, scx_dsq_id_flags, SCX_DSQ_LOCAL); \
|
||||
SCX_ENUM_SET(skel, scx_dsq_id_flags, SCX_DSQ_LOCAL_ON); \
|
||||
SCX_ENUM_SET(skel, scx_dsq_id_flags, SCX_DSQ_LOCAL_CPU_MASK); \
|
||||
SCX_ENUM_SET(skel, scx_ent_flags, SCX_TASK_QUEUED); \
|
||||
SCX_ENUM_SET(skel, scx_ent_flags, SCX_TASK_RESET_RUNNABLE_AT); \
|
||||
SCX_ENUM_SET(skel, scx_ent_flags, SCX_TASK_DEQD_FOR_SLEEP); \
|
||||
SCX_ENUM_SET(skel, scx_ent_flags, SCX_TASK_STATE_SHIFT); \
|
||||
SCX_ENUM_SET(skel, scx_ent_flags, SCX_TASK_STATE_BITS); \
|
||||
SCX_ENUM_SET(skel, scx_ent_flags, SCX_TASK_STATE_MASK); \
|
||||
SCX_ENUM_SET(skel, scx_ent_flags, SCX_TASK_CURSOR); \
|
||||
SCX_ENUM_SET(skel, scx_task_state, SCX_TASK_NONE); \
|
||||
SCX_ENUM_SET(skel, scx_task_state, SCX_TASK_INIT); \
|
||||
SCX_ENUM_SET(skel, scx_task_state, SCX_TASK_READY); \
|
||||
SCX_ENUM_SET(skel, scx_task_state, SCX_TASK_ENABLED); \
|
||||
SCX_ENUM_SET(skel, scx_task_state, SCX_TASK_NR_STATES); \
|
||||
SCX_ENUM_SET(skel, scx_ent_dsq_flags, SCX_TASK_DSQ_ON_PRIQ); \
|
||||
SCX_ENUM_SET(skel, scx_kick_flags, SCX_KICK_IDLE); \
|
||||
SCX_ENUM_SET(skel, scx_kick_flags, SCX_KICK_PREEMPT); \
|
||||
SCX_ENUM_SET(skel, scx_kick_flags, SCX_KICK_WAIT); \
|
||||
SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_WAKEUP); \
|
||||
SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_HEAD); \
|
||||
SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_PREEMPT); \
|
||||
SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_REENQ); \
|
||||
SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_LAST); \
|
||||
SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_CLEAR_OPSS); \
|
||||
SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_DSQ_PRIQ); \
|
||||
} while (0)
|
@ -7,49 +7,6 @@
|
||||
#ifndef __SCX_ENUMS_BPF_H
|
||||
#define __SCX_ENUMS_BPF_H
|
||||
|
||||
#include <scx/enums.h>
|
||||
|
||||
#define SCX_ENUM_DEFINE(name) const volatile u64 SCX_ENUM(name);
|
||||
|
||||
SCX_ENUM_DEFINE(SCX_OPS_NAME_LEN);
|
||||
SCX_ENUM_DEFINE(SCX_SLICE_DFL);
|
||||
SCX_ENUM_DEFINE(SCX_SLICE_INF);
|
||||
|
||||
SCX_ENUM_DEFINE(SCX_DSQ_FLAG_BUILTIN);
|
||||
SCX_ENUM_DEFINE(SCX_DSQ_FLAG_LOCAL_ON);
|
||||
SCX_ENUM_DEFINE(SCX_DSQ_INVALID);
|
||||
SCX_ENUM_DEFINE(SCX_DSQ_GLOBAL);
|
||||
SCX_ENUM_DEFINE(SCX_DSQ_LOCAL);
|
||||
SCX_ENUM_DEFINE(SCX_DSQ_LOCAL_ON);
|
||||
SCX_ENUM_DEFINE(SCX_DSQ_LOCAL_CPU_MASK);
|
||||
|
||||
SCX_ENUM_DEFINE(SCX_TASK_QUEUED);
|
||||
SCX_ENUM_DEFINE(SCX_TASK_RESET_RUNNABLE_AT);
|
||||
SCX_ENUM_DEFINE(SCX_TASK_DEQD_FOR_SLEEP);
|
||||
SCX_ENUM_DEFINE(SCX_TASK_STATE_SHIFT);
|
||||
SCX_ENUM_DEFINE(SCX_TASK_STATE_BITS);
|
||||
SCX_ENUM_DEFINE(SCX_TASK_STATE_MASK);
|
||||
SCX_ENUM_DEFINE(SCX_TASK_CURSOR);
|
||||
|
||||
SCX_ENUM_DEFINE(SCX_TASK_NONE);
|
||||
SCX_ENUM_DEFINE(SCX_TASK_INIT);
|
||||
SCX_ENUM_DEFINE(SCX_TASK_READY);
|
||||
SCX_ENUM_DEFINE(SCX_TASK_ENABLED);
|
||||
SCX_ENUM_DEFINE(SCX_TASK_NR_STATES);
|
||||
|
||||
SCX_ENUM_DEFINE(SCX_TASK_DSQ_ON_PRIQ);
|
||||
|
||||
SCX_ENUM_DEFINE(SCX_KICK_IDLE);
|
||||
SCX_ENUM_DEFINE(SCX_KICK_PREEMPT);
|
||||
SCX_ENUM_DEFINE(SCX_KICK_WAIT);
|
||||
|
||||
SCX_ENUM_DEFINE(SCX_ENQ_WAKEUP);
|
||||
SCX_ENUM_DEFINE(SCX_ENQ_HEAD);
|
||||
SCX_ENUM_DEFINE(SCX_ENQ_CPU_SELECTED);
|
||||
SCX_ENUM_DEFINE(SCX_ENQ_PREEMPT);
|
||||
SCX_ENUM_DEFINE(SCX_ENQ_REENQ);
|
||||
SCX_ENUM_DEFINE(SCX_ENQ_LAST);
|
||||
SCX_ENUM_DEFINE(SCX_ENQ_CLEAR_OPSS);
|
||||
SCX_ENUM_DEFINE(SCX_ENQ_DSQ_PRIQ);
|
||||
#include "enums.autogen.bpf.h"
|
||||
|
||||
#endif /* __SCX_ENUMS_BPF_H */
|
||||
|
@ -9,10 +9,6 @@
|
||||
#ifndef __SCX_ENUMS_H
|
||||
#define __SCX_ENUMS_H
|
||||
|
||||
#define SCX_ENUM(name) __##name
|
||||
|
||||
#ifndef __bpf__
|
||||
|
||||
static inline void __ENUM_set(u64 *val, char *type, char *name)
|
||||
{
|
||||
bool res;
|
||||
@ -21,51 +17,11 @@ static inline void __ENUM_set(u64 *val, char *type, char *name)
|
||||
SCX_BUG_ON(!res, "enum not found(%s)", name);
|
||||
}
|
||||
|
||||
#define SCX_ENUM_SET(skel, type, name) do { \
|
||||
__ENUM_set(&skel->rodata->SCX_ENUM(name), #type, #name); \
|
||||
#define SCX_ENUM_SET(skel, type, name) do { \
|
||||
__ENUM_set(&skel->rodata->__##name, #type, #name); \
|
||||
} while (0)
|
||||
|
||||
#define SCX_ENUM_INIT(skel) \
|
||||
SCX_ENUM_SET(skel, scx_public_consts, SCX_OPS_NAME_LEN); \
|
||||
SCX_ENUM_SET(skel, scx_public_consts, SCX_SLICE_DFL); \
|
||||
SCX_ENUM_SET(skel, scx_public_consts, SCX_SLICE_INF); \
|
||||
\
|
||||
SCX_ENUM_SET(skel, scx_dsq_id_flags, SCX_DSQ_FLAG_BUILTIN); \
|
||||
SCX_ENUM_SET(skel, scx_dsq_id_flags, SCX_DSQ_FLAG_LOCAL_ON); \
|
||||
SCX_ENUM_SET(skel, scx_dsq_id_flags, SCX_DSQ_INVALID); \
|
||||
SCX_ENUM_SET(skel, scx_dsq_id_flags, SCX_DSQ_GLOBAL); \
|
||||
SCX_ENUM_SET(skel, scx_dsq_id_flags, SCX_DSQ_LOCAL); \
|
||||
SCX_ENUM_SET(skel, scx_dsq_id_flags, SCX_DSQ_LOCAL_ON); \
|
||||
SCX_ENUM_SET(skel, scx_dsq_id_flags, SCX_DSQ_LOCAL_CPU_MASK); \
|
||||
\
|
||||
SCX_ENUM_SET(skel, scx_ent_flags, SCX_TASK_QUEUED); \
|
||||
SCX_ENUM_SET(skel, scx_ent_flags, SCX_TASK_RESET_RUNNABLE_AT); \
|
||||
SCX_ENUM_SET(skel, scx_ent_flags, SCX_TASK_DEQD_FOR_SLEEP); \
|
||||
SCX_ENUM_SET(skel, scx_ent_flags, SCX_TASK_STATE_SHIFT); \
|
||||
SCX_ENUM_SET(skel, scx_ent_flags, SCX_TASK_STATE_BITS); \
|
||||
SCX_ENUM_SET(skel, scx_ent_flags, SCX_TASK_STATE_MASK); \
|
||||
SCX_ENUM_SET(skel, scx_ent_flags, SCX_TASK_CURSOR); \
|
||||
\
|
||||
SCX_ENUM_SET(skel, scx_task_state, SCX_TASK_NONE); \
|
||||
SCX_ENUM_SET(skel, scx_task_state, SCX_TASK_INIT); \
|
||||
SCX_ENUM_SET(skel, scx_task_state, SCX_TASK_READY); \
|
||||
SCX_ENUM_SET(skel, scx_task_state, SCX_TASK_ENABLED); \
|
||||
SCX_ENUM_SET(skel, scx_task_state, SCX_TASK_NR_STATES); \
|
||||
\
|
||||
SCX_ENUM_SET(skel, scx_ent_dsq_flags, SCX_TASK_DSQ_ON_PRIQ); \
|
||||
\
|
||||
SCX_ENUM_SET(skel, scx_kick_flags, SCX_KICK_IDLE); \
|
||||
SCX_ENUM_SET(skel, scx_kick_flags, SCX_KICK_PREEMPT); \
|
||||
SCX_ENUM_SET(skel, scx_kick_flags, SCX_KICK_WAIT); \
|
||||
\
|
||||
SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_WAKEUP); \
|
||||
SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_HEAD); \
|
||||
SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_PREEMPT); \
|
||||
SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_REENQ); \
|
||||
SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_LAST); \
|
||||
SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_CLEAR_OPSS); \
|
||||
SCX_ENUM_SET(skel, scx_enq_flags, SCX_ENQ_DSQ_PRIQ);
|
||||
|
||||
#endif /* !__bpf__ */
|
||||
#include "enums.autogen.h"
|
||||
|
||||
#endif /* __SCX_ENUMS_H */
|
||||
|
84
scripts/gen_enums.py
Executable file
84
scripts/gen_enums.py
Executable file
@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
warning = """
|
||||
/*
|
||||
* WARNING: This file is autogenerated from scripts/gen_enums.py. If you would
|
||||
* like to access an enum that is currently missing, add it to the script
|
||||
* and run it from the root directory to update this file.
|
||||
*/
|
||||
|
||||
"""
|
||||
|
||||
enums = [
|
||||
("scx_public_consts", "SCX_OPS_NAME_LEN"),
|
||||
("scx_public_consts", "SCX_SLICE_DFL"),
|
||||
("scx_public_consts", "SCX_SLICE_INF"),
|
||||
|
||||
("scx_dsq_id_flags", "SCX_DSQ_FLAG_BUILTIN"),
|
||||
("scx_dsq_id_flags", "SCX_DSQ_FLAG_LOCAL_ON"),
|
||||
("scx_dsq_id_flags", "SCX_DSQ_INVALID"),
|
||||
("scx_dsq_id_flags", "SCX_DSQ_GLOBAL"),
|
||||
("scx_dsq_id_flags", "SCX_DSQ_LOCAL"),
|
||||
("scx_dsq_id_flags", "SCX_DSQ_LOCAL_ON"),
|
||||
("scx_dsq_id_flags", "SCX_DSQ_LOCAL_CPU_MASK"),
|
||||
|
||||
("scx_ent_flags", "SCX_TASK_QUEUED"),
|
||||
("scx_ent_flags", "SCX_TASK_RESET_RUNNABLE_AT"),
|
||||
("scx_ent_flags", "SCX_TASK_DEQD_FOR_SLEEP"),
|
||||
("scx_ent_flags", "SCX_TASK_STATE_SHIFT"),
|
||||
("scx_ent_flags", "SCX_TASK_STATE_BITS"),
|
||||
("scx_ent_flags", "SCX_TASK_STATE_MASK"),
|
||||
("scx_ent_flags", "SCX_TASK_CURSOR"),
|
||||
|
||||
("scx_task_state", "SCX_TASK_NONE"),
|
||||
("scx_task_state", "SCX_TASK_INIT"),
|
||||
("scx_task_state", "SCX_TASK_READY"),
|
||||
("scx_task_state", "SCX_TASK_ENABLED"),
|
||||
("scx_task_state", "SCX_TASK_NR_STATES"),
|
||||
|
||||
("scx_ent_dsq_flags", "SCX_TASK_DSQ_ON_PRIQ"),
|
||||
|
||||
("scx_kick_flags", "SCX_KICK_IDLE"),
|
||||
("scx_kick_flags", "SCX_KICK_PREEMPT"),
|
||||
("scx_kick_flags", "SCX_KICK_WAIT"),
|
||||
|
||||
("scx_enq_flags", "SCX_ENQ_WAKEUP"),
|
||||
("scx_enq_flags", "SCX_ENQ_HEAD"),
|
||||
("scx_enq_flags", "SCX_ENQ_PREEMPT"),
|
||||
("scx_enq_flags", "SCX_ENQ_REENQ"),
|
||||
("scx_enq_flags", "SCX_ENQ_LAST"),
|
||||
("scx_enq_flags", "SCX_ENQ_CLEAR_OPSS"),
|
||||
("scx_enq_flags", "SCX_ENQ_DSQ_PRIQ"),
|
||||
]
|
||||
|
||||
def localvar(symbol):
|
||||
return "__" + symbol
|
||||
|
||||
def gen_enums_bpf_h():
|
||||
autogen = Path.cwd() / "scheds" / "include" / "scx" / "enums.autogen.bpf.h"
|
||||
with open(autogen, "w") as f:
|
||||
f.write(warning)
|
||||
for _, symbol in enums:
|
||||
f.write("const volatile u64 {};\n".format(localvar(symbol)))
|
||||
f.write("#define {} {}\n".format(symbol, localvar(symbol)))
|
||||
f.write("\n")
|
||||
|
||||
|
||||
def gen_enums_h():
|
||||
autogen = Path.cwd() / "scheds" / "include" / "scx" / "enums.autogen.h"
|
||||
with open(autogen, "w") as f:
|
||||
f.write(warning)
|
||||
f.write("#define SCX_ENUM_INIT(skel) do { \\\n")
|
||||
for kind, symbol in enums:
|
||||
f.write("\tSCX_ENUM_SET(skel, {}, {}); \\\n".format(kind, symbol))
|
||||
f.write("} while (0)\n")
|
||||
|
||||
"""
|
||||
Helper script for autogenerating relocatable enum headers.
|
||||
"""
|
||||
if __name__ == "__main__":
|
||||
gen_enums_bpf_h()
|
||||
gen_enums_h()
|
||||
|
Loading…
Reference in New Issue
Block a user