FILE
maximal.bpf.c
File preview with syntax highlighting.
linux-6.19.14/tools/testing/selftests/sched_ext/maximal.bpf.c
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 13char _license[] SEC("license") = "GPL"; 14 15#define DSQ_ID 0 16 17s32 BPF_STRUCT_OPS(maximal_select_cpu, struct task_struct *p, s32 prev_cpu, 18 u64 wake_flags) 19{ 20 return prev_cpu; 21} 22 23void BPF_STRUCT_OPS(maximal_enqueue, struct task_struct *p, u64 enq_flags) 24{ 25 scx_bpf_dsq_insert(p, DSQ_ID, SCX_SLICE_DFL, enq_flags); 26} 27 28void BPF_STRUCT_OPS(maximal_dequeue, struct task_struct *p, u64 deq_flags) 29{} 30 31void BPF_STRUCT_OPS(maximal_dispatch, s32 cpu, struct task_struct *prev) 32{ 33 scx_bpf_dsq_move_to_local(DSQ_ID); 34} 35 36void BPF_STRUCT_OPS(maximal_runnable, struct task_struct *p, u64 enq_flags) 37{} 38 39void BPF_STRUCT_OPS(maximal_running, struct task_struct *p) 40{} 41 42void BPF_STRUCT_OPS(maximal_stopping, struct task_struct *p, bool runnable) 43{} 44 45void BPF_STRUCT_OPS(maximal_quiescent, struct task_struct *p, u64 deq_flags) 46{} 47 48bool BPF_STRUCT_OPS(maximal_yield, struct task_struct *from, 49 struct task_struct *to) 50{ 51 return false; 52} 53 54bool BPF_STRUCT_OPS(maximal_core_sched_before, struct task_struct *a, 55 struct task_struct *b) 56{ 57 return false; 58} 59 60void BPF_STRUCT_OPS(maximal_set_weight, struct task_struct *p, u32 weight) 61{} 62 63void BPF_STRUCT_OPS(maximal_set_cpumask, struct task_struct *p, 64 const struct cpumask *cpumask) 65{} 66 67void BPF_STRUCT_OPS(maximal_update_idle, s32 cpu, bool idle) 68{} 69 70void BPF_STRUCT_OPS(maximal_cpu_acquire, s32 cpu, 71 struct scx_cpu_acquire_args *args) 72{} 73 74void BPF_STRUCT_OPS(maximal_cpu_release, s32 cpu, 75 struct scx_cpu_release_args *args) 76{} 77 78void BPF_STRUCT_OPS(maximal_cpu_online, s32 cpu) 79{} 80 81void BPF_STRUCT_OPS(maximal_cpu_offline, s32 cpu) 82{} 83 84s32 BPF_STRUCT_OPS(maximal_init_task, struct task_struct *p, 85 struct scx_init_task_args *args) 86{ 87 return 0; 88} 89 90void BPF_STRUCT_OPS(maximal_enable, struct task_struct *p) 91{} 92 93void BPF_STRUCT_OPS(maximal_exit_task, struct task_struct *p, 94 struct scx_exit_task_args *args) 95{} 96 97void BPF_STRUCT_OPS(maximal_disable, struct task_struct *p) 98{} 99 100s32 BPF_STRUCT_OPS(maximal_cgroup_init, struct cgroup *cgrp, 101 struct scx_cgroup_init_args *args) 102{ 103 return 0; 104} 105 106void BPF_STRUCT_OPS(maximal_cgroup_exit, struct cgroup *cgrp) 107{} 108 109s32 BPF_STRUCT_OPS(maximal_cgroup_prep_move, struct task_struct *p, 110 struct cgroup *from, struct cgroup *to) 111{ 112 return 0; 113} 114 115void BPF_STRUCT_OPS(maximal_cgroup_move, struct task_struct *p, 116 struct cgroup *from, struct cgroup *to) 117{} 118 119void BPF_STRUCT_OPS(maximal_cgroup_cancel_move, struct task_struct *p, 120 struct cgroup *from, struct cgroup *to) 121{} 122 123void BPF_STRUCT_OPS(maximal_cgroup_set_weight, struct cgroup *cgrp, u32 weight) 124{} 125 126void BPF_STRUCT_OPS(maximal_cgroup_set_bandwidth, struct cgroup *cgrp, 127 u64 period_us, u64 quota_us, u64 burst_us) 128{} 129 130s32 BPF_STRUCT_OPS_SLEEPABLE(maximal_init) 131{ 132 return scx_bpf_create_dsq(DSQ_ID, -1); 133} 134 135void BPF_STRUCT_OPS(maximal_exit, struct scx_exit_info *info) 136{} 137 138SEC(".struct_ops.link") 139struct sched_ext_ops maximal_ops = { 140 .select_cpu = (void *) maximal_select_cpu, 141 .enqueue = (void *) maximal_enqueue, 142 .dequeue = (void *) maximal_dequeue, 143 .dispatch = (void *) maximal_dispatch, 144 .runnable = (void *) maximal_runnable, 145 .running = (void *) maximal_running, 146 .stopping = (void *) maximal_stopping, 147 .quiescent = (void *) maximal_quiescent, 148 .yield = (void *) maximal_yield, 149 .core_sched_before = (void *) maximal_core_sched_before, 150 .set_weight = (void *) maximal_set_weight, 151 .set_cpumask = (void *) maximal_set_cpumask, 152 .update_idle = (void *) maximal_update_idle, 153 .cpu_acquire = (void *) maximal_cpu_acquire, 154 .cpu_release = (void *) maximal_cpu_release, 155 .cpu_online = (void *) maximal_cpu_online, 156 .cpu_offline = (void *) maximal_cpu_offline, 157 .init_task = (void *) maximal_init_task, 158 .enable = (void *) maximal_enable, 159 .exit_task = (void *) maximal_exit_task, 160 .disable = (void *) maximal_disable, 161 .cgroup_init = (void *) maximal_cgroup_init, 162 .cgroup_exit = (void *) maximal_cgroup_exit, 163 .cgroup_prep_move = (void *) maximal_cgroup_prep_move, 164 .cgroup_move = (void *) maximal_cgroup_move, 165 .cgroup_cancel_move = (void *) maximal_cgroup_cancel_move, 166 .cgroup_set_weight = (void *) maximal_cgroup_set_weight, 167 .cgroup_set_bandwidth = (void *) maximal_cgroup_set_bandwidth, 168 .init = (void *) maximal_init, 169 .exit = (void *) maximal_exit, 170 .name = "maximal", 171};
~/
Read-only file preview.