xref: /linux/tools/testing/selftests/sched_ext/maybe_null_fail_yld.bpf.c (revision daa9f66fe194f672d2c94d879b6dad7035e03ebe)
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 
BPF_STRUCT_OPS(maybe_null_running,struct task_struct * p)12 void BPF_STRUCT_OPS(maybe_null_running, struct task_struct *p)
13 {}
14 
BPF_STRUCT_OPS(maybe_null_fail_yield,struct task_struct * from,struct task_struct * to)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			= (void *) maybe_null_fail_yield,
26 	.enable			= (void *) maybe_null_running,
27 	.name			= "maybe_null_fail_yield",
28 };
29