xref: /linux/tools/testing/selftests/sched_ext/maybe_null_fail_dsp.bpf.c (revision daa9f66fe194f672d2c94d879b6dad7035e03ebe)
1a5db7817SDavid Vernet /* SPDX-License-Identifier: GPL-2.0 */
2a5db7817SDavid Vernet /*
3a5db7817SDavid Vernet  * Copyright (c) 2024 Meta Platforms, Inc. and affiliates.
4a5db7817SDavid Vernet  */
5a5db7817SDavid Vernet 
6a5db7817SDavid Vernet #include <scx/common.bpf.h>
7a5db7817SDavid Vernet 
8a5db7817SDavid Vernet char _license[] SEC("license") = "GPL";
9a5db7817SDavid Vernet 
10a5db7817SDavid Vernet u64 vtime_test;
11a5db7817SDavid Vernet 
BPF_STRUCT_OPS(maybe_null_running,struct task_struct * p)12a5db7817SDavid Vernet void BPF_STRUCT_OPS(maybe_null_running, struct task_struct *p)
13a5db7817SDavid Vernet {}
14a5db7817SDavid Vernet 
BPF_STRUCT_OPS(maybe_null_fail_dispatch,s32 cpu,struct task_struct * p)15a5db7817SDavid Vernet void BPF_STRUCT_OPS(maybe_null_fail_dispatch, s32 cpu, struct task_struct *p)
16a5db7817SDavid Vernet {
17a5db7817SDavid Vernet 	vtime_test = p->scx.dsq_vtime;
18a5db7817SDavid Vernet }
19a5db7817SDavid Vernet 
20a5db7817SDavid Vernet SEC(".struct_ops.link")
21a5db7817SDavid Vernet struct sched_ext_ops maybe_null_fail = {
22*4f7f4170SVishal Chourasia 	.dispatch               = (void *) maybe_null_fail_dispatch,
23*4f7f4170SVishal Chourasia 	.enable			= (void *) maybe_null_running,
24a5db7817SDavid Vernet 	.name			= "maybe_null_fail_dispatch",
25a5db7817SDavid Vernet };
26