mirror of
https://github.com/sched-ext/scx.git
synced 2024-11-27 21:20:24 +00:00
factor enum handling into existing headers/operations
This commit is contained in:
parent
a1d0e7e638
commit
c545d23e79
@ -46,7 +46,6 @@
|
||||
* Copyright (c) 2022 David Vernet <dvernet@meta.com>
|
||||
*/
|
||||
#include <scx/common.bpf.h>
|
||||
#include <scx/enums.bpf.h>
|
||||
|
||||
char _license[] SEC("license") = "GPL";
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include <libgen.h>
|
||||
#include <bpf/bpf.h>
|
||||
#include <scx/common.h>
|
||||
#include <scx/enums.h>
|
||||
#include "scx_central.bpf.skel.h"
|
||||
|
||||
const char help_fmt[] =
|
||||
@ -56,7 +55,6 @@ int main(int argc, char **argv)
|
||||
signal(SIGTERM, sigint_handler);
|
||||
restart:
|
||||
skel = SCX_OPS_OPEN(central_ops, scx_central);
|
||||
SCX_ENUM_INIT(skel);
|
||||
|
||||
skel->rodata->central_cpu = 0;
|
||||
skel->rodata->nr_cpu_ids = libbpf_num_possible_cpus();
|
||||
|
@ -54,7 +54,7 @@
|
||||
char _license[] SEC("license") = "GPL";
|
||||
|
||||
const volatile u32 nr_cpus = 32; /* !0 for veristat, set during init */
|
||||
const volatile u64 cgrp_slice_ns = SCX_SLICE_DFL;
|
||||
const volatile u64 cgrp_slice_ns;
|
||||
const volatile bool fifo_sched;
|
||||
|
||||
u64 cvtime_now;
|
||||
|
@ -137,6 +137,7 @@ restart:
|
||||
skel = SCX_OPS_OPEN(flatcg_ops, scx_flatcg);
|
||||
|
||||
skel->rodata->nr_cpus = libbpf_num_possible_cpus();
|
||||
skel->rodata->cgrp_slice_ns = __COMPAT_ENUM_OR_ZERO("scx_public_consts", "SCX_SLICE_DFL");
|
||||
|
||||
while ((opt = getopt(argc, argv, "s:i:dfvh")) != -1) {
|
||||
double v;
|
||||
|
@ -47,7 +47,7 @@ enum {
|
||||
const volatile u64 p_remove_ns = 2 * NSEC_PER_MSEC;
|
||||
const volatile u64 r_max = 5;
|
||||
const volatile u64 r_impatient = 2;
|
||||
const volatile u64 slice_ns = SCX_SLICE_DFL;
|
||||
const volatile u64 slice_ns;
|
||||
const volatile bool find_fully_idle = false;
|
||||
const volatile u64 sampling_cadence_ns = 1 * NSEC_PER_SEC;
|
||||
const volatile u64 r_depth = 5;
|
||||
|
@ -171,6 +171,7 @@ restart:
|
||||
|
||||
skel->rodata->nr_cpus = libbpf_num_possible_cpus();
|
||||
skel->rodata->sampling_cadence_ns = SAMPLING_CADENCE_S * 1000 * 1000 * 1000;
|
||||
skel->rodata->slice_ns = __COMPAT_ENUM_OR_ZERO("scx_public_consts", "SCX_SLICE_DFL");
|
||||
|
||||
while ((opt = getopt(argc, argv, "d:m:i:Is:vh")) != -1) {
|
||||
switch (opt) {
|
||||
|
@ -124,7 +124,7 @@ char _license[] SEC("license") = "GPL";
|
||||
const volatile u32 nr_cpu_ids = 1;
|
||||
|
||||
/* a pair of CPUs stay on a cgroup for this duration */
|
||||
const volatile u32 pair_batch_dur_ns = SCX_SLICE_DFL;
|
||||
const volatile u32 pair_batch_dur_ns;
|
||||
|
||||
/* cpu ID -> pair cpu ID */
|
||||
const volatile s32 RESIZABLE_ARRAY(rodata, pair_cpu);
|
||||
|
@ -55,6 +55,7 @@ restart:
|
||||
skel = SCX_OPS_OPEN(pair_ops, scx_pair);
|
||||
|
||||
skel->rodata->nr_cpu_ids = libbpf_num_possible_cpus();
|
||||
skel->rodata->pair_batch_dur_ns = __COMPAT_ENUM_OR_ZERO("scx_public_consts", "SCX_SLICE_DFL");
|
||||
|
||||
/* pair up the earlier half to the latter by default, override with -s */
|
||||
stride = skel->rodata->nr_cpu_ids / 2;
|
||||
|
@ -33,7 +33,7 @@ enum consts {
|
||||
|
||||
char _license[] SEC("license") = "GPL";
|
||||
|
||||
const volatile u64 slice_ns = SCX_SLICE_DFL;
|
||||
const volatile u64 slice_ns;
|
||||
const volatile u32 stall_user_nth;
|
||||
const volatile u32 stall_kernel_nth;
|
||||
const volatile u32 dsp_inf_loop_after;
|
||||
|
@ -64,6 +64,8 @@ int main(int argc, char **argv)
|
||||
|
||||
skel = SCX_OPS_OPEN(qmap_ops, scx_qmap);
|
||||
|
||||
skel->rodata->slice_ns = __COMPAT_ENUM_OR_ZERO("scx_public_consts", "SCX_SLICE_DFL");
|
||||
|
||||
while ((opt = getopt(argc, argv, "s:e:t:T:l:b:PHd:D:Spvh")) != -1) {
|
||||
switch (opt) {
|
||||
case 's':
|
||||
|
@ -467,5 +467,6 @@ static inline u32 log2_u64(u64 v) {
|
||||
}
|
||||
|
||||
#include "compat.bpf.h"
|
||||
#include "enums.bpf.h"
|
||||
|
||||
#endif /* __SCX_COMMON_BPF_H */
|
||||
|
@ -71,5 +71,6 @@ typedef int64_t s64;
|
||||
|
||||
#include "user_exit_info.h"
|
||||
#include "compat.h"
|
||||
#include "enums.h"
|
||||
|
||||
#endif /* __SCHED_EXT_COMMON_H */
|
||||
|
@ -149,6 +149,7 @@ static inline long scx_hotplug_seq(void)
|
||||
__skel = __scx_name##__open(); \
|
||||
SCX_BUG_ON(!__skel, "Could not open " #__scx_name); \
|
||||
__skel->struct_ops.__ops_name->hotplug_seq = scx_hotplug_seq(); \
|
||||
SCX_ENUM_INIT(__skel); \
|
||||
__skel; \
|
||||
})
|
||||
|
||||
|
@ -5,102 +5,102 @@
|
||||
* and run it from the root directory to update this file.
|
||||
*/
|
||||
|
||||
const volatile u64 __SCX_OPS_NAME_LEN;
|
||||
const volatile u64 __SCX_OPS_NAME_LEN __weak;
|
||||
#define SCX_OPS_NAME_LEN __SCX_OPS_NAME_LEN
|
||||
|
||||
const volatile u64 __SCX_SLICE_DFL;
|
||||
const volatile u64 __SCX_SLICE_DFL __weak;
|
||||
#define SCX_SLICE_DFL __SCX_SLICE_DFL
|
||||
|
||||
const volatile u64 __SCX_SLICE_INF;
|
||||
const volatile u64 __SCX_SLICE_INF __weak;
|
||||
#define SCX_SLICE_INF __SCX_SLICE_INF
|
||||
|
||||
const volatile u64 __SCX_DSQ_FLAG_BUILTIN;
|
||||
const volatile u64 __SCX_DSQ_FLAG_BUILTIN __weak;
|
||||
#define SCX_DSQ_FLAG_BUILTIN __SCX_DSQ_FLAG_BUILTIN
|
||||
|
||||
const volatile u64 __SCX_DSQ_FLAG_LOCAL_ON;
|
||||
const volatile u64 __SCX_DSQ_FLAG_LOCAL_ON __weak;
|
||||
#define SCX_DSQ_FLAG_LOCAL_ON __SCX_DSQ_FLAG_LOCAL_ON
|
||||
|
||||
const volatile u64 __SCX_DSQ_INVALID;
|
||||
const volatile u64 __SCX_DSQ_INVALID __weak;
|
||||
#define SCX_DSQ_INVALID __SCX_DSQ_INVALID
|
||||
|
||||
const volatile u64 __SCX_DSQ_GLOBAL;
|
||||
const volatile u64 __SCX_DSQ_GLOBAL __weak;
|
||||
#define SCX_DSQ_GLOBAL __SCX_DSQ_GLOBAL
|
||||
|
||||
const volatile u64 __SCX_DSQ_LOCAL;
|
||||
const volatile u64 __SCX_DSQ_LOCAL __weak;
|
||||
#define SCX_DSQ_LOCAL __SCX_DSQ_LOCAL
|
||||
|
||||
const volatile u64 __SCX_DSQ_LOCAL_ON;
|
||||
const volatile u64 __SCX_DSQ_LOCAL_ON __weak;
|
||||
#define SCX_DSQ_LOCAL_ON __SCX_DSQ_LOCAL_ON
|
||||
|
||||
const volatile u64 __SCX_DSQ_LOCAL_CPU_MASK;
|
||||
const volatile u64 __SCX_DSQ_LOCAL_CPU_MASK __weak;
|
||||
#define SCX_DSQ_LOCAL_CPU_MASK __SCX_DSQ_LOCAL_CPU_MASK
|
||||
|
||||
const volatile u64 __SCX_TASK_QUEUED;
|
||||
const volatile u64 __SCX_TASK_QUEUED __weak;
|
||||
#define SCX_TASK_QUEUED __SCX_TASK_QUEUED
|
||||
|
||||
const volatile u64 __SCX_TASK_RESET_RUNNABLE_AT;
|
||||
const volatile u64 __SCX_TASK_RESET_RUNNABLE_AT __weak;
|
||||
#define SCX_TASK_RESET_RUNNABLE_AT __SCX_TASK_RESET_RUNNABLE_AT
|
||||
|
||||
const volatile u64 __SCX_TASK_DEQD_FOR_SLEEP;
|
||||
const volatile u64 __SCX_TASK_DEQD_FOR_SLEEP __weak;
|
||||
#define SCX_TASK_DEQD_FOR_SLEEP __SCX_TASK_DEQD_FOR_SLEEP
|
||||
|
||||
const volatile u64 __SCX_TASK_STATE_SHIFT;
|
||||
const volatile u64 __SCX_TASK_STATE_SHIFT __weak;
|
||||
#define SCX_TASK_STATE_SHIFT __SCX_TASK_STATE_SHIFT
|
||||
|
||||
const volatile u64 __SCX_TASK_STATE_BITS;
|
||||
const volatile u64 __SCX_TASK_STATE_BITS __weak;
|
||||
#define SCX_TASK_STATE_BITS __SCX_TASK_STATE_BITS
|
||||
|
||||
const volatile u64 __SCX_TASK_STATE_MASK;
|
||||
const volatile u64 __SCX_TASK_STATE_MASK __weak;
|
||||
#define SCX_TASK_STATE_MASK __SCX_TASK_STATE_MASK
|
||||
|
||||
const volatile u64 __SCX_TASK_CURSOR;
|
||||
const volatile u64 __SCX_TASK_CURSOR __weak;
|
||||
#define SCX_TASK_CURSOR __SCX_TASK_CURSOR
|
||||
|
||||
const volatile u64 __SCX_TASK_NONE;
|
||||
const volatile u64 __SCX_TASK_NONE __weak;
|
||||
#define SCX_TASK_NONE __SCX_TASK_NONE
|
||||
|
||||
const volatile u64 __SCX_TASK_INIT;
|
||||
const volatile u64 __SCX_TASK_INIT __weak;
|
||||
#define SCX_TASK_INIT __SCX_TASK_INIT
|
||||
|
||||
const volatile u64 __SCX_TASK_READY;
|
||||
const volatile u64 __SCX_TASK_READY __weak;
|
||||
#define SCX_TASK_READY __SCX_TASK_READY
|
||||
|
||||
const volatile u64 __SCX_TASK_ENABLED;
|
||||
const volatile u64 __SCX_TASK_ENABLED __weak;
|
||||
#define SCX_TASK_ENABLED __SCX_TASK_ENABLED
|
||||
|
||||
const volatile u64 __SCX_TASK_NR_STATES;
|
||||
const volatile u64 __SCX_TASK_NR_STATES __weak;
|
||||
#define SCX_TASK_NR_STATES __SCX_TASK_NR_STATES
|
||||
|
||||
const volatile u64 __SCX_TASK_DSQ_ON_PRIQ;
|
||||
const volatile u64 __SCX_TASK_DSQ_ON_PRIQ __weak;
|
||||
#define SCX_TASK_DSQ_ON_PRIQ __SCX_TASK_DSQ_ON_PRIQ
|
||||
|
||||
const volatile u64 __SCX_KICK_IDLE;
|
||||
const volatile u64 __SCX_KICK_IDLE __weak;
|
||||
#define SCX_KICK_IDLE __SCX_KICK_IDLE
|
||||
|
||||
const volatile u64 __SCX_KICK_PREEMPT;
|
||||
const volatile u64 __SCX_KICK_PREEMPT __weak;
|
||||
#define SCX_KICK_PREEMPT __SCX_KICK_PREEMPT
|
||||
|
||||
const volatile u64 __SCX_KICK_WAIT;
|
||||
const volatile u64 __SCX_KICK_WAIT __weak;
|
||||
#define SCX_KICK_WAIT __SCX_KICK_WAIT
|
||||
|
||||
const volatile u64 __SCX_ENQ_WAKEUP;
|
||||
const volatile u64 __SCX_ENQ_WAKEUP __weak;
|
||||
#define SCX_ENQ_WAKEUP __SCX_ENQ_WAKEUP
|
||||
|
||||
const volatile u64 __SCX_ENQ_HEAD;
|
||||
const volatile u64 __SCX_ENQ_HEAD __weak;
|
||||
#define SCX_ENQ_HEAD __SCX_ENQ_HEAD
|
||||
|
||||
const volatile u64 __SCX_ENQ_PREEMPT;
|
||||
const volatile u64 __SCX_ENQ_PREEMPT __weak;
|
||||
#define SCX_ENQ_PREEMPT __SCX_ENQ_PREEMPT
|
||||
|
||||
const volatile u64 __SCX_ENQ_REENQ;
|
||||
const volatile u64 __SCX_ENQ_REENQ __weak;
|
||||
#define SCX_ENQ_REENQ __SCX_ENQ_REENQ
|
||||
|
||||
const volatile u64 __SCX_ENQ_LAST;
|
||||
const volatile u64 __SCX_ENQ_LAST __weak;
|
||||
#define SCX_ENQ_LAST __SCX_ENQ_LAST
|
||||
|
||||
const volatile u64 __SCX_ENQ_CLEAR_OPSS;
|
||||
const volatile u64 __SCX_ENQ_CLEAR_OPSS __weak;
|
||||
#define SCX_ENQ_CLEAR_OPSS __SCX_ENQ_CLEAR_OPSS
|
||||
|
||||
const volatile u64 __SCX_ENQ_DSQ_PRIQ;
|
||||
const volatile u64 __SCX_ENQ_DSQ_PRIQ __weak;
|
||||
#define SCX_ENQ_DSQ_PRIQ __SCX_ENQ_DSQ_PRIQ
|
||||
|
||||
|
@ -61,7 +61,7 @@ def gen_enums_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("const volatile u64 {} __weak;\n".format(localvar(symbol)))
|
||||
f.write("#define {} {}\n".format(symbol, localvar(symbol)))
|
||||
f.write("\n")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user