File Index
Files and directories
Sign in
FILE

select_cpu_dispatch_bad_dsq.bpf.c

File preview with syntax highlighting.

linux-6.19.14/tools/testing/selftests/sched_ext/select_cpu_dispatch_bad_dsq.bpf.c C
 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.
 5 *
 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 */
10
11#include <scx/common.bpf.h>
12
13char _license[] SEC("license") = "GPL";
14
15UEI_DEFINE(uei);
16
17s32 BPF_STRUCT_OPS(select_cpu_dispatch_bad_dsq_select_cpu, struct task_struct *p,
18		   s32 prev_cpu, u64 wake_flags)
19{
20	/* Dispatching to a random DSQ should fail. */
21	scx_bpf_dsq_insert(p, 0xcafef00d, SCX_SLICE_DFL, 0);
22
23	return prev_cpu;
24}
25
26void BPF_STRUCT_OPS(select_cpu_dispatch_bad_dsq_exit, struct scx_exit_info *ei)
27{
28	UEI_RECORD(uei, ei);
29}
30
31SEC(".struct_ops.link")
32struct sched_ext_ops select_cpu_dispatch_bad_dsq_ops = {
33	.select_cpu		= (void *) select_cpu_dispatch_bad_dsq_select_cpu,
34	.exit			= (void *) select_cpu_dispatch_bad_dsq_exit,
35	.name			= "select_cpu_dispatch_bad_dsq",
36	.timeout_ms		= 1000U,
37};
~/ Read-only file preview.