1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Create and destroy DSQs in a loop.
5 * Copyright (c) 2024 Meta Platforms, Inc. and affiliates.
6 * Copyright (c) 2024 David Vernet <dvernet@meta.com>
9 #include <scx/common.bpf.h>
11 char _license
[] SEC("license") = "GPL";
13 void BPF_STRUCT_OPS(create_dsq_exit_task
, struct task_struct
*p
,
14 struct scx_exit_task_args
*args
)
16 scx_bpf_destroy_dsq(p
->pid
);
19 s32
BPF_STRUCT_OPS_SLEEPABLE(create_dsq_init_task
, struct task_struct
*p
,
20 struct scx_init_task_args
*args
)
24 err
= scx_bpf_create_dsq(p
->pid
, -1);
26 scx_bpf_error("Failed to create DSQ for %s[%d]",
32 s32
BPF_STRUCT_OPS_SLEEPABLE(create_dsq_init
)
38 err
= scx_bpf_create_dsq(i
, -1);
40 scx_bpf_error("Failed to create DSQ %d", i
);
46 scx_bpf_destroy_dsq(i
);
52 SEC(".struct_ops.link")
53 struct sched_ext_ops create_dsq_ops
= {
54 .init_task
= (void *) create_dsq_init_task
,
55 .exit_task
= (void *) create_dsq_exit_task
,
56 .init
= (void *) create_dsq_init
,