1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2023 Meta Platforms, Inc. and affiliates. 4 * Copyright (c) 2023 David Vernet <dvernet@meta.com> 5 * Copyright (c) 2023 Tejun Heo <tj@kernel.org> 6 */ 7 8 #include <scx/common.bpf.h> 9 10 char _license[] SEC("license") = "GPL"; 11 12 /* Manually specify the signature until the kfunc is added to the scx repo. */ 13 s32 scx_bpf_select_cpu_dfl(struct task_struct *p, s32 prev_cpu, u64 wake_flags, 14 bool *found) __ksym; 15 16 s32 BPF_STRUCT_OPS(enq_select_cpu_fails_select_cpu, struct task_struct *p, 17 s32 prev_cpu, u64 wake_flags) 18 { 19 return prev_cpu; 20 } 21 22 void BPF_STRUCT_OPS(enq_select_cpu_fails_enqueue, struct task_struct *p, 23 u64 enq_flags) 24 { 25 /* 26 * Need to initialize the variable or the verifier will fail to load. 27 * Improving these semantics is actively being worked on. 28 */ 29 bool found = false; 30 31 /* Can only call from ops.select_cpu() */ 32 scx_bpf_select_cpu_dfl(p, 0, 0, &found); 33 34 scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, enq_flags); 35 } 36 37 SEC(".struct_ops.link") 38 struct sched_ext_ops enq_select_cpu_fails_ops = { 39 .select_cpu = (void *) enq_select_cpu_fails_select_cpu, 40 .enqueue = (void *) enq_select_cpu_fails_enqueue, 41 .name = "enq_select_cpu_fails", 42 .timeout_ms = 1000U, 43 }; 44
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.