xref: /linux/tools/testing/selftests/sched_ext/maybe_null_fail_yld.bpf.c (revision 566ab427f827b0256d3e8ce0235d088e6a9c28bd)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (c) 2024 Meta Platforms, Inc. and affiliates.
4  */
5 
6 #include <scx/common.bpf.h>
7 
8 char _license[] SEC("license") = "GPL";
9 
10 u64 vtime_test;
11 
12 void BPF_STRUCT_OPS(maybe_null_running, struct task_struct *p)
13 {}
14 
15 bool BPF_STRUCT_OPS(maybe_null_fail_yield, struct task_struct *from,
16 		    struct task_struct *to)
17 {
18 	bpf_printk("Yielding to %s[%d]", to->comm, to->pid);
19 
20 	return false;
21 }
22 
23 SEC(".struct_ops.link")
24 struct sched_ext_ops maybe_null_fail = {
25 	.yield			= maybe_null_fail_yield,
26 	.enable			= maybe_null_running,
27 	.name			= "maybe_null_fail_yield",
28 };
29