1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * A scheduler with every callback defined. 4 * 5 * This scheduler defines every callback. 6 * 7 * Copyright (c) 2024 Meta Platforms, Inc. and affiliates. 8 * Copyright (c) 2024 David Vernet <dvernet@meta.com> 9 */ 10 11 #include <scx/common.bpf.h> 12 13 char _license[] SEC("license") = "GPL"; 14 15 s32 BPF_STRUCT_OPS(maximal_select_cpu, struct task_struct *p, s32 prev_cpu, 16 u64 wake_flags) 17 { 18 return prev_cpu; 19 } 20 21 void BPF_STRUCT_OPS(maximal_enqueue, struct task_struct *p, u64 enq_flags) 22 { 23 scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); 24 } 25 26 void BPF_STRUCT_OPS(maximal_dequeue, struct task_struct *p, u64 deq_flags) 27 {} 28 29 void BPF_STRUCT_OPS(maximal_dispatch, s32 cpu, struct task_struct *prev) 30 { 31 scx_bpf_consume(SCX_DSQ_GLOBAL); 32 } 33 34 void BPF_STRUCT_OPS(maximal_runnable, struct task_struct *p, u64 enq_flags) 35 {} 36 37 void BPF_STRUCT_OPS(maximal_running, struct task_struct *p) 38 {} 39 40 void BPF_STRUCT_OPS(maximal_stopping, struct task_struct *p, bool runnable) 41 {} 42 43 void BPF_STRUCT_OPS(maximal_quiescent, struct task_struct *p, u64 deq_flags) 44 {} 45 46 bool BPF_STRUCT_OPS(maximal_yield, struct task_struct *from, 47 struct task_struct *to) 48 { 49 return false; 50 } 51 52 bool BPF_STRUCT_OPS(maximal_core_sched_before, struct task_struct *a, 53 struct task_struct *b) 54 { 55 return false; 56 } 57 58 void BPF_STRUCT_OPS(maximal_set_weight, struct task_struct *p, u32 weight) 59 {} 60 61 void BPF_STRUCT_OPS(maximal_set_cpumask, struct task_struct *p, 62 const struct cpumask *cpumask) 63 {} 64 65 void BPF_STRUCT_OPS(maximal_update_idle, s32 cpu, bool idle) 66 {} 67 68 void BPF_STRUCT_OPS(maximal_cpu_acquire, s32 cpu, 69 struct scx_cpu_acquire_args *args) 70 {} 71 72 void BPF_STRUCT_OPS(maximal_cpu_release, s32 cpu, 73 struct scx_cpu_release_args *args) 74 {} 75 76 void BPF_STRUCT_OPS(maximal_cpu_online, s32 cpu) 77 {} 78 79 void BPF_STRUCT_OPS(maximal_cpu_offline, s32 cpu) 80 {} 81 82 s32 BPF_STRUCT_OPS(maximal_init_task, struct task_struct *p, 83 struct scx_init_task_args *args) 84 { 85 return 0; 86 } 87 88 void BPF_STRUCT_OPS(maximal_enable, struct task_struct *p) 89 {} 90 91 void BPF_STRUCT_OPS(maximal_exit_task, struct task_struct *p, 92 struct scx_exit_task_args *args) 93 {} 94 95 void BPF_STRUCT_OPS(maximal_disable, struct task_struct *p) 96 {} 97 98 s32 BPF_STRUCT_OPS(maximal_cgroup_init, struct cgroup *cgrp, 99 struct scx_cgroup_init_args *args) 100 { 101 return 0; 102 } 103 104 void BPF_STRUCT_OPS(maximal_cgroup_exit, struct cgroup *cgrp) 105 {} 106 107 s32 BPF_STRUCT_OPS(maximal_cgroup_prep_move, struct task_struct *p, 108 struct cgroup *from, struct cgroup *to) 109 { 110 return 0; 111 } 112 113 void BPF_STRUCT_OPS(maximal_cgroup_move, struct task_struct *p, 114 struct cgroup *from, struct cgroup *to) 115 {} 116 117 void BPF_STRUCT_OPS(maximal_cgroup_cancel_move, struct task_struct *p, 118 struct cgroup *from, struct cgroup *to) 119 {} 120 121 void BPF_STRUCT_OPS(maximal_cgroup_set_weight, struct cgroup *cgrp, u32 weight) 122 {} 123 124 s32 BPF_STRUCT_OPS_SLEEPABLE(maximal_init) 125 { 126 return 0; 127 } 128 129 void BPF_STRUCT_OPS(maximal_exit, struct scx_exit_info *info) 130 {} 131 132 SEC(".struct_ops.link") 133 struct sched_ext_ops maximal_ops = { 134 .select_cpu = (void *) maximal_select_cpu, 135 .enqueue = (void *) maximal_enqueue, 136 .dequeue = (void *) maximal_dequeue, 137 .dispatch = (void *) maximal_dispatch, 138 .runnable = (void *) maximal_runnable, 139 .running = (void *) maximal_running, 140 .stopping = (void *) maximal_stopping, 141 .quiescent = (void *) maximal_quiescent, 142 .yield = (void *) maximal_yield, 143 .core_sched_before = (void *) maximal_core_sched_before, 144 .set_weight = (void *) maximal_set_weight, 145 .set_cpumask = (void *) maximal_set_cpumask, 146 .update_idle = (void *) maximal_update_idle, 147 .cpu_acquire = (void *) maximal_cpu_acquire, 148 .cpu_release = (void *) maximal_cpu_release, 149 .cpu_online = (void *) maximal_cpu_online, 150 .cpu_offline = (void *) maximal_cpu_offline, 151 .init_task = (void *) maximal_init_task, 152 .enable = (void *) maximal_enable, 153 .exit_task = (void *) maximal_exit_task, 154 .disable = (void *) maximal_disable, 155 .cgroup_init = (void *) maximal_cgroup_init, 156 .cgroup_exit = (void *) maximal_cgroup_exit, 157 .cgroup_prep_move = (void *) maximal_cgroup_prep_move, 158 .cgroup_move = (void *) maximal_cgroup_move, 159 .cgroup_cancel_move = (void *) maximal_cgroup_cancel_move, 160 .cgroup_set_weight = (void *) maximal_cgroup_set_weight, 161 .init = (void *) maximal_init, 162 .exit = (void *) maximal_exit, 163 .name = "maximal", 164 }; 165