Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / tools / testing / selftests / sched_ext / select_cpu_dispatch_dbl_dsp.bpf.c
blob0fda57fe0ecfaecc5a5cfaebe2589f563f7ad579
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * A scheduler that validates the behavior of direct dispatching with a default
4 * select_cpu implementation.
6 * Copyright (c) 2023 Meta Platforms, Inc. and affiliates.
7 * Copyright (c) 2023 David Vernet <dvernet@meta.com>
8 * Copyright (c) 2023 Tejun Heo <tj@kernel.org>
9 */
11 #include <scx/common.bpf.h>
13 char _license[] SEC("license") = "GPL";
15 UEI_DEFINE(uei);
17 s32 BPF_STRUCT_OPS(select_cpu_dispatch_dbl_dsp_select_cpu, struct task_struct *p,
18 s32 prev_cpu, u64 wake_flags)
20 /* Dispatching twice in a row is disallowed. */
21 scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, 0);
22 scx_bpf_dispatch(p, SCX_DSQ_GLOBAL, SCX_SLICE_DFL, 0);
24 return prev_cpu;
27 void BPF_STRUCT_OPS(select_cpu_dispatch_dbl_dsp_exit, struct scx_exit_info *ei)
29 UEI_RECORD(uei, ei);
32 SEC(".struct_ops.link")
33 struct sched_ext_ops select_cpu_dispatch_dbl_dsp_ops = {
34 .select_cpu = (void *) select_cpu_dispatch_dbl_dsp_select_cpu,
35 .exit = (void *) select_cpu_dispatch_dbl_dsp_exit,
36 .name = "select_cpu_dispatch_dbl_dsp",
37 .timeout_ms = 1000U,